Class: Rundeck::Project
- Inherits:
-
Object
- Object
- Rundeck::Project
- Defined in:
- lib/rundeck-ruby-client/project.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(session, hash) ⇒ Project
constructor
A new instance of Project.
- #job(id) ⇒ Object
- #jobs(force_reload = false) ⇒ Object
Constructor Details
#initialize(session, hash) ⇒ Project
Returns a new instance of Project.
14 15 16 17 18 19 20 21 |
# File 'lib/rundeck-ruby-client/project.rb', line 14 def initialize(session, hash) @session = session if hash.class != Array @name = hash['name'] else @name = hash[1] end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/rundeck-ruby-client/project.rb', line 22 def name @name end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
22 23 24 |
# File 'lib/rundeck-ruby-client/project.rb', line 22 def session @session end |
Class Method Details
.all(session) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/rundeck-ruby-client/project.rb', line 3 def self.all(session) @all ||= begin result = session.get('api/3/projects', 'result', 'projects', 'project') || [] result.map{|hash| Project.new(session, hash)} end end |
.find(session, name) ⇒ Object
10 11 12 |
# File 'lib/rundeck-ruby-client/project.rb', line 10 def self.find(session, name) all(session).first{|p| p.name == name} end |
Instance Method Details
#job(id) ⇒ Object
30 31 32 |
# File 'lib/rundeck-ruby-client/project.rb', line 30 def job(id) jobs.first{|j| j.id == id} end |
#jobs(force_reload = false) ⇒ Object
24 25 26 27 28 |
# File 'lib/rundeck-ruby-client/project.rb', line 24 def jobs(force_reload = false) return @jobs unless @jobs.nil? || force_reload result = session.get("api/2/jobs?project=#{name}", 'result', 'jobs', 'job') || [] @jobs = result.map{|hash| Job.from_hash(session, hash)} end |