pttool 0.0.2 → 0.0.3
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 +4 -4
- data/README.md +5 -0
- data/lib/pttool/application.rb +39 -21
- data/lib/pttool/helper.rb +1 -3
- data/lib/pttool/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 289e2e3641c45a7859cc2080d6fde2db0efca87c
|
4
|
+
data.tar.gz: 89658f299963cd8563c7a354b8defe33a9fbda26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 044a16ccb34b76bd1145ba1d2b7068012b66526921b67f4060b75b9dd5875ce4b6975abcb341f01ebf08f809c2b6489b7703403af41b3b975a6db534a23c045c
|
7
|
+
data.tar.gz: d7cc566a1cb5248990c115dab0f017f2f2722e7dd72990f74b1926ea6e1daec8b979b536c4762f2f4428197891049a585d41da82065e2270410b245e6023f9e2
|
data/README.md
CHANGED
@@ -9,6 +9,11 @@
|
|
9
9
|
|
10
10
|
### List of PT Projects
|
11
11
|
|
12
|
+
In order to use this tool, the environment variable `PT_TOKEN` must be set to
|
13
|
+
your PivotalTracker API key. The key is listed under the "API TOKEN" section at
|
14
|
+
the bottom of your PivotalTracker
|
15
|
+
[profile](https://www.pivotaltracker.com/profile)."
|
16
|
+
|
12
17
|
pttool projects
|
13
18
|
|
14
19
|
### Other
|
data/lib/pttool/application.rb
CHANGED
@@ -10,54 +10,68 @@ module PTTool
|
|
10
10
|
pttool: A tool that interfaces with pivotal tracker.
|
11
11
|
|
12
12
|
Usage:
|
13
|
-
pttool projects [--sort=<key>] [--
|
14
|
-
pttool sync PROJECT... [--force]
|
13
|
+
pttool projects [--sort=<key>] [--num_members]
|
14
|
+
pttool sync PROJECT... [--force] [--dryrun]
|
15
15
|
pttool -h | --help
|
16
16
|
pttool --version
|
17
17
|
|
18
18
|
Options:
|
19
|
-
--
|
20
|
-
|
21
|
-
--
|
22
|
-
|
23
|
-
|
19
|
+
--dryrun Do a dry run of the sync, printing out end result
|
20
|
+
[default: false].
|
21
|
+
--force Do not prompt for confirmation [default: false].
|
22
|
+
--num_members Output the number of members for each project
|
23
|
+
[default: false].
|
24
|
+
--sort=<key> Sort output by name or id [default: name].
|
25
|
+
-h --help Show this information.
|
26
|
+
--version Show the pttool version (#{VERSION}).
|
24
27
|
DOC
|
25
28
|
|
26
29
|
def initialize
|
27
30
|
@exit_status = 0
|
28
31
|
end
|
29
32
|
|
30
|
-
def cmd_projects(
|
33
|
+
def cmd_projects(num_members, sort)
|
31
34
|
valid = %w(name id)
|
32
35
|
raise Docopt::Exit, 'invalid sort option' unless valid.include?(sort)
|
33
36
|
PTTool.client.projects.sort_by { |k| k.send(sort) }.each do |project|
|
34
|
-
member_extra = " (#{project.memberships.size} members)" if
|
37
|
+
member_extra = " (#{project.memberships.size} members)" if num_members
|
35
38
|
puts format("%8s: #{project.name}#{member_extra}", project.id)
|
36
39
|
end
|
37
40
|
end
|
38
41
|
|
39
|
-
def cmd_sync(projects, force)
|
40
|
-
|
42
|
+
def cmd_sync(projects, dryrun, force)
|
43
|
+
if projects.size < 2
|
44
|
+
raise Docopt::Exit, 'must list at least two projects'
|
45
|
+
end
|
41
46
|
|
42
47
|
require 'set'
|
43
|
-
|
48
|
+
all_people = Set.new
|
44
49
|
by_project = {}
|
45
50
|
|
46
51
|
PTTool.client.projects.each do |project|
|
47
52
|
next unless projects.include?(project.name)
|
48
53
|
projects.delete(project.name)
|
49
|
-
|
50
|
-
|
51
|
-
# tracker_api doesn't properly compare People objects so we'll only
|
52
|
-
# use their id (for now)
|
53
|
-
by_project[project] = project.memberships.map(&:person).map(&:id))
|
54
|
+
all_people.merge(
|
55
|
+
by_project[project] = project.memberships.map(&:person))
|
54
56
|
end
|
55
57
|
|
56
58
|
puts "Could not match: #{projects.join(', ')}" unless projects.empty?
|
57
59
|
raise Error, 'too few matching projects' if by_project.size < 2
|
58
60
|
|
59
|
-
|
60
|
-
|
61
|
+
if dryrun
|
62
|
+
puts "\nThe following would become members on all projects:"
|
63
|
+
all_people.sort_by(&:name).each { |person| display_person(person) }
|
64
|
+
|
65
|
+
by_project.each do |project, people|
|
66
|
+
next unless new = all_people - people
|
67
|
+
puts "\nNew members for #{project.name}:"
|
68
|
+
new.sort_by(&:name).each { |person| display_person(person) }
|
69
|
+
end
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
by_project.each do |project, people|
|
74
|
+
to_add = all_people - people
|
61
75
|
next if to_add.empty? || (!force && !Helper.prompt(
|
62
76
|
"Do you want to add #{to_add.size} people to #{project.name}?"))
|
63
77
|
to_add.each { |person_id| Helper.add_membership(project, person_id) }
|
@@ -74,6 +88,10 @@ module PTTool
|
|
74
88
|
|
75
89
|
private
|
76
90
|
|
91
|
+
def display_person(person)
|
92
|
+
puts person.email ? "#{person.name} (#{person.email})" : person.name
|
93
|
+
end
|
94
|
+
|
77
95
|
def exit_with_status(msg, condition = true)
|
78
96
|
puts msg
|
79
97
|
@exit_status == 0 && condition ? 1 : @exit_status
|
@@ -81,9 +99,9 @@ module PTTool
|
|
81
99
|
|
82
100
|
def handle_args(options)
|
83
101
|
if options['projects']
|
84
|
-
cmd_projects(options['--
|
102
|
+
cmd_projects(options['--num_members'], options['--sort'])
|
85
103
|
elsif options['sync']
|
86
|
-
cmd_sync(options['PROJECT'], options['--force'])
|
104
|
+
cmd_sync(options['PROJECT'], options['--dryrun'], options['--force'])
|
87
105
|
else
|
88
106
|
commands = options.find_all { |x| x[1] == true }.map { |x| x[0] }
|
89
107
|
puts "Unhandled command(s): #{commands}"
|
data/lib/pttool/helper.rb
CHANGED
@@ -11,9 +11,7 @@ module PTTool
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.add_membership(project, person_id, role = 'member')
|
14
|
-
|
15
|
-
params: { person_id: person_id, role: role })
|
16
|
-
puts data.body
|
14
|
+
project.add_membership(person_id: person_id, role: role)
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
data/lib/pttool/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pttool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce Boe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
78
|
+
rubygems_version: 2.4.5.1
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
|
-
summary: Command line tool that interfaces with pivotaltracker
|
81
|
+
summary: Command line tool that interfaces with pivotaltracker.
|
82
82
|
test_files: []
|