Class: Dev::TargetProcess::UserStory
- Defined in:
- lib/firespring_dev_commands/target_process/user_story.rb
Overview
Class containing user story information
Constant Summary collapse
- RESOURCE_TYPE =
The resource type for the api endpoint
'UserStory'.freeze
- PATH =
The api path for user story requests
'/UserStories'.freeze
Instance Attribute Summary collapse
-
#create_date ⇒ Object
Returns the value of attribute create_date.
-
#creator ⇒ Object
Returns the value of attribute creator.
-
#data ⇒ Object
Returns the value of attribute data.
-
#description ⇒ Object
Returns the value of attribute description.
-
#effort ⇒ Object
Returns the value of attribute effort.
-
#end_date ⇒ Object
Returns the value of attribute end_date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#last_state_change_date ⇒ Object
Returns the value of attribute last_state_change_date.
-
#modify_date ⇒ Object
Returns the value of attribute modify_date.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#priority ⇒ Object
Returns the value of attribute priority.
-
#project ⇒ Object
Returns the value of attribute project.
-
#release ⇒ Object
Returns the value of attribute release.
-
#start_date ⇒ Object
Returns the value of attribute start_date.
-
#state ⇒ Object
Returns the value of attribute state.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#team ⇒ Object
Returns the value of attribute team.
-
#time_spent ⇒ Object
Returns the value of attribute time_spent.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#cycle_time ⇒ Object
Calculate the cycle time as the amount of time the story was open.
-
#initialize(data) ⇒ UserStory
constructor
A new instance of UserStory.
-
#parse_time(string) ⇒ Object
Parse the dot net time representation into something that ruby can use.
-
#team_cycle_time(team_ids) ⇒ Object
Returns the time the team was responsible for the issue was.
Constructor Details
#initialize(data) ⇒ UserStory
Returns a new instance of UserStory.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 14 def initialize(data) @data = data @id = data['Id'] @type = data['ResourceType'] @name = data['Name'] @description = data['Description'] @state = data['EntityState']['Name'] if data['EntityState'] @project = Project.new(data['Project']) if data['Project'] @owner = User.new(data['Owner']) if data['Owner'] @creator = User.new(data['Creator']) if data['Creator'] @release = Release.new(data['Release']) if data['Release'] @team = Team.new(data['Team']) if data['Team'] @start_date = parse_time(data['StartDate']) @end_date = parse_time(data['EndDate']) @create_date = parse_time(data['CreateDate']) @modify_date = parse_time(data['ModifyDate']) @tags = data['Tags'] @effort = data['Effort'] @time_spent = data['TimeSpent'] @last_state_change_date = parse_time(data['LastStateChangeDate']) end |
Instance Attribute Details
#create_date ⇒ Object
Returns the value of attribute create_date.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def create_date @create_date end |
#creator ⇒ Object
Returns the value of attribute creator.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def creator @creator end |
#data ⇒ Object
Returns the value of attribute data.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def data @data end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def description @description end |
#effort ⇒ Object
Returns the value of attribute effort.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def effort @effort end |
#end_date ⇒ Object
Returns the value of attribute end_date.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def end_date @end_date end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def id @id end |
#last_state_change_date ⇒ Object
Returns the value of attribute last_state_change_date.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def last_state_change_date @last_state_change_date end |
#modify_date ⇒ Object
Returns the value of attribute modify_date.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def modify_date @modify_date end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def owner @owner end |
#priority ⇒ Object
Returns the value of attribute priority.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def priority @priority end |
#project ⇒ Object
Returns the value of attribute project.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def project @project end |
#release ⇒ Object
Returns the value of attribute release.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def release @release end |
#start_date ⇒ Object
Returns the value of attribute start_date.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def start_date @start_date end |
#state ⇒ Object
Returns the value of attribute state.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def state @state end |
#tags ⇒ Object
Returns the value of attribute tags.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def @tags end |
#team ⇒ Object
Returns the value of attribute team.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def team @team end |
#time_spent ⇒ Object
Returns the value of attribute time_spent.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def time_spent @time_spent end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 11 def type @type end |
Instance Method Details
#cycle_time ⇒ Object
Calculate the cycle time as the amount of time the story was open
44 45 46 47 48 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 44 def cycle_time return 1.0 unless start_date && end_date (end_date - start_date).to_f / (60 * 60 * 24) end |
#parse_time(string) ⇒ Object
Parse the dot net time representation into something that ruby can use
37 38 39 40 41 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 37 def parse_time(string) return nil unless string && !string.empty? ::Time.at(string.slice(6, 10).to_i) end |
#team_cycle_time(team_ids) ⇒ Object
Returns the time the team was responsible for the issue was
51 52 53 54 55 56 57 58 59 |
# File 'lib/firespring_dev_commands/target_process/user_story.rb', line 51 def team_cycle_time(team_ids) # Calculate the difference and convert to days finished_dev_query = Dev::TargetProcess::Query.new finished_dev_query.filter_by_team_ids(team_ids) finished_dev_query.filter_by_entity_type(Dev::TargetProcess::UserStory::RESOURCE_TYPE) finished_dev_query.filter_by_entity_id(id) team_assignments = Dev::TargetProcess.new.team_assignments(finished_dev_query) team_assignments.sum(&:cycle_time) end |