pivotoolz 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c9bbddb0c21ad076943ee1ce72ab6cafd41459aeaf552e6fd74d30bc6065f60b
4
- data.tar.gz: e582a7305bed0b5ac27c28ad1810d10587c379fc674ce8b908ec9047246aae06
3
+ metadata.gz: aca1810714c054ba41bf1b72a60f3fce16862b676c67ef1102870076709ac337
4
+ data.tar.gz: 47080946190eee394bd88d21f74f42db80d66fb81ccff819e128f593fda48f5c
5
5
  SHA512:
6
- metadata.gz: 8bed0db6bf96b4e83026a8799e2647070649227548f7efab6b6d52fc9055d32d21517a9d5b0d07ff2e383414b03b57aa2982b8fa124016a692c7784e01c5c96c
7
- data.tar.gz: 4a648482e7ef1b245d1b5b6a35af088c42bbbc306b81554d3ed76de60859853a7660527a0d32eb08e01ca64b619233067cdbec5c21558d83e743ca2416cb3724
6
+ metadata.gz: c1e142c9bdc333d70c6fcf8891ae38e8ae47b868037ffaa9fe75dbc09a5f98df76fb9866aff915d5c3230a17b5408aa2bf87a583bbe75d0c6d78c097b3cffea1
7
+ data.tar.gz: 224490cd818bd2579742413f0f1ad2943dc3dcc34fc5a2f905419ea7c526d39e542bad2107039535ded9c1557b8cbcd1a74d77dfddc63f97409f25af0781d865
@@ -3,28 +3,44 @@
3
3
  require 'open-uri'
4
4
  require 'json'
5
5
 
6
- def get_story_info(story_id)
6
+ BASE_URL = "https://www.pivotaltracker.com/services/v5/stories/"
7
+
8
+ def get_story_info(story_id, flags = [])
7
9
  return nil if story_id.empty?
8
10
 
9
11
  begin
10
- open("https://www.pivotaltracker.com/services/v5/stories/#{story_id}", 'X-TrackerToken' => ENV['PIVOTAL_TRACKER_API_TOKEN']).read
12
+ include_owner_names = flags.any? { |f| f == '--owners' || f == '-O' }
13
+ url = BASE_URL + "#{story_id}" + "/#{include_owner_names ? '?fields=:default,owners' : ''}"
14
+ open(
15
+ url,
16
+ 'X-TrackerToken' => ENV['PIVOTAL_TRACKER_API_TOKEN']
17
+ ).read
11
18
  rescue StandardError => e
12
19
  JSON.generate({error: "could not get story info for story #{story_id}: #{e.message}\nstory info may be available at https://www.pivotaltracker.com/story/show/#{story_id}"})
13
20
  end
14
21
  end
15
22
 
23
+ flags = ARGV.reduce([]) do |reduced, a|
24
+ reduced << a if a.include?('--') || a.include?('-')
25
+ reduced
26
+ end
27
+
28
+ flags.each { |f| ARGV.delete f }
29
+
16
30
  stream = ARGV.any? ? ARGV : ARGF
17
31
 
18
32
  if stream == ARGF && $stdin.tty?
19
33
  puts "Usage:\nget-story-info-from-id STORY_ID\n"
20
34
  puts " OR\n"
21
35
  puts "echo STORY_ID | get-story-info-from-id"
36
+ puts " OR\n"
37
+ puts "use --w-owner-names to include owner names"
22
38
  exit 1
23
39
  end
24
40
 
25
41
  infos = stream.reduce([]) do |reduced, story_id|
26
42
  next reduced unless story_id && story_id =~ /\d+/
27
- reduced << get_story_info(story_id.strip)
43
+ reduced << get_story_info(story_id.strip, flags)
28
44
  end
29
45
 
30
46
  puts infos.join("\n")
data/exe/stories-deployed CHANGED
@@ -4,19 +4,36 @@ require 'json'
4
4
  require 'ostruct'
5
5
 
6
6
  environment_tag = ARGV[0]&.strip
7
-
8
7
  if environment_tag.nil? || environment_tag.empty?
9
8
  puts "Usage: stories-deployed ENVIRONMENT"
10
9
  exit 1
11
10
  end
12
11
 
13
- deployed_story_infos = `story-ids-deployed #{environment_tag} | get-story-info-from-id`
12
+ flags = ARGV.select { |a| a.include?('--') || a.include?('-') }
13
+ deployed_story_infos = `story-ids-deployed #{environment_tag} | get-story-info-from-id #{flags.join(' ')}`
14
14
 
15
15
  stories_deployed = deployed_story_infos.split("\n").compact.reduce([]) do |reduced, story_info|
16
16
  story = OpenStruct.new(JSON.parse(story_info))
17
17
 
18
+ include_owner_names = flags.any? { |f| f == '--owners' || f == '-O' }
19
+
18
20
  reduced << "#{story.error}"
19
- reduced << "#{story.name}:\n#{story.url}"
21
+ reduced << "#{story.name&.strip}:\n#{story.url}"
22
+
23
+ if include_owner_names
24
+ owners = story
25
+ .owners
26
+ .compact
27
+ .map { |o| OpenStruct.new(o).name }
28
+
29
+ names_joined = owners.size > 2 ?
30
+ "#{owners[0..-2].join(',')} and #{owners.last}" :
31
+ owners.join(' and ')
32
+
33
+ reduced << "\nBrought to you by: #{names_joined}"
34
+ end
35
+
36
+ reduced
20
37
  end
21
38
 
22
39
  puts stories_deployed
@@ -1,3 +1,3 @@
1
1
  module Pivotoolz
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pivotoolz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sufyan Adam
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-05 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client