pivo 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a937aec4acf572a7ace3e423d5ac55dfbc6842c9
4
- data.tar.gz: 6baf2bb80dafd7927b049d398c6538b1f05231ad
3
+ metadata.gz: a0c22fc0e3eb5d1946f5419d969b60f3a890b778
4
+ data.tar.gz: b46e4c1726162364a8d656c783a76cdc2a17b679
5
5
  SHA512:
6
- metadata.gz: 2670619859d8c2e9341409dd4c391972e21cb6a3caba22da2bcd213c10d506a8d829a62c8e6abca14d2b0e749a06e902800d6092020816b863478814ce44f0fa
7
- data.tar.gz: dbaf21f833805d231369f3fc44d80f4705ef546ed06fdad58758de8aa7431548ff6cc549375c017bb1bece807abd9ebf495d5fe6e8edc687d66da44e4472a162
6
+ metadata.gz: 1aeba5b748bb7c22514df2dd6421e0d0dbb52ffd2ec92887476c198c504e22d8a0ba002b5bcad2b8b0879af628840023fc6fb0f7cbfabe523bbc814f894f2f55
7
+ data.tar.gz: 14fbb3559af97ff2292cf036ffe8e076019b4e9f1849ea4ed9a9a4c4b6e08ea64c3a7d6b506f00f184eaa55649d5cbce9c89a26c42a83bea9e6faff843fcce2b
data/lib/pivo/commands.rb CHANGED
@@ -11,7 +11,7 @@ module Pivo
11
11
  desc "all PROJECT_NAME", "listing all stories"
12
12
  option :status, type: 'string', desc: "unscheduled, unstarted, planned, rejected, started, finished, delivered, accepted"
13
13
  option :mywork, type: 'string', desc: "listing mywork storeis of the specified user"
14
- option :format, type: 'string', desc: "default, md"
14
+ option :format, type: 'string', desc: "default, md, kanban"
15
15
  def all(project_name)
16
16
  project = Resource::Project.find_by_name(project_name)
17
17
  filtering_options = []
@@ -19,12 +19,14 @@ module Pivo
19
19
  if options[:mywork]
20
20
  filtering_options << "mywork:#{options[:mywork]}" if options[:mywork]
21
21
  end
22
- options = filtering_options.empty? ? {} : {filter: filtering_options.join(" ")}
22
+ request_params = filtering_options.empty? ? {} : {filter: filtering_options.join(" ")}
23
23
  case options[:format]
24
24
  when 'md'
25
- say Formatters::Stories::Markdown.new(project.stories(options)).to_s
25
+ say Formatters::Stories::Markdown.new(project.stories(request_params)).to_s
26
+ when 'kanban'
27
+ say Formatters::Stories::Kanban.new(project.stories(request_params)).to_s
26
28
  else
27
- say Formatters::Stories::Default.new(project.stories(options)).to_s
29
+ say Formatters::Stories::Default.new(project.stories(request_params)).to_s
28
30
  end
29
31
  end
30
32
 
@@ -39,7 +41,7 @@ module Pivo
39
41
 
40
42
  desc "iteration PROJECT_NAME", "listing stories of iteration"
41
43
  option :iterationnumber, type: 'numeric', default: 0, desc: "current iteration number = 0, prev iterationn number = 1, prev prev = 2..."
42
- option :format, type: 'string', desc: "default, md"
44
+ option :format, type: 'string', desc: "default, md, kanban"
43
45
  def iteration(project_name)
44
46
  project = Resource::Project.find_by_name(project_name)
45
47
  iteration_number = project.current_iteration_number
@@ -48,6 +50,8 @@ module Pivo
48
50
  case options[:format]
49
51
  when 'md'
50
52
  say Formatters::Stories::Markdown.new(iteration.stories).to_s
53
+ when 'kanban'
54
+ say Formatters::Stories::Kanban.new(iteration.stories).to_s
51
55
  else
52
56
  say Formatters::Stories::Default.new(iteration.stories).to_s
53
57
  end
@@ -2,5 +2,6 @@ module Pivo
2
2
  module Formatters
3
3
  require_relative 'formatters/stories/default'
4
4
  require_relative 'formatters/stories/markdown'
5
+ require_relative 'formatters/stories/kanban'
5
6
  end
6
7
  end
@@ -0,0 +1,63 @@
1
+ require 'kosi'
2
+
3
+ module Pivo
4
+ module Formatters
5
+ module Stories
6
+ class Kanban
7
+ def initialize(stories)
8
+ @stories = stories
9
+ @rows = []
10
+ end
11
+
12
+ def to_s
13
+ kanban = {
14
+ todo: { point: 0, stories: [] },
15
+ doing: { point: 0, stories: [] },
16
+ done: { point: 0, stories: [] }
17
+ }
18
+
19
+ @stories.each do |story|
20
+ row = Array.new(3, '')
21
+ key = category(story)
22
+ kanban[key][:point] += story.estimate.to_i
23
+ kanban[key][:stories] << story
24
+ end
25
+
26
+ collect!(kanban)
27
+ @rows << [kanban[:todo][:point], kanban[:doing][:point], kanban[:done][:point]]
28
+
29
+ kosi = Kosi::Table.new(align: Kosi::Align::TYPE::LEFT, header: ['ToDo', 'Doing', 'Done'])
30
+ kosi.render @rows
31
+ end
32
+
33
+ private
34
+
35
+ def category(story)
36
+ case story.current_state
37
+ when 'unscheduled', 'unstarted', 'planned'
38
+ :todo
39
+ when 'started', 'finished', 'delivered'
40
+ :doing
41
+ when 'rejected', 'accepted'
42
+ :done
43
+ end
44
+ end
45
+
46
+ def collect!(kanban)
47
+ todo = kanban[:todo][:stories].shift
48
+ doing = kanban[:doing][:stories].shift
49
+ done = kanban[:done][:stories].shift
50
+
51
+ if todo.nil? && doing.nil? && done.nil?
52
+ return
53
+ end
54
+
55
+ col = -> (story) { "[#{story.estimate.to_i}]#{story.name}" }
56
+
57
+ @rows << [todo ? col.call(todo): '', doing ? col.call(doing): '', done ? col.call(done) : '']
58
+ collect!(kanban)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
data/lib/pivo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pivo
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
data/pivo.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency "tracker_api", '>=0.2.9'
25
25
  spec.add_dependency "thor"
26
+ spec.add_dependency "kosi"
26
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - AKAMATSU Yuki
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: kosi
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: for pivotal tracker
70
84
  email:
71
85
  - y.akamatsu@ukstudio.jp
@@ -84,6 +98,7 @@ files:
84
98
  - lib/pivo/commands.rb
85
99
  - lib/pivo/formatters.rb
86
100
  - lib/pivo/formatters/stories/default.rb
101
+ - lib/pivo/formatters/stories/kanban.rb
87
102
  - lib/pivo/formatters/stories/markdown.rb
88
103
  - lib/pivo/resource.rb
89
104
  - lib/pivo/version.rb