Class: Cukebase::Project
- Inherits:
-
Object
- Object
- Cukebase::Project
- Defined in:
- lib/cukebase/project.rb
Instance Attribute Summary collapse
-
#failed_status ⇒ Object
readonly
Returns the value of attribute failed_status.
-
#invalid_status ⇒ Object
readonly
Returns the value of attribute invalid_status.
-
#passed_status ⇒ Object
readonly
Returns the value of attribute passed_status.
-
#pending_status ⇒ Object
readonly
Returns the value of attribute pending_status.
-
#undefined_status ⇒ Object
readonly
Returns the value of attribute undefined_status.
Instance Method Summary collapse
-
#initialize(name) ⇒ Project
constructor
A new instance of Project.
- #ticket_for_name(name) ⇒ Object
- #ticketing_categories ⇒ Object
- #ticketing_category_id_for_name(name) ⇒ Object
- #ticketing_status_id_for_name(name) ⇒ Object
- #ticketing_statuses ⇒ Object
Constructor Details
#initialize(name) ⇒ Project
Returns a new instance of Project.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cukebase/project.rb', line 9 def initialize name @name = name @category = ticketing_category_id_for_name Cukebase.config.category @undefined_status = ticketing_status_id_for_name Cukebase.config.undefined_status @pending_status = ticketing_status_id_for_name Cukebase.config.pending_status @failed_status = ticketing_status_id_for_name Cukebase.config.failed_status @passed_status = ticketing_status_id_for_name Cukebase.config.passed_status @invalid_status = ticketing_status_id_for_name Cukebase.config.invalid_status end |
Instance Attribute Details
#failed_status ⇒ Object (readonly)
Returns the value of attribute failed_status.
5 6 7 |
# File 'lib/cukebase/project.rb', line 5 def failed_status @failed_status end |
#invalid_status ⇒ Object (readonly)
Returns the value of attribute invalid_status.
7 8 9 |
# File 'lib/cukebase/project.rb', line 7 def invalid_status @invalid_status end |
#passed_status ⇒ Object (readonly)
Returns the value of attribute passed_status.
6 7 8 |
# File 'lib/cukebase/project.rb', line 6 def passed_status @passed_status end |
#pending_status ⇒ Object (readonly)
Returns the value of attribute pending_status.
4 5 6 |
# File 'lib/cukebase/project.rb', line 4 def pending_status @pending_status end |
#undefined_status ⇒ Object (readonly)
Returns the value of attribute undefined_status.
3 4 5 |
# File 'lib/cukebase/project.rb', line 3 def undefined_status @undefined_status end |
Instance Method Details
#ticket_for_name(name) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/cukebase/project.rb', line 33 def ticket_for_name name data = Request.get("#{@name}/tickets", query: { query: "subject:\"#{name}\" category:\"#{Cukebase.config.category}\"" }).parsed_response["tickets"].first if data Ticket.new data else Ticket.new summary: name, category_id: @category, ticket_type: Cukebase.config.normal_type end end |
#ticketing_categories ⇒ Object
21 22 23 24 25 |
# File 'lib/cukebase/project.rb', line 21 def ticketing_categories @ticketing_categories ||= Request.get("#{@name}/tickets/categories").parsed_response["ticketing_categories"].map do |hash| TicketingCategory.new hash end end |
#ticketing_category_id_for_name(name) ⇒ Object
43 44 45 46 47 |
# File 'lib/cukebase/project.rb', line 43 def ticketing_category_id_for_name name ticketing_categories.find do |ticketing_category| ticketing_category.name == name end.try(:id) or raise "Could not find a Codebase ticket category with name \"#{name}\". Please create it first." end |
#ticketing_status_id_for_name(name) ⇒ Object
49 50 51 52 53 |
# File 'lib/cukebase/project.rb', line 49 def ticketing_status_id_for_name name ticketing_statuses.find do |ticketing_status| ticketing_status.name == name end.try(:id) or raise "Could not find a Codebase ticket status with name \"#{name}\". Please create it first." end |
#ticketing_statuses ⇒ Object
27 28 29 30 31 |
# File 'lib/cukebase/project.rb', line 27 def ticketing_statuses @ticketing_statuses ||= Request.get("#{@name}/tickets/statuses").parsed_response["ticketing_statuses"].map do |hash| TicketingStatus.new hash end end |