tracker_deliveries 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +0 -1
- data/README.md +5 -0
- data/lib/format_tools.rb +36 -0
- data/lib/pivotal_tracker.rb +36 -0
- data/lib/tracker_deliveries/version.rb +1 -1
- data/lib/tracker_deliveries.rb +3 -55
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98406035e4d6cd6b02b1d048cfaf917d9d022c60
|
4
|
+
data.tar.gz: 70281c68f1eff2661291154cd7a8bfcfee04bbab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 526d933dae0eb25e6a57ea729170b66cc95906f6a993b5957fe997b1349b2b0322a8cf2ce0ad99fdf9864db2bffc3cc7c6571482eb14b0c562d9c1412c83e9d7
|
7
|
+
data.tar.gz: 5be1e99756a91d460faae8fd39e983ca519b1a829c25a556099feda1e601054ec4f8ed1db952dc9bad03f4e1d411be956cf598aeb4309e2ac17d3fcb82e5e946
|
data/.circleci/config.yml
CHANGED
data/README.md
CHANGED
@@ -84,3 +84,8 @@ token is at the bottom of the page.
|
|
84
84
|
Visit your PivotalTracker project the `project_id` last part of
|
85
85
|
the URL, e.g. `https://www.pivotaltracker.com/n/projects/1234567` the
|
86
86
|
`project_id` is `1234567`
|
87
|
+
|
88
|
+
## Acknowledgements
|
89
|
+
|
90
|
+
This was built using Ruby, Rspec/TDD with Blanket Wrapper provides the
|
91
|
+
basis of the REST service client.
|
data/lib/format_tools.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module TrackerDeliveries
|
2
|
+
class FormatTools
|
3
|
+
PIVOTAL_TRACKER_STORY_URL = 'https://pivotaltracker.com/story/show/'
|
4
|
+
|
5
|
+
def initialize format
|
6
|
+
@format = format
|
7
|
+
end
|
8
|
+
|
9
|
+
def pivotal_tracker_link s
|
10
|
+
%Q{#{PIVOTAL_TRACKER_STORY_URL}#{s.id}}
|
11
|
+
end
|
12
|
+
|
13
|
+
def story_formatter s
|
14
|
+
return send(@format, s)
|
15
|
+
end
|
16
|
+
|
17
|
+
def wrap_output output
|
18
|
+
return %Q{<ul>\n#{output}\n</ul>} if @format == :html
|
19
|
+
output
|
20
|
+
end
|
21
|
+
|
22
|
+
def plaintext s
|
23
|
+
%Q{#{s.id} - #{s.name}}
|
24
|
+
end
|
25
|
+
|
26
|
+
def markdown s
|
27
|
+
link = %Q{[#{s.id}](#{pivotal_tracker_link s})}
|
28
|
+
%Q{- #{link} - #{s.name}}
|
29
|
+
end
|
30
|
+
|
31
|
+
def html s
|
32
|
+
link = %Q{<a href="#{pivotal_tracker_link s}">#{s.id}</a>}
|
33
|
+
%Q{<li>#{link} - #{s.name}</li>}
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'blanket'
|
2
|
+
|
3
|
+
module TrackerDeliveries
|
4
|
+
class PivotalTracker
|
5
|
+
PIVOTAL_API_URL = 'https://www.pivotaltracker.com/services/v5/'
|
6
|
+
|
7
|
+
attr_accessor :api
|
8
|
+
|
9
|
+
def initialize project_id, api_key, options = {}
|
10
|
+
@api_key = api_key
|
11
|
+
@project_id = project_id
|
12
|
+
@format_tools = TrackerDeliveries::FormatTools.new options[:format] || :plaintext
|
13
|
+
@api = Blanket.wrap PIVOTAL_API_URL,
|
14
|
+
headers: { 'X-TrackerToken' => @api_key }
|
15
|
+
end
|
16
|
+
|
17
|
+
def delivered_stories
|
18
|
+
options = {with_state: "delivered"}
|
19
|
+
wrap_output(api
|
20
|
+
.projects(@project_id)
|
21
|
+
.stories
|
22
|
+
.get(params: options)
|
23
|
+
.payload
|
24
|
+
.map{|s| story_formatter s }
|
25
|
+
.join("\n"))
|
26
|
+
end
|
27
|
+
|
28
|
+
def wrap_output output
|
29
|
+
@format_tools.wrap_output output
|
30
|
+
end
|
31
|
+
|
32
|
+
def story_formatter story
|
33
|
+
@format_tools.story_formatter story
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/tracker_deliveries.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require 'blanket'
|
2
1
|
require 'tracker_deliveries/version'
|
2
|
+
require 'pivotal_tracker'
|
3
|
+
require 'format_tools'
|
3
4
|
|
4
5
|
module TrackerDeliveries
|
5
6
|
class Main
|
@@ -10,64 +11,11 @@ module TrackerDeliveries
|
|
10
11
|
def initialize(options = {})
|
11
12
|
@project_id = ENV['TRACKER_DELIVERIES_PROJECT_ID']
|
12
13
|
@api_token = ENV['TRACKER_DELIVERIES_API_TOKEN']
|
13
|
-
@pivotal_tracker = PivotalTracker.new(@project_id, @api_token, options)
|
14
|
+
@pivotal_tracker = TrackerDeliveries::PivotalTracker.new(@project_id, @api_token, options)
|
14
15
|
end
|
15
16
|
|
16
17
|
def delivered_stories
|
17
18
|
@pivotal_tracker.delivered_stories
|
18
19
|
end
|
19
20
|
end
|
20
|
-
|
21
|
-
class PivotalTracker
|
22
|
-
PIVOTAL_API_URL = 'https://www.pivotaltracker.com/services/v5/'
|
23
|
-
attr_accessor :api
|
24
|
-
|
25
|
-
def initialize project_id, api_key, options = {}
|
26
|
-
@api_key = api_key
|
27
|
-
@project_id = project_id
|
28
|
-
@format = options[:format] || :plaintext
|
29
|
-
@api = Blanket.wrap PIVOTAL_API_URL,
|
30
|
-
headers: { 'X-TrackerToken' => @api_key }
|
31
|
-
end
|
32
|
-
|
33
|
-
def delivered_stories
|
34
|
-
options = {with_state: "delivered"}
|
35
|
-
wrap_output(api
|
36
|
-
.projects(@project_id)
|
37
|
-
.stories
|
38
|
-
.get(params: options)
|
39
|
-
.payload
|
40
|
-
.map{|s| story_formatter s }
|
41
|
-
.join("\n"))
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def pivotal_tracker_link s
|
47
|
-
%Q{https://pivotaltracker.com/story/show/#{s.id}}
|
48
|
-
end
|
49
|
-
|
50
|
-
def story_formatter s
|
51
|
-
return send(@format, s)
|
52
|
-
end
|
53
|
-
|
54
|
-
def wrap_output output
|
55
|
-
return %Q{<ul>\n#{output}\n</ul>} if @format == :html
|
56
|
-
output
|
57
|
-
end
|
58
|
-
|
59
|
-
def plaintext s
|
60
|
-
%Q{#{s.id} - #{s.name}}
|
61
|
-
end
|
62
|
-
|
63
|
-
def markdown s
|
64
|
-
link = %Q{[#{s.id}](#{pivotal_tracker_link s})}
|
65
|
-
%Q{- #{link} - #{s.name}}
|
66
|
-
end
|
67
|
-
|
68
|
-
def html s
|
69
|
-
link = %Q{<a href="#{pivotal_tracker_link s}">#{s.id}</a>}
|
70
|
-
%Q{<li>#{link} - #{s.name}</li>}
|
71
|
-
end
|
72
|
-
end
|
73
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tracker_deliveries
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Milkins
|
@@ -115,6 +115,8 @@ files:
|
|
115
115
|
- bin/console
|
116
116
|
- bin/setup
|
117
117
|
- exe/tracker_deliveries
|
118
|
+
- lib/format_tools.rb
|
119
|
+
- lib/pivotal_tracker.rb
|
118
120
|
- lib/tracker_deliveries.rb
|
119
121
|
- lib/tracker_deliveries/version.rb
|
120
122
|
- tracker_deliveries.gemspec
|