Class: Sem::API::Project
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Sem::API::Project
- Extended by:
- Base
- Defined in:
- lib/sem/api/project.rb
Instance Attribute Summary collapse
-
#org_name ⇒ Object
readonly
Returns the value of attribute org_name.
Class Method Summary collapse
Instance Method Summary collapse
- #add_config_file(config_file) ⇒ Object
- #add_env_var(env_var) ⇒ Object
- #add_shared_config(shared_config) ⇒ Object
- #config_files ⇒ Object
- #env_vars ⇒ Object
- #full_name ⇒ Object
-
#initialize(org_name, project) ⇒ Project
constructor
A new instance of Project.
- #remove_shared_config(shared_config) ⇒ Object
- #shared_configs ⇒ Object
- #teams ⇒ Object
Methods included from Base
Constructor Details
#initialize(org_name, project) ⇒ Project
Returns a new instance of Project.
24 25 26 27 28 |
# File 'lib/sem/api/project.rb', line 24 def initialize(org_name, project) @org_name = org_name super(project) end |
Instance Attribute Details
#org_name ⇒ Object (readonly)
Returns the value of attribute org_name.
22 23 24 |
# File 'lib/sem/api/project.rb', line 22 def org_name @org_name end |
Class Method Details
.all ⇒ Object
4 5 6 7 8 |
# File 'lib/sem/api/project.rb', line 4 def self.all Sem::API::Org.all.map do |org| client.projects.list_for_org(org.username).map { |project| new(org.username, project) } end.flatten end |
.find!(project_srn) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sem/api/project.rb', line 10 def self.find!(project_srn) org_name, project_name = Sem::SRN.parse_project(project_srn) # TODO: fix .to_a bug in client project = client.projects.list_for_org(org_name, :name => project_name).to_a.first raise Sem::Errors::ResourceNotFound.new("Project", [org_name, project_name]) if project.nil? new(org_name, project) end |
Instance Method Details
#add_config_file(config_file) ⇒ Object
62 63 64 |
# File 'lib/sem/api/project.rb', line 62 def add_config_file(config_file) Sem::API::Base.client.config_files.attach_to_project(config_file.id, id) end |
#add_env_var(env_var) ⇒ Object
58 59 60 |
# File 'lib/sem/api/project.rb', line 58 def add_env_var(env_var) Sem::API::Base.client.env_vars.attach_to_project(env_var.id, id) end |
#add_shared_config(shared_config) ⇒ Object
42 43 44 |
# File 'lib/sem/api/project.rb', line 42 def add_shared_config(shared_config) Sem::API::Base.client.shared_configs.attach_to_project(shared_config.id, id) end |
#config_files ⇒ Object
50 51 52 |
# File 'lib/sem/api/project.rb', line 50 def config_files Sem::API::Base.client.config_files.list_for_project(id).map { |file| Sem::API::File.new(file) } end |
#env_vars ⇒ Object
54 55 56 |
# File 'lib/sem/api/project.rb', line 54 def env_vars Sem::API::Base.client.env_vars.list_for_project(id).map { |var| Sem::API::EnvVar.new(var) } end |
#full_name ⇒ Object
30 31 32 |
# File 'lib/sem/api/project.rb', line 30 def full_name "#{@org_name}/#{name}" end |
#remove_shared_config(shared_config) ⇒ Object
46 47 48 |
# File 'lib/sem/api/project.rb', line 46 def remove_shared_config(shared_config) Sem::API::Base.client.shared_configs.detach_from_project(shared_config.id, id) end |