peekj 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: a1992311107c1fc1e811ae3f67f4b8d7e6726a7a3dfda4c74fedfaaf1913fdcc
4
- data.tar.gz: 125ad3e622f5cd49169e46619d3334b772dc2f8139eb7ba896292fd435f8cb91
3
+ metadata.gz: 8fb9dea3eac792b5023030073eea733f3879dd930db492d52b56343593b480a4
4
+ data.tar.gz: 89e44665df721a597373a46a1cc415c56511eb60a37c3dd5f49250c729e7fc29
5
5
  SHA512:
6
- metadata.gz: 601cea9beb7a03452b414770dc1723390dc7a4bbf8f3650e1f1e8378fc2ccac410ba4ca32f4314150d752c3d9d4e5a36ac36364d6909de51f94904ca0420037b
7
- data.tar.gz: cc384476df9cc52cabafe2cd245d364dbe39c5ed957068be6834d7c9ecb844de2a670685b9a70a074f946c8a3549dd1ed364a2bc3579b9dbc237260a5c0a4cbb
6
+ metadata.gz: 84cacc7a93176127a20966412b9b96191b4b6ea744ab672a9c7fb9ede31d12f139119d5bf4e841964b844589085db312cb98ca70553e106ad7ec72d88f9e257e
7
+ data.tar.gz: 103d9f19863815b7be7c952b8dc5550549b90ecda4c30c61b4e55100e780100f9bd7c668fec8767b9ca9fa3afe878361e90ee312ad31d5c1b6ca74c55aab43d9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- peekj (0.1.0)
4
+ peekj (0.1.1)
5
5
  http
6
6
  thor
7
7
 
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Peekj
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/peekj`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
23
+ Enter Jira credentials and app url:
24
+
25
+ $ peekj login
26
+
27
+ Fetch issue summary:
26
28
 
27
- ## Development
29
+ $ peekj summary ISSUE-KEY
28
30
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+ Fetch issue summary from current branch name:
30
32
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/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.
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
 
@@ -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
- def summary(issue_key)
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
- desc "login", "Enter login credentials"
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
- Credentials.send("#{credential_key}=", credential_value)
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
@@ -7,14 +7,30 @@ module Peekj
7
7
  response = new.get("issue/#{issue_key}")
8
8
 
9
9
  OpenStruct.new(
10
- summary: response['fields']['summary']
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
@@ -1,3 +1,3 @@
1
1
  module Peekj
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-23 00:00:00.000000000 Z
11
+ date: 2019-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler