Class: BambooApi::Plan
Constant Summary
Constants inherited from BambooApi
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#average_build_time ⇒ Object
readonly
Returns the value of attribute average_build_time.
-
#branches ⇒ Object
readonly
Returns the value of attribute branches.
-
#builds_cache ⇒ Object
readonly
Returns the value of attribute builds_cache.
-
#enabled ⇒ Object
readonly
Returns the value of attribute enabled.
-
#is_active ⇒ Object
readonly
Returns the value of attribute is_active.
-
#is_building ⇒ Object
readonly
Returns the value of attribute is_building.
-
#is_favourite ⇒ Object
readonly
Returns the value of attribute is_favourite.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#short_key ⇒ Object
readonly
Returns the value of attribute short_key.
-
#short_name ⇒ Object
readonly
Returns the value of attribute short_name.
-
#stages ⇒ Object
readonly
Returns the value of attribute stages.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
- #building? ⇒ Boolean
- #builds ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(short_name, short_key, type, enabled, link, key, name, is_favourite = nil, is_active = nil, is_building = nil, average_build_time = nil, actions = nil, stages = nil, branches = nil) ⇒ Plan
constructor
A new instance of Plan.
- #readable_status ⇒ Object
- #successful? ⇒ Boolean
Methods inherited from BambooApi
Constructor Details
#initialize(short_name, short_key, type, enabled, link, key, name, is_favourite = nil, is_active = nil, is_building = nil, average_build_time = nil, actions = nil, stages = nil, branches = nil) ⇒ Plan
Returns a new instance of Plan.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bamboo_api/plan.rb', line 7 def initialize short_name, short_key, type, enabled, link, key, name, is_favourite=nil, is_active=nil, is_building=nil, average_build_time=nil, actions=nil, stages=nil, branches=nil @short_name = short_name @short_key = short_key @type = type @enabled = enabled @link = link @key = key @name = name # optional @is_favourite = is_favourite @is_active = is_active @is_building = is_building @average_build_time = average_build_time @actions = actions @stages = stages @branches = branches end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def actions @actions end |
#average_build_time ⇒ Object (readonly)
Returns the value of attribute average_build_time.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def average_build_time @average_build_time end |
#branches ⇒ Object (readonly)
Returns the value of attribute branches.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def branches @branches end |
#builds_cache ⇒ Object (readonly)
Returns the value of attribute builds_cache.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def builds_cache @builds_cache end |
#enabled ⇒ Object (readonly)
Returns the value of attribute enabled.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def enabled @enabled end |
#is_active ⇒ Object (readonly)
Returns the value of attribute is_active.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def is_active @is_active end |
#is_building ⇒ Object (readonly)
Returns the value of attribute is_building.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def is_building @is_building end |
#is_favourite ⇒ Object (readonly)
Returns the value of attribute is_favourite.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def is_favourite @is_favourite end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def key @key end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def link @link end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def name @name end |
#short_key ⇒ Object (readonly)
Returns the value of attribute short_key.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def short_key @short_key end |
#short_name ⇒ Object (readonly)
Returns the value of attribute short_name.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def short_name @short_name end |
#stages ⇒ Object (readonly)
Returns the value of attribute stages.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def stages @stages end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/bamboo_api/plan.rb', line 3 def type @type end |
Class Method Details
.all ⇒ Object
85 86 87 |
# File 'lib/bamboo_api/plan.rb', line 85 def self.all BambooApi::Plan.parse( BambooApi.request "plan" ) end |
.find(key) ⇒ Object
89 90 91 |
# File 'lib/bamboo_api/plan.rb', line 89 def self.find key BambooApi::Plan.parse_single( BambooApi.request "plan/#{key}" ) end |
.parse(plans) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/bamboo_api/plan.rb', line 68 def self.parse plans parsed_plans = [] plans[ "plans" ][ "plan" ].each do | plan | parsed_plans.push( BambooApi::Plan.parse_single( plan ) ) end parsed_plans end |
.parse_single(plan) ⇒ Object
78 79 80 81 82 83 |
# File 'lib/bamboo_api/plan.rb', line 78 def self.parse_single plan BambooApi::Plan.new plan[ "shortName" ], plan[ "shortKey" ], plan[ "type" ], plan[ "enabled" ], plan[ "link" ], plan[ "key" ], plan[ "name" ], plan[ "isFavourite" ], plan[ "isActive" ], plan[ "isBuilding" ], plan[ "averageBuildTimeInSeconds" ], plan[ "actions" ], plan[ "stages" ], plan[ "branches" ] end |
Instance Method Details
#building? ⇒ Boolean
33 34 35 |
# File 'lib/bamboo_api/plan.rb', line 33 def building? self.is_building end |
#builds ⇒ Object
28 29 30 31 |
# File 'lib/bamboo_api/plan.rb', line 28 def builds @builds_cache = BambooApi::Build.find_by_plan self.key if @builds_cache.nil? @builds_cache end |
#failed? ⇒ Boolean
47 48 49 50 51 52 53 54 55 |
# File 'lib/bamboo_api/plan.rb', line 47 def failed? is_failed = false if !self.building? is_failed = self.builds.first.failed? rescue false end is_failed end |
#readable_status ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/bamboo_api/plan.rb', line 57 def readable_status if self.building? "#{self.name} is currently building." elsif self.successful? "#{self.name} is currently open and it is safe to commit." elsif self.failed? last_build = self.builds.first "#{self.name} is currently broken due to failing #{last_build.failing_stage.name} committed by #{ last_build.username }" end end |
#successful? ⇒ Boolean
37 38 39 40 41 42 43 44 45 |
# File 'lib/bamboo_api/plan.rb', line 37 def successful? is_successful = false if !self.building? is_successful = self.builds.first.successful?# rescue false end is_successful end |