Class: Jenkins::Job
- Inherits:
-
Object
- Object
- Jenkins::Job
- Defined in:
- lib/jenkins-json-api/job.rb
Constant Summary collapse
- SUCCESS =
'blue'
- FAILED =
'red'
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #==(r) ⇒ Object
- #build ⇒ Object
- #build_async ⇒ Object
-
#initialize(json) ⇒ Job
constructor
A new instance of Job.
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(json) ⇒ Job
Returns a new instance of Job.
9 10 11 12 13 |
# File 'lib/jenkins-json-api/job.rb', line 9 def initialize(json) @name = json['name'] @url = json['url'] @color = json['color'] end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
42 43 44 |
# File 'lib/jenkins-json-api/job.rb', line 42 def color @color end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
42 43 44 |
# File 'lib/jenkins-json-api/job.rb', line 42 def name @name end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
42 43 44 |
# File 'lib/jenkins-json-api/job.rb', line 42 def url @url end |
Instance Method Details
#==(r) ⇒ Object
36 37 38 39 40 |
# File 'lib/jenkins-json-api/job.rb', line 36 def ==(r) r.name == name and r.url == url and r.success? == success? end |
#build ⇒ Object
21 22 23 |
# File 'lib/jenkins-json-api/job.rb', line 21 def build open url+'build' end |
#build_async ⇒ Object
25 26 27 28 29 30 |
# File 'lib/jenkins-json-api/job.rb', line 25 def build_async Process.waitpid @job if @job @job = fork do build end end |
#success? ⇒ Boolean
15 16 17 18 19 |
# File 'lib/jenkins-json-api/job.rb', line 15 def success? return true if color == SUCCESS return false if color == FAILED raise "Inconsistent class state! color: #{color}" end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/jenkins-json-api/job.rb', line 32 def to_s "\n #{super.to_s}\n name: #{name}\n url: #{url}\n success: #{success?}\n" end |