pivotal_tracker_cli 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +103 -0
- data/Rakefile +6 -0
- data/bin/console +5 -0
- data/bin/pt +5 -0
- data/bin/setup +6 -0
- data/lib/api.rb +87 -0
- data/lib/hash_manager.rb +24 -0
- data/lib/pivotal_tracker_cli/version.rb +3 -0
- data/lib/pivotal_tracker_cli.rb +154 -0
- data/lib/string_utilities.rb +32 -0
- data/lib/user_cache.rb +26 -0
- data/pivotal-tracker-cli.gemspec +33 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4af2149b3aca4a10c1b57ec9d58e94261545fb2d
|
4
|
+
data.tar.gz: 90a67f3fef0f78f6456cd08d5c99aff8395f1633
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 26985e6de259cafa075dc481f6839d3917e10a522eeb2e7f6170d5a9924824848e69ce8e67f6829a939b7c5684c9dca2a47aa43e1945555ad6820dacbbdc1bc5
|
7
|
+
data.tar.gz: 97b5f1ad84a04ab60b2437cca5e2ae6a4b56d692f1c31b9572c272ed48510b226f9e4b430877e249da4773ba2264549b8dbe1ce459dedbbc3945c2cdbc3fef0c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.3
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at me@jalexhall.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Alex Hall
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# PivotalTrackerCli
|
2
|
+
|
3
|
+
The purpose of this gem is to facilitate the day to day **engineering** workflow with Pivotal Tracker.
|
4
|
+
|
5
|
+
This gem is not intended to be a 1:1 cli replacement for the tracker website/app.
|
6
|
+
|
7
|
+
Current features:
|
8
|
+
- Get all stories assigned to a given user
|
9
|
+
- Grep the 3 latest iterations from the backlog (including status and assigned to)
|
10
|
+
- Show basic details about any specific story
|
11
|
+
- Update the status of any available story/chore
|
12
|
+
- Colorized and markdown formatted story output
|
13
|
+
|
14
|
+
TODOs:
|
15
|
+
- Make the current user configurable via command line
|
16
|
+
- Make the # of iterations configurable
|
17
|
+
- Make initial pt file configurable via command line
|
18
|
+
- Better error handling for initial setup & general error messages from Tracker API
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
To pull in dependencies, simply run:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
## Setup
|
27
|
+
|
28
|
+
In order to use the gem you must first create a .pt file in the home directory:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
vim ~/.pt
|
32
|
+
```
|
33
|
+
|
34
|
+
Fill in the following details, and paste into the file:
|
35
|
+
|
36
|
+
```yml
|
37
|
+
|
38
|
+
---
|
39
|
+
api_token: <API TOKEN HERE>
|
40
|
+
project_id: <PROJECT ID HERE>
|
41
|
+
usernames: [<USERNAME HERE>, ...]
|
42
|
+
```
|
43
|
+
|
44
|
+
Write, quit, and you're done!
|
45
|
+
|
46
|
+
NOTE: Details about getting an API token can be found in the [tracker API documentation](https://www.pivotaltracker.com/help/api/#Getting_Started):
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
The current commands for the gem are:
|
51
|
+
|
52
|
+
```
|
53
|
+
Commands:
|
54
|
+
pt backlog # Displays all stores for the 3 most recent iterations in the backlog
|
55
|
+
pt help [COMMAND] # Describe available commands or one specific command
|
56
|
+
pt list # Lists all current stories for current user
|
57
|
+
pt refresh # Refreshes the user cache from Tracker
|
58
|
+
pt show [STORY_ID] # Shows a specific story
|
59
|
+
pt update [STORY_ID] [STATUS] # Updates the status of a story, available statuses are: unstart, start, deliver, finish
|
60
|
+
```
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
## Development
|
65
|
+
|
66
|
+
To run the gem in development mode, simple cd to the project directory and run the following command:
|
67
|
+
|
68
|
+
```bash
|
69
|
+
bundle exec ./bin/pt
|
70
|
+
```
|
71
|
+
|
72
|
+
Once you're happy with the functionality you've built, simply bump the version in ```/lib/pivotal_tracker_cli/version.rb``` and run ```rake relase```.
|
73
|
+
|
74
|
+
This will output a gem to the ```pkg``` directory which you can then run ```gem install pkg/pivotal_tracker_cli-X.X.X.gem```.
|
75
|
+
Once you've installed the gem you can just use the ```pt``` namespace in your shell.
|
76
|
+
|
77
|
+
NOTE: X.X.X in the example above is a place holder for the major, minor, and patch release versions.
|
78
|
+
|
79
|
+
|
80
|
+
TODO: Push gem to Rubygems!!
|
81
|
+
|
82
|
+
|
83
|
+
## Contributing
|
84
|
+
|
85
|
+
In order to contribute, please create an issue to discuss the feature/bug/enhancement. If a pull request is in order,
|
86
|
+
fork the repository, create a branch off of master, and make commits with very descriptive, passing commits.
|
87
|
+
|
88
|
+
Please note that **_ALL_** code must be test driven to be accepted into the repository. No exceptions.
|
89
|
+
|
90
|
+
|
91
|
+
## Contributors
|
92
|
+
|
93
|
+
@alex-hall
|
94
|
+
|
95
|
+
@WRMilling
|
96
|
+
|
97
|
+
@lm185074
|
98
|
+
|
99
|
+
|
100
|
+
## License
|
101
|
+
|
102
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
103
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/pt
ADDED
data/bin/setup
ADDED
data/lib/api.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
module PivotalTrackerCli
|
2
|
+
class Api
|
3
|
+
def self.get_all_users_for_project(project_id, api_token)
|
4
|
+
response = HTTParty.get("https://www.pivotaltracker.com/services/v5/projects/#{project_id}/memberships",
|
5
|
+
headers: {
|
6
|
+
'X-TrackerToken': api_token
|
7
|
+
}
|
8
|
+
)
|
9
|
+
|
10
|
+
return unless response.success?
|
11
|
+
|
12
|
+
member_map = {}
|
13
|
+
|
14
|
+
response.parsed_response.map do |member|
|
15
|
+
member_map[member['person']['username']] = { id: member['person']['id'], name: member['person']['name'] }
|
16
|
+
end
|
17
|
+
|
18
|
+
member_map
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.get_story_by_id(project_id, api_token, story_id)
|
22
|
+
response = HTTParty
|
23
|
+
.get("https://www.pivotaltracker.com/services/v5/projects/#{project_id}/stories/#{story_id.to_s}",
|
24
|
+
headers: {
|
25
|
+
'X-TrackerToken': api_token
|
26
|
+
})
|
27
|
+
|
28
|
+
OpenStruct.new(response.parsed_response) if response.success?
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.update_story_state(project_id, api_token, id, state, owner_ids)
|
32
|
+
response = HTTParty.put(
|
33
|
+
"https://www.pivotaltracker.com/services/v5/projects/#{project_id}/stories/#{id.to_s}",
|
34
|
+
headers: {
|
35
|
+
'X-TrackerToken': api_token
|
36
|
+
},
|
37
|
+
body: {
|
38
|
+
'current_state': state,
|
39
|
+
'owner_ids': owner_ids
|
40
|
+
}
|
41
|
+
)
|
42
|
+
|
43
|
+
"Story ##{id} successfully #{state}." if response.success?
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.get_current_stories_for_user(project_id, api_token, usernames)
|
47
|
+
search_term = usernames.map do |username|
|
48
|
+
"owner:\"#{username}\""
|
49
|
+
end.join(' OR ')
|
50
|
+
|
51
|
+
|
52
|
+
response = HTTParty
|
53
|
+
.get("https://www.pivotaltracker.com/services/v5/projects/#{project_id}/search",
|
54
|
+
query: {
|
55
|
+
query: search_term
|
56
|
+
},
|
57
|
+
headers: {
|
58
|
+
'X-TrackerToken': api_token
|
59
|
+
})
|
60
|
+
|
61
|
+
story_list = []
|
62
|
+
|
63
|
+
response.parsed_response['stories']['stories'].map { |story| story_list.push(OpenStruct.new(story)) } if response.success?
|
64
|
+
|
65
|
+
story_list
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.get_backlog_for_project(project_id, api_token, limit=3)
|
69
|
+
|
70
|
+
endpoint = "https://www.pivotaltracker.com/services/v5/projects/#{project_id}/iterations?scope=current_backlog&limit=#{limit}"
|
71
|
+
|
72
|
+
response = HTTParty.get(endpoint,
|
73
|
+
headers: {
|
74
|
+
'X-TrackerToken': api_token
|
75
|
+
})
|
76
|
+
|
77
|
+
stories = []
|
78
|
+
|
79
|
+
response.parsed_response.each do |iteration|
|
80
|
+
iteration['stories'].each do |story|
|
81
|
+
stories.push(OpenStruct.new(story))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
stories
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/hash_manager.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module PivotalTrackerCli
|
2
|
+
class HashManager
|
3
|
+
def self.get_owner_name_from_ids(owners, username_to_user_id_map)
|
4
|
+
return 'unassigned'.light_blue if owners.empty?
|
5
|
+
|
6
|
+
owners.map do |owner|
|
7
|
+
find_name_given_id(owner, username_to_user_id_map)
|
8
|
+
end.join(', ').yellow
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_name_given_id(owner_id, username_to_user_id_map)
|
12
|
+
name = ''
|
13
|
+
|
14
|
+
username_to_user_id_map.each_value do |value|
|
15
|
+
if value[:id] == owner_id
|
16
|
+
name = value[:name]
|
17
|
+
break
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'httparty'
|
3
|
+
require 'awesome_print'
|
4
|
+
require 'thor'
|
5
|
+
require 'byebug'
|
6
|
+
require 'colorize'
|
7
|
+
require 'colorized_string'
|
8
|
+
require_relative 'api'
|
9
|
+
require_relative 'string_utilities'
|
10
|
+
require_relative 'user_cache'
|
11
|
+
require_relative 'hash_manager'
|
12
|
+
|
13
|
+
module PivotalTrackerCli
|
14
|
+
class Client < Thor
|
15
|
+
|
16
|
+
attr_reader :username_to_user_id_map
|
17
|
+
|
18
|
+
def initialize(args, local_options, config)
|
19
|
+
@config = YAML.load_file(ENV['HOME'] + '/.pt')
|
20
|
+
|
21
|
+
@api_token = @config['api_token']
|
22
|
+
@project_id = @config['project_id']
|
23
|
+
@usernames = @config['usernames']
|
24
|
+
|
25
|
+
@story_statuses = {
|
26
|
+
'unstart' => 'unstarted',
|
27
|
+
'start' => 'started',
|
28
|
+
'deliver' => 'delivered',
|
29
|
+
'finish' => %w(finished accepted)
|
30
|
+
}
|
31
|
+
|
32
|
+
@username_to_user_id_map = build_or_assign_user_cache(@config)
|
33
|
+
super
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'list', 'Lists all current stories for current user'
|
37
|
+
|
38
|
+
def list
|
39
|
+
get_current_stories_for_user.map do |story|
|
40
|
+
output.puts('*' * 40)
|
41
|
+
format_story(story)
|
42
|
+
end
|
43
|
+
output.puts('*' * 40)
|
44
|
+
end
|
45
|
+
|
46
|
+
desc 'show [STORY_ID]', 'Shows a specific story'
|
47
|
+
|
48
|
+
def show(id)
|
49
|
+
format_story(get_story(id))
|
50
|
+
end
|
51
|
+
|
52
|
+
desc 'update [STORY_ID] [STATUS]', 'Updates the status of a story, available statuses are: unstart, start, deliver, finish'
|
53
|
+
|
54
|
+
def update(id, status)
|
55
|
+
validate_and_update_story(id, status)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc 'backlog', 'Displays all stores for the 3 most recent iterations in the backlog'
|
59
|
+
|
60
|
+
def backlog
|
61
|
+
get_backlog(3).map do |story|
|
62
|
+
output.puts("* #{story.id.to_s.red} - #{colorize_status(story.current_state)} - #{embiggen_string(story.name)} <#{get_owner_name_from_ids(story.owner_ids)}>")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
desc 'refresh', 'Refreshes the user cache for tracker'
|
67
|
+
|
68
|
+
def refresh
|
69
|
+
rebuild_user_cache(@config)
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def validate_and_update_story(id, status)
|
75
|
+
return output.puts('Invalid story status. Story statuses are: unstart, start, deliver, finish') unless @story_statuses[status]
|
76
|
+
|
77
|
+
story = get_story(id)
|
78
|
+
|
79
|
+
return output.puts('Story not found, please validate story number.') unless story
|
80
|
+
|
81
|
+
if status != 'finish'
|
82
|
+
output.puts(update_story(id, @story_statuses[status]))
|
83
|
+
else
|
84
|
+
if story.story_type == 'chore'
|
85
|
+
output.puts(update_story(id, 'accepted'))
|
86
|
+
else
|
87
|
+
output.puts(update_story(id, 'finished'))
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def format_story(story)
|
94
|
+
output.puts("#{'Story ID'.bold} : #{story.id}")
|
95
|
+
output.puts("#{'Status'.bold} : #{colorize_status(story.current_state)}")
|
96
|
+
output.puts("#{'Story Type'.bold} : #{story.story_type}")
|
97
|
+
output.puts("#{'Story Name'.bold} : #{embiggen_string(story.name)}")
|
98
|
+
output.puts("#{'Owners'.bold} : #{get_owner_name_from_ids(story.owner_ids).yellow}")
|
99
|
+
output.puts("#{'Story Description'.bold} :")
|
100
|
+
output.puts(" #{wrap(embiggen_string(story.description), 150, 10)}")
|
101
|
+
end
|
102
|
+
def wrap(s, width=150, offset=0)
|
103
|
+
s.gsub(/(.{1,#{width}})(\s+|\Z)/, "#{' '* offset}\\1\n")
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_owner_name_from_ids(owners)
|
107
|
+
PivotalTrackerCli::HashManager.get_owner_name_from_ids(owners, @username_to_user_id_map)
|
108
|
+
end
|
109
|
+
|
110
|
+
def find_name_given_id(owners)
|
111
|
+
PivotalTrackerCli::HashManager.find_name_given_id(owners, @username_to_user_id_map)
|
112
|
+
end
|
113
|
+
|
114
|
+
def build_or_assign_user_cache(config)
|
115
|
+
PivotalTrackerCli::UserCache.build_or_assign_user_cache(config, @project_id, @api_token)
|
116
|
+
end
|
117
|
+
|
118
|
+
def rebuild_user_cache(config)
|
119
|
+
PivotalTrackerCli::UserCache.rebuild_user_cache(config, @project_id, @api_token)
|
120
|
+
end
|
121
|
+
|
122
|
+
def embiggen_string(string)
|
123
|
+
PivotalTrackerCli::StringUtilities.embiggen_string(string)
|
124
|
+
end
|
125
|
+
|
126
|
+
def colorize_status(status)
|
127
|
+
PivotalTrackerCli::StringUtilities.colorize_status(status)
|
128
|
+
end
|
129
|
+
|
130
|
+
def get_backlog(iterations)
|
131
|
+
PivotalTrackerCli::Api.get_backlog_for_project(@project_id, @api_token, iterations)
|
132
|
+
end
|
133
|
+
|
134
|
+
def get_current_stories_for_user
|
135
|
+
PivotalTrackerCli::Api.get_current_stories_for_user(@project_id, @api_token, @usernames)
|
136
|
+
end
|
137
|
+
|
138
|
+
def get_story(id)
|
139
|
+
PivotalTrackerCli::Api.get_story_by_id(@project_id, @api_token, id)
|
140
|
+
end
|
141
|
+
|
142
|
+
def update_story(id, status)
|
143
|
+
PivotalTrackerCli::Api.update_story_state(@project_id, @api_token, id, status, get_user_ids_from_usernames(@username_to_user_id_map, @usernames))
|
144
|
+
end
|
145
|
+
|
146
|
+
def output
|
147
|
+
@output ||= $stdout
|
148
|
+
end
|
149
|
+
|
150
|
+
def get_user_ids_from_usernames(user_map, username)
|
151
|
+
PivotalTrackerCli::UserCache.get_user_ids_from_usernames(user_map, username)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module PivotalTrackerCli
|
2
|
+
class StringUtilities
|
3
|
+
|
4
|
+
def self.embiggen_string(string)
|
5
|
+
return string if ENV['DISABLE_MARKDOWN'] == 'true'
|
6
|
+
|
7
|
+
string
|
8
|
+
.gsub(/(\*\*)(.*?)(\*\*)/, "\033[1m" + '\2' "\033[0m")
|
9
|
+
.gsub(/(_)(.*?)(_)/, "\033[4m" + '\2' "\033[0m")
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.colorize_status(story_state)
|
13
|
+
case story_state
|
14
|
+
when 'rejected'
|
15
|
+
return story_state.red
|
16
|
+
when 'accepted'
|
17
|
+
return story_state.green
|
18
|
+
when 'delivered'
|
19
|
+
return story_state.cyan
|
20
|
+
when 'finished'
|
21
|
+
return story_state.yellow
|
22
|
+
when 'started'
|
23
|
+
return story_state.magenta
|
24
|
+
when 'unstarted'
|
25
|
+
return story_state
|
26
|
+
end
|
27
|
+
|
28
|
+
story_state
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
data/lib/user_cache.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module PivotalTrackerCli
|
2
|
+
class UserCache
|
3
|
+
|
4
|
+
def self.build_or_assign_user_cache(config, project_id, api_token)
|
5
|
+
config['username_to_user_id_map'] || rebuild_user_cache(config, project_id, api_token)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.rebuild_user_cache(config, project_id, api_token)
|
9
|
+
username_to_user_id_map = PivotalTrackerCli::Api.get_all_users_for_project(project_id, api_token)
|
10
|
+
|
11
|
+
config['username_to_user_id_map'] = username_to_user_id_map
|
12
|
+
|
13
|
+
File.open(ENV['HOME'] + '/.pt', 'w') do |f|
|
14
|
+
f.write config.to_yaml
|
15
|
+
end
|
16
|
+
|
17
|
+
username_to_user_id_map
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get_user_ids_from_usernames(user_map, usernames)
|
21
|
+
usernames.map do |username|
|
22
|
+
user_map[username][:id]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pivotal_tracker_cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'pivotal_tracker_cli'
|
8
|
+
spec.version = PivotalTrackerCli::VERSION
|
9
|
+
spec.authors = ['Alex Hall']
|
10
|
+
spec.email = ['me@jalexhall.com']
|
11
|
+
|
12
|
+
spec.summary = 'This gem is supposed to be used for dev purposes'
|
13
|
+
spec.description = 'Simple integration with pivotal-tracker gem'
|
14
|
+
spec.homepage = 'http://github.com/alex-hall/pivotal_tracker_cli'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'bin'
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'httparty'
|
25
|
+
spec.add_dependency 'thor'
|
26
|
+
spec.add_dependency 'colorize'
|
27
|
+
|
28
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
29
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
31
|
+
spec.add_development_dependency 'byebug'
|
32
|
+
spec.add_development_dependency 'awesome_print'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pivotal_tracker_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 5.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Hall
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.13'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.13'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: awesome_print
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Simple integration with pivotal-tracker gem
|
126
|
+
email:
|
127
|
+
- me@jalexhall.com
|
128
|
+
executables:
|
129
|
+
- console
|
130
|
+
- pt
|
131
|
+
- setup
|
132
|
+
extensions: []
|
133
|
+
extra_rdoc_files: []
|
134
|
+
files:
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".ruby-version"
|
138
|
+
- CODE_OF_CONDUCT.md
|
139
|
+
- Gemfile
|
140
|
+
- LICENSE.txt
|
141
|
+
- README.md
|
142
|
+
- Rakefile
|
143
|
+
- bin/console
|
144
|
+
- bin/pt
|
145
|
+
- bin/setup
|
146
|
+
- lib/api.rb
|
147
|
+
- lib/hash_manager.rb
|
148
|
+
- lib/pivotal_tracker_cli.rb
|
149
|
+
- lib/pivotal_tracker_cli/version.rb
|
150
|
+
- lib/string_utilities.rb
|
151
|
+
- lib/user_cache.rb
|
152
|
+
- pivotal-tracker-cli.gemspec
|
153
|
+
homepage: http://github.com/alex-hall/pivotal_tracker_cli
|
154
|
+
licenses:
|
155
|
+
- MIT
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 2.5.2
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: This gem is supposed to be used for dev purposes
|
177
|
+
test_files: []
|