pivo 0.0.3 → 0.0.4

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: 838ef8112306336eac9425e25fdb19cab787eca8
4
- data.tar.gz: 60a955eddc0d84f231654d1226ab8c9c7f0747f7
3
+ metadata.gz: 6ddf9101bfda6e5401398c93bdf1e02e99ca4b9f
4
+ data.tar.gz: e250acbabf48a28012e328517827cc98529ec527
5
5
  SHA512:
6
- metadata.gz: 4637884ba2b3dd5ea791dc885cc37c77647339d9588b1341f0c7e3b04a5ad121f88c5c368f44a6b4d950d4afbfbefae8d7c4be11ac82b9ef468784d821d57b6d
7
- data.tar.gz: c070566d6f034ac61d95fedfe460c747bd502a1e7ef3a1714cd60592121a0afc5e9874242e71939429955bb7ee2617b25c134709c69a9c25a38446fb3c6ef49c
6
+ metadata.gz: 222db0f22f1abc80db68da9be32bc5e5397af8ced5946dd4301337f6d8d2ba4ab2dbca3dd9baa7a666af92eb7276117661a31249680b3f001af536b1ea76e2fb
7
+ data.tar.gz: c4804ca224482f05fdf1c6f7a926cae525bd10feaebc7238e23d7864a29ae1b9572e32fe663729b6b0d7585461e5f3e011c15ea398899fe45dd72782c82f0789
data/README.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Pivo
2
2
 
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'pivo'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pivo
3
18
  ## Usage
4
19
 
5
20
  Add [Pivotal Trackert](http://www.pivotaltracker.com/) API token to $HOME/.pivo.yml
@@ -18,6 +33,7 @@ $ pivo projects
18
33
 
19
34
  ```shell
20
35
  $ pivo stories all PROJECT_NAME
36
+ $ pivo stories all PROJECT_NAME --status unstarted # filtering by status
21
37
  ```
22
38
 
23
39
  ### Listing mywork
@@ -25,6 +41,7 @@ $ pivo stories all PROJECT_NAME
25
41
 
26
42
  ```shell
27
43
  $ pivo stories me PROJECT_NAME
44
+ $ pivo stories me PROJECT_NAME --status unstarted # filtering by status
28
45
  ```
29
46
 
30
47
  #### with peco
@@ -36,29 +53,9 @@ function pivo-open() {
36
53
  }
37
54
  ```
38
55
 
39
- ## Installation
40
-
41
- Add this line to your application's Gemfile:
42
-
43
- ```ruby
44
- gem 'pivo'
45
- ```
46
-
47
- And then execute:
48
-
49
- $ bundle
50
-
51
- Or install it yourself as:
52
-
53
- $ gem install pivo
54
-
55
- ## Usage
56
-
57
- TODO: Write usage instructions here
58
-
59
56
  ## Contributing
60
57
 
61
- 1. Fork it ( https://github.com/[my-github-username]/pivo/fork )
58
+ 1. Fork it ( https://github.com/ukstudio/pivo/fork )
62
59
  2. Create your feature branch (`git checkout -b my-new-feature`)
63
60
  3. Commit your changes (`git commit -am 'Add some feature'`)
64
61
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1,88 @@
1
+ require 'yaml'
2
+ require 'tracker_api'
3
+ require 'thor'
4
+ require 'date'
5
+
6
+ require 'pivo/resource'
7
+
8
+ module Pivo
9
+ class Velocity < Thor
10
+ desc "velocity me PROJECT_NAME VELOCITY", "listing my stories each velocity"
11
+ def me(project_name, velocity)
12
+ me = Resource::Me.new
13
+ project = Resource::Project.find_by_name(project_name)
14
+ stories = project.stories(filter: "owner:\"#{me.name}\"")
15
+
16
+ days = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
17
+ week_start_day = project.week_start_day
18
+ index_of_start_day = days.index(week_start_day)
19
+ current_day = DateTime.now.wday
20
+ diff = current_day-index_of_start_day
21
+ diff = 7 - diff if diff < 0
22
+
23
+ current_iteration_start_date = DateTime.now - diff
24
+
25
+ point = 0
26
+ iteration_index = 1
27
+ say "\n===#{current_iteration_start_date.strftime('%Y-%m-%d %a')}=========================================================================\n\n"
28
+ stories.each do |story |
29
+ if point + story.estimate > velocity.to_i
30
+ say "total point: #{point}"
31
+ say "\n===#{(current_iteration_start_date + iteration_index*7).strftime('%Y-%m-%d %a')}=========================================================================\n\n"
32
+ iteration_index += 1
33
+ point = story.estimate
34
+ else
35
+ point += story.estimate
36
+ end
37
+ say Resource::Story.new(story).to_s
38
+ end
39
+ end
40
+ end
41
+
42
+ class Stories < Thor
43
+
44
+ desc "all PROJECT_NAME", "listing all stories"
45
+ option :status, type: 'string', desc: "unscheduled, unstarted, planned, rejected, started, finished, delivered, accepted"
46
+ def all(project_name)
47
+ project = Resource::Project.find_by_name(project_name)
48
+ filtering_options = {}
49
+ filtering_options.merge!(with_state: options[:status]) if options[:status]
50
+ project.stories(filtering_options).each do |story|
51
+ say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
52
+ end
53
+ end
54
+
55
+ desc "me PROJECT_NAME", "listing my stories"
56
+ option :status, type: 'string', desc: "unscheduled, unstarted, planned, rejected, started, finished, delivered, accepted"
57
+ def me(project_name)
58
+ me = Resource::Me.new
59
+ project = Resource::Project.find_by_name(project_name)
60
+ filtering_options = {}
61
+ filtering_options.merge!(filter: "state:#{options[:status]} owner:\"#{me.name}\"")
62
+ project.stories(filtering_options).each do |story|
63
+ say Resource::Story.new(story).to_s
64
+ end
65
+ end
66
+ end
67
+
68
+ class CLI < Thor
69
+ desc "projects", "listing project names"
70
+ def projects
71
+ say Resource::Project.all.map(&:name).join("\n")
72
+ end
73
+
74
+ desc "stories PROJECT_NAME", "listing project stories"
75
+ def stories(project_name)
76
+ project = Resource::Project.find_by_name(project_name)
77
+ project.stories.each do |story|
78
+ say Resource::Story.new(story).to_s
79
+ end
80
+ end
81
+
82
+ desc "stories SUBCOMMAND ARGS", "listing stories"
83
+ subcommand "stories", Stories
84
+
85
+ desc "velocity SUBCOMMAND ARGS", "listing stories each velocity"
86
+ subcommand "velocity", Velocity
87
+ end
88
+ end
@@ -0,0 +1,49 @@
1
+ module Resource
2
+ module ApiClient
3
+ private
4
+
5
+ def client
6
+ TrackerApi::Client.new(token: token)
7
+ end
8
+
9
+ def token
10
+ YAML.load(File.read("#{ENV['HOME']}/.pivo.yml"))['token']
11
+ end
12
+ end
13
+
14
+ class Me
15
+ include ApiClient
16
+
17
+ def initialize
18
+ @me = client.me
19
+ end
20
+
21
+ def name
22
+ @me.name
23
+ end
24
+ end
25
+
26
+ class Project
27
+ extend ApiClient
28
+
29
+ class << self
30
+ def all
31
+ client.projects
32
+ end
33
+
34
+ def find_by_name(name)
35
+ client.projects.select {|project| project.name == name}[0]
36
+ end
37
+ end
38
+ end
39
+
40
+ class Story
41
+ def initialize(story)
42
+ @story = story
43
+ end
44
+
45
+ def to_s
46
+ "[#{@story.estimate}][#{@story.current_state}]\t#{@story.name}\t#{@story.url}"
47
+ end
48
+ end
49
+ end
data/lib/pivo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pivo
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/pivo.rb CHANGED
@@ -1,63 +1,5 @@
1
1
  require "pivo/version"
2
-
3
- require 'yaml'
4
- require 'tracker_api'
5
- require 'thor'
2
+ require "pivo/commands"
6
3
 
7
4
  module Pivo
8
- class Stories < Thor
9
- desc "stories all PROJECT_NAME", "listing all stories"
10
- def all(project_name)
11
- project = client.projects.select {|project| project.name == project_name}[0]
12
- project.stories.each do |story|
13
- say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
14
- end
15
- end
16
-
17
- desc "stories me PROJECT_NAME", "listing my stories"
18
- def me(project_name)
19
- me = client.me
20
- project = client.projects.select {|project| project.name == project_name}[0]
21
- project.stories(filter: "mywork:\"#{me.name}\"").each do |story|
22
- say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
23
- end
24
- end
25
-
26
- private
27
-
28
- def client
29
- TrackerApi::Client.new(token: token)
30
- end
31
-
32
- def token
33
- YAML.load(File.read("#{ENV['HOME']}/.pivo.yml"))['token']
34
- end
35
- end
36
- class CLI < Thor
37
- desc "projects", "listing project names"
38
- def projects
39
- say client.projects.map(&:name).join("\n")
40
- end
41
-
42
- desc "stories PROJECT_NAME", "listing project stories"
43
- def stories(project_name)
44
- project = client.projects.select {|project| project.name == project_name}[0]
45
- project.stories.each do |story|
46
- say "[#{story.current_state}]\t#{story.name}\t#{story.url}"
47
- end
48
- end
49
-
50
- desc "stories SUBCOMMAND ARGS", "listing stories"
51
- subcommand "stories", Stories
52
-
53
- private
54
-
55
- def client
56
- TrackerApi::Client.new(token: token)
57
- end
58
-
59
- def token
60
- YAML.load(File.read("#{ENV['HOME']}/.pivo.yml"))['token']
61
- end
62
- end
63
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - AKAMATSU Yuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,8 @@ files:
67
67
  - Rakefile
68
68
  - bin/pivo
69
69
  - lib/pivo.rb
70
+ - lib/pivo/commands.rb
71
+ - lib/pivo/resource.rb
70
72
  - lib/pivo/version.rb
71
73
  - pivo.gemspec
72
74
  homepage: https://github.com/ukstudio/pivo