Class: PGit::Project
- Inherits:
-
PGit::Pivotal::IndividualRequest
- Object
- PGit::Pivotal::Request
- PGit::Pivotal::IndividualRequest
- PGit::Project
- Extended by:
- Helpers::QueryMethods
- Includes:
- ActiveModel::Validations, Helpers::QueryMethods
- Defined in:
- lib/pgit/project.rb,
lib/pgit/project/add.rb,
lib/pgit/project/remove.rb,
lib/pgit/project/application.rb,
lib/pgit/project/interactive_adder.rb,
lib/pgit/project/reuse_api_token_adder.rb
Defined Under Namespace
Classes: Add, Application, InteractiveAdder, Remove, ReuseApiTokenAdder
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#id ⇒ Object
Returns the value of attribute id.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #commands ⇒ Object
- #commands=(some_commands) ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(configuration = :no_config_given, proj = {}) {|_self| ... } ⇒ Project
constructor
A new instance of Project.
- #remove! ⇒ Object
- #save! ⇒ Object
- #sublink ⇒ Object
- #to_hash ⇒ Object
Methods included from Helpers::QueryMethods
attr_given, attr_has, attr_query, defaulted_attrs, ensure_given_attr, ensure_given_queries, given_attrs, not_given, set_attr, set_default_attr, set_default_queries
Methods inherited from PGit::Pivotal::IndividualRequest
#define_methods, #get!, #hash=, #put!
Methods inherited from PGit::Pivotal::Request
#api_version, #before_initialize, #current_project, #get_request, #link
Constructor Details
#initialize(configuration = :no_config_given, proj = {}) {|_self| ... } ⇒ Project
Returns a new instance of Project.
15 16 17 18 19 20 21 22 23 |
# File 'lib/pgit/project.rb', line 15 def initialize(configuration=:no_config_given, proj={}, &block) yield self if block_given? @query_hash = proj @configuration = configuration @cmds = proj.fetch('commands') { Array.new } set_default_queries end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
12 13 14 |
# File 'lib/pgit/project.rb', line 12 def api_token @api_token end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/pgit/project.rb', line 12 def configuration @configuration end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/pgit/project.rb', line 12 def id @id end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
12 13 14 |
# File 'lib/pgit/project.rb', line 12 def kind @kind end |
#path ⇒ Object
Returns the value of attribute path.
12 13 14 |
# File 'lib/pgit/project.rb', line 12 def path @path end |
Instance Method Details
#commands ⇒ Object
29 30 31 |
# File 'lib/pgit/project.rb', line 29 def commands build_commands(@cmds) end |
#commands=(some_commands) ⇒ Object
25 26 27 |
# File 'lib/pgit/project.rb', line 25 def commands=(some_commands) @cmds = some_commands end |
#exists? ⇒ Boolean
53 54 55 |
# File 'lib/pgit/project.rb', line 53 def exists? configuration.projects.find {|p| p.path == path} end |
#remove! ⇒ Object
49 50 51 |
# File 'lib/pgit/project.rb', line 49 def remove! remove_old_copy end |
#save! ⇒ Object
42 43 44 45 46 47 |
# File 'lib/pgit/project.rb', line 42 def save! ensure_given_queries raise PGit::Error::User, errors..first unless valid? remove_old_copy { configuration.projects = configuration.projects << self } end |
#sublink ⇒ Object
57 58 59 |
# File 'lib/pgit/project.rb', line 57 def sublink "projects/#{id}" end |
#to_hash ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/pgit/project.rb', line 33 def to_hash { "path" => path, "api_token" => api_token, "id" => id, "commands" => commands.map {|cmd| cmd.to_hash} } end |