tracker_deliveries 0.1.2 → 0.1.6

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: f635ded874b022e199939d96831f90f396a4b885
4
- data.tar.gz: c2f355173ce76fdb9196d46e814d7f042c152efb
3
+ metadata.gz: 4971fefd1275558af1f0fc609fc641ac5102c5fa
4
+ data.tar.gz: 8eab891ba1e6894bd8c1209a99b9ca5a1cbca2c1
5
5
  SHA512:
6
- metadata.gz: d97c098c6e053c3b6c3e9157dee3f8153ab6ec0e8a98d519086c4502a3d3438876fd10765843797bc3aa5de3f5d0176bfd3f1ee0b25483e2cabee9d1d0ed16a1
7
- data.tar.gz: f8a91a9fbeffed17b0397e4519e2b7522a2384587468def649e0065560d0247216a784a7ad90d02ef192656cd5620ddb3fe76c3a9f57f2dc5d1ba34d972769d1
6
+ metadata.gz: 433cf7f8aaf755e8f8dbb9933183742c0dac9eec1f74507f36fe022be5b5f9e9f45159912def85250254e6ebfe4ac9aae8e2ea9f033063b51be4ae8dc3bf3ef3
7
+ data.tar.gz: 48c87f501af5039dbe07f3e4d82fd6e2b202a67632af2f67417f462a5bf10944aa8a16f5b682c7f5d778b9fd751f98024da5902ba2ab35d8fbf169dae4e28ed8
data/.circleci/config.yml CHANGED
@@ -23,10 +23,9 @@ jobs:
23
23
  command: |
24
24
  mkdir /tmp/test-results
25
25
  TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
26
- bundle exec rspec --format progress \
26
+ bundle exec rspec --format documentation \
27
27
  --format RspecJunitFormatter \
28
28
  --out /tmp/test-results/rspec.xml \
29
- --format progress \
30
29
  "${TEST_FILES}"
31
30
  - store_test_results:
32
31
  path: /tmp/test-results
data/README.md CHANGED
@@ -19,31 +19,64 @@ gem install tracker_deliveries
19
19
 
20
20
  ## Usage
21
21
 
22
- Define these environment variables
22
+ Define these environment variables:
23
23
 
24
- `TRACKER_DELIVERIES_API_TOKEN` - tracker API token.
24
+ - `TRACKER_DELIVERIES_API_TOKEN` - tracker API token
25
+ - `TRACKER_DELIVERIES_PROJECT_ID` - tracker project ID
25
26
 
26
- `TRACKER_DELIVERIES_PROJECT_ID` - tracker project ID
27
-
28
- Then run the command:
27
+ Run:
29
28
 
30
29
  ```
31
30
  tracker_deliveries
32
31
  ```
33
32
 
34
- This fetches the currently delivered tracker stories from your project
35
- and display the id and story title.
33
+ Output current delivered stories ids & story titles as plaintext e.g.:
34
+
35
+ ```
36
+ 132412351 - Add widget service request to order form
37
+ 123412144 - Display widget detail view UI
38
+ 131412414 - Update widget quantity in shopping cart
39
+ 132412155 - Localize cart in Pirate speak, arr.
40
+ ```
41
+
42
+ ### Formatting output
36
43
 
37
- e.g.
44
+ Generate the list with alternative formatting as Markdown or HTML (with built in links to the tracker stories):
38
45
 
39
46
  ```
40
- #342351 - Add widget service request to order form
41
- #213144 - Display widget detail view UI
42
- #341414 - Update widget quantity in shopping cart
43
- #342155 - Localize cart in Pirate speak, arr.
47
+ tracker_deliveries --markdown
44
48
  ```
45
49
 
46
- ## Pivotal Tracker API Token and Project ID
50
+ ```
51
+ - [132412351](https://pivotaltracker.com/story/show/132412351) - Add widget service request to order form
52
+ - [123412144](https://pivotaltracker.com/story/show/123412144) - Display widget detail view UI
53
+ - [131412414](https://pivotaltracker.com/story/show/131412414) - Update widget quantity in shopping cart
54
+ - [132412155](https://pivotaltracker.com/story/show/132412155) - Localize cart in Pirate speak, arr.
55
+ ```
56
+
57
+ or
58
+
59
+ ```
60
+ tracker_deliveries --html
61
+ ```
62
+
63
+ ```
64
+ <ul>
65
+ <li><a href="https://pivotaltracker.com/story/show/132412351">132412351</a> - Add widget service request to order form</li>
66
+ <li><a href="https://pivotaltracker.com/story/show/123412144">123412144</a> - Display widget detail view UI</li>
67
+ <li><a href="https://pivotaltracker.com/story/show/131412414">131412414</a> - Update widget quantity in shopping cart</li>
68
+ <li><a href="https://pivotaltracker.com/story/show/132412155">132412155</a> - Localize cart in Pirate speak, arr.</li>
69
+ </ul>
70
+ ```
71
+
72
+ Rendering as:
73
+
74
+ - [132412351](https://pivotaltracker.com/story/show/132412351) - Add widget service request to order form
75
+ - [123412144](https://pivotaltracker.com/story/show/123412144) - Display widget detail view UI
76
+ - [131412414](https://pivotaltracker.com/story/show/131412414) - Update widget quantity in shopping cart
77
+ - [132412155](https://pivotaltracker.com/story/show/132412155) - Localize cart in Pirate speak, arr.
78
+
79
+ ## Get hold of the Pivotal Tracker API Token / Project ID
47
80
 
48
81
  On https://www.pivotaltracker.com/profile (while logged in) the API
49
82
  token is at the bottom of the page.
@@ -1,5 +1,12 @@
1
1
  #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
2
3
 
3
4
  require 'tracker_deliveries'
4
5
 
5
- puts TrackerDeliveries::Main.new().delivered_stories
6
+ if ARGV[0] == '--markdown'
7
+ puts TrackerDeliveries::Main.new(format: :markdown).delivered_stories
8
+ elsif ARGV[0] == '--html'
9
+ puts TrackerDeliveries::Main.new(format: :html).delivered_stories
10
+ else
11
+ puts TrackerDeliveries::Main.new().delivered_stories
12
+ end
@@ -1,3 +1,3 @@
1
1
  module TrackerDeliveries
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -7,10 +7,10 @@ module TrackerDeliveries
7
7
  :api_token,
8
8
  :pivotal_tracker
9
9
 
10
- def initialize
10
+ def initialize(options = {})
11
11
  @project_id = ENV['TRACKER_DELIVERIES_PROJECT_ID']
12
12
  @api_token = ENV['TRACKER_DELIVERIES_API_TOKEN']
13
- @pivotal_tracker = PivotalTracker.new(@project_id, @api_token)
13
+ @pivotal_tracker = PivotalTracker.new(@project_id, @api_token, options)
14
14
  end
15
15
 
16
16
  def delivered_stories
@@ -22,21 +22,52 @@ module TrackerDeliveries
22
22
  PIVOTAL_API_URL = 'https://www.pivotaltracker.com/services/v5/'
23
23
  attr_accessor :api
24
24
 
25
- def initialize project_id, api_key
25
+ def initialize project_id, api_key, options = {}
26
26
  @api_key = api_key
27
27
  @project_id = project_id
28
+ @format = options[:format] || :plaintext
28
29
  @api = Blanket.wrap PIVOTAL_API_URL,
29
30
  headers: { 'X-TrackerToken' => @api_key }
30
31
  end
31
32
 
32
33
  def delivered_stories
33
34
  options = {with_state: "delivered"}
34
- api
35
- .projects(@project_id)
36
- .stories
37
- .get(params: options)
38
- .payload
39
- .map{|s| "#{s.id} - #{s.name}" }
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>}
40
71
  end
41
72
  end
42
73
  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.2
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Milkins