peekj 0.1.0 → 0.1.1
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/Gemfile.lock +1 -1
- data/README.md +11 -9
- data/lib/peekj/cli.rb +47 -7
- data/lib/peekj/jira_api.rb +18 -2
- data/lib/peekj/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fb9dea3eac792b5023030073eea733f3879dd930db492d52b56343593b480a4
|
4
|
+
data.tar.gz: 89e44665df721a597373a46a1cc415c56511eb60a37c3dd5f49250c729e7fc29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84cacc7a93176127a20966412b9b96191b4b6ea744ab672a9c7fb9ede31d12f139119d5bf4e841964b844589085db312cb98ca70553e106ad7ec72d88f9e257e
|
7
|
+
data.tar.gz: 103d9f19863815b7be7c952b8dc5550549b90ecda4c30c61b4e55100e780100f9bd7c668fec8767b9ca9fa3afe878361e90ee312ad31d5c1b6ca74c55aab43d9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Peekj
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Command line interface to interact with Jira's API.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -14,7 +12,7 @@ gem 'peekj'
|
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
17
|
-
$ bundle
|
15
|
+
$ bundle install
|
18
16
|
|
19
17
|
Or install it yourself as:
|
20
18
|
|
@@ -22,17 +20,21 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
Enter Jira credentials and app url:
|
24
|
+
|
25
|
+
$ peekj login
|
26
|
+
|
27
|
+
Fetch issue summary:
|
26
28
|
|
27
|
-
|
29
|
+
$ peekj summary ISSUE-KEY
|
28
30
|
|
29
|
-
|
31
|
+
Fetch issue summary from current branch name:
|
30
32
|
|
31
|
-
|
33
|
+
$ peekj summary --current_branch
|
32
34
|
|
33
35
|
## Contributing
|
34
36
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ericlarosa/peekj. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
38
|
|
37
39
|
## License
|
38
40
|
|
data/lib/peekj/cli.rb
CHANGED
@@ -3,21 +3,61 @@ require 'thor'
|
|
3
3
|
|
4
4
|
module Peekj
|
5
5
|
class CLI < Thor
|
6
|
+
desc "login", "Enter login credentials"
|
7
|
+
def login
|
8
|
+
Credentials::KEYS.each do |credential_key|
|
9
|
+
credential_value = ask("#{credential_key}:")
|
10
|
+
|
11
|
+
Credentials.send("#{credential_key}=", credential_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
6
15
|
desc "summary ITEM", "Prints issue summary"
|
7
|
-
|
16
|
+
method_options current_branch: :boolean,
|
17
|
+
short: :boolean,
|
18
|
+
long: :boolean
|
19
|
+
def summary(issue_key=nil)
|
20
|
+
issue_key = current_branch_issue_key if options['current_branch']
|
21
|
+
|
8
22
|
issue = JiraApi.get_issue(issue_key)
|
9
23
|
|
24
|
+
say("#{issue_key} ", [:bold, :red])
|
25
|
+
say("(#{issue.status})", [:bold, :magenta])
|
10
26
|
say(issue.summary)
|
27
|
+
|
28
|
+
unless options['short']
|
29
|
+
say('Description:', [:bold, :red])
|
30
|
+
say(issue.description)
|
31
|
+
end
|
32
|
+
|
33
|
+
if options['long']
|
34
|
+
say('Comments:', [:bold, :red])
|
35
|
+
issue.comments.each do |comment|
|
36
|
+
say("#{comment[:author]}: ", [:yellow])
|
37
|
+
say(comment[:body])
|
38
|
+
end
|
39
|
+
end
|
11
40
|
end
|
12
41
|
|
42
|
+
desc "comment ITEM", "Adds comment to issue"
|
43
|
+
method_options current_branch: :boolean
|
44
|
+
def comment(issue_key=nil)
|
45
|
+
issue_key = current_branch_issue_key if options['current_branch']
|
13
46
|
|
14
|
-
|
15
|
-
def login
|
16
|
-
Credentials::KEYS.each do |credential_key|
|
17
|
-
credential_value = ask("#{credential_key}:")
|
47
|
+
add_comment_succeeded = JiraApi.add_comment(issue_key, ask('Comment:', [:red, :bold]))
|
18
48
|
|
19
|
-
|
49
|
+
if add_comment_succeeded
|
50
|
+
say('Comment added succesfully', [:green, :bold])
|
51
|
+
else
|
52
|
+
say('Error', [:red, :bold])
|
20
53
|
end
|
21
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def current_branch_issue_key
|
59
|
+
current_branch = `git rev-parse --abbrev-ref HEAD`
|
60
|
+
current_branch.match(/[^-]*-[^-]*/)
|
61
|
+
end
|
22
62
|
end
|
23
|
-
end
|
63
|
+
end
|
data/lib/peekj/jira_api.rb
CHANGED
@@ -7,14 +7,30 @@ module Peekj
|
|
7
7
|
response = new.get("issue/#{issue_key}")
|
8
8
|
|
9
9
|
OpenStruct.new(
|
10
|
-
|
10
|
+
status: response['fields']['status']['name'],
|
11
|
+
summary: response['fields']['summary'],
|
12
|
+
description: response['fields']['description'],
|
13
|
+
comments: response['fields']['comment']['comments'].map { |c|
|
14
|
+
{author: c['author']['displayName'], body: c['body']}
|
15
|
+
}
|
11
16
|
)
|
12
17
|
end
|
13
18
|
|
19
|
+
def self.add_comment(issue_key, comment_body)
|
20
|
+
params = {body: comment_body}
|
21
|
+
response = new.post("issue/#{issue_key}/comment", params)
|
22
|
+
post_succeeded = !response['created'].nil?
|
23
|
+
post_succeeded
|
24
|
+
end
|
25
|
+
|
14
26
|
def get(relative_path)
|
15
27
|
HTTP.basic_auth(auth_params).get("#{base_url}#{relative_path}").parse
|
16
28
|
end
|
17
29
|
|
30
|
+
def post(relative_path, params)
|
31
|
+
HTTP.basic_auth(auth_params).post("#{base_url}#{relative_path}", json: params).parse
|
32
|
+
end
|
33
|
+
|
18
34
|
private
|
19
35
|
|
20
36
|
def auth_params
|
@@ -27,4 +43,4 @@ module Peekj
|
|
27
43
|
"#{app_url}/rest/api/latest/"
|
28
44
|
end
|
29
45
|
end
|
30
|
-
end
|
46
|
+
end
|
data/lib/peekj/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peekj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric La Rosa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|