pivo_flow 0.2.11 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -46,32 +46,59 @@ module PivoFlow
46
46
  end
47
47
 
48
48
  def list_stories_to_output stories
49
- if current_story
50
- puts "You've got some started stories, it may be a good idea to finish them in the first place"
51
- puts "[##{current_story.id}] #{current_story.name} - #{current_story.description}"
52
- end
53
-
54
49
  HighLine.new.choose do |menu|
55
- menu.header = "--- STORIES FROM PIVOTAL TRACKER ---\nWhich one would you like to start? "
50
+ menu.header = "\n--- STORIES FROM PIVOTAL TRACKER ---\nWhich one would you like to start? "
56
51
  menu.prompt = "story no.? "
57
52
  menu.select_by = :index
58
53
  stories.each do |story|
59
- vars = {
60
- story_id: story.id,
61
- requested_by: story.requested_by,
62
- name: story.name,
63
- story_type: story_type_icon(story),
64
- estimate: estimate_points(story),
65
- owner: story_owner(story),
66
- started: story.current_state == "started" ? "started >" : ""
67
- }
68
- story_text = "%{started} [#%{story_id}] %{story_type} [%{estimate} pts.] %{owner} %{name}" % vars
69
- story_text += "\n Description: #{story.description}" unless story.description
70
- menu.choice(story_text) { |answer| pick_up_story(answer.match(/\[#(?<id>\d+)\]/)[:id])}
54
+ menu.choice(story_string(story)) { |answer| show_story(answer.match(/\[#(?<id>\d+)\]/)[:id])}
71
55
  end
72
56
  end
73
57
  end
74
58
 
59
+ def show_story story_id
60
+ story = find_story(story_id)
61
+ puts story_string(story, true)
62
+ proceed = ask_question "Do you want to start this story?"
63
+ accepted_answers = %w[yes y sure ofc jup yep yup ja tak]
64
+ if accepted_answers.include?(proceed.downcase)
65
+ pick_up_story(story_id)
66
+ else
67
+ show_stories
68
+ end
69
+ end
70
+
71
+
72
+ def find_story story_id
73
+ story = project_stories.find { |p| p.id == story_id }
74
+ story.nil? ? @options[:project].stories.find(story_id) : story
75
+ end
76
+
77
+ def story_string story, long=false
78
+ vars = {
79
+ story_id: story.id,
80
+ requested_by: story.requested_by,
81
+ name: truncate(story.name),
82
+ story_type: story_type_icon(story),
83
+ estimate: estimate_points(story),
84
+ owner: story_owner(story),
85
+ description: story.description,
86
+ labels: story.labels,
87
+ started: story.current_state == "started" ? "S" : "N"
88
+ }
89
+ if long
90
+ "STORY %{started} %{story_type} [#%{story_id}]
91
+ Name: %{name}
92
+ Labels: %{labels}
93
+ Owned by: %{owner}
94
+ Requested by: %{requested_by}
95
+ Description: %{description}
96
+ Estimate: %{estimate}" % vars
97
+ else
98
+ "[#%{story_id}] (%{started}) %{story_type} [%{estimate} pts.] %{owner} %{name}" % vars
99
+ end
100
+ end
101
+
75
102
  def story_type_icon story
76
103
  case story.story_type
77
104
  when "feature" then "☆"
@@ -81,8 +108,12 @@ module PivoFlow
81
108
  end
82
109
  end
83
110
 
111
+ def truncate string
112
+ string.length > 80 ? "#{string[0..80]}..." : string
113
+ end
114
+
84
115
  def story_owner story
85
- story.owned_by.nil? ? "" : "(#{initials(story.owned_by)})"
116
+ story.owned_by.nil? ? "(--)" : "(#{initials(story.owned_by)})"
86
117
  end
87
118
 
88
119
  def initials name
@@ -93,7 +124,7 @@ module PivoFlow
93
124
  unless story.estimate.nil?
94
125
  story.estimate < 0 ? "?" : story.estimate
95
126
  else
96
- "no"
127
+ "-"
97
128
  end
98
129
  end
99
130
 
@@ -102,7 +133,7 @@ module PivoFlow
102
133
  end
103
134
 
104
135
  def update_story story_id, state
105
- story = @options[:project].stories.find(story_id)
136
+ story = find_story(story_id)
106
137
  if story.nil?
107
138
  puts "Story not found, sorry."
108
139
  return
@@ -1,3 +1,3 @@
1
1
  module PivoFlow
2
- VERSION = "0.2.11"
2
+ VERSION = "0.3.0"
3
3
  end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivo_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -98,6 +98,7 @@ files:
98
98
  - lib/pivo_flow/pivotal.rb
99
99
  - lib/pivo_flow/version.rb
100
100
  - pivo_flow.gemspec
101
+ - spec/spec_helper.rb
101
102
  homepage: https://github.com/lubieniebieski/pivo_flow
102
103
  licenses: []
103
104
  post_install_message:
@@ -122,4 +123,5 @@ rubygems_version: 1.8.24
122
123
  signing_key:
123
124
  specification_version: 3
124
125
  summary: Simple pivotal tracker integration for day to day work with git
125
- test_files: []
126
+ test_files:
127
+ - spec/spec_helper.rb