jira-cli 0.3.0 → 0.3.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
  SHA1:
3
- metadata.gz: 90eee20531277d150c8a465d36bd465f87aadc09
4
- data.tar.gz: 40144b5a1cb60ff669124475a6a651fa45b6691a
3
+ metadata.gz: 874d1feca2b584a69783f88d0001e695160e8d81
4
+ data.tar.gz: f4ad3bcdeaf2fdb0013521e248928f5b736f0704
5
5
  SHA512:
6
- metadata.gz: 74fad1cbbdc11727a57c82fa39e3184eb7d80a5b199aac67eabbc9fe14acc510412f3b30a83ad805abd89ea30dc19eddd3517195a43829bfd400ff10d04f01f4
7
- data.tar.gz: fb6e29c2710f0b74bb3000cb767799aff6f0bc82c5bb9199ed9cad29a91acb7646f0ab7eb1c59f543bc2dcfe7da546853f103dd47a49d9d40dd3abb18528df71
6
+ metadata.gz: f3a5d3352e86aee6c4178b5e72077e2ec5b077d9edcce645e2728b707218727e95aafb474d4f93c9aff4ce466df4c7d8cffa5749c7d3ab8fee13a4f71272a1b9
7
+ data.tar.gz: b45960e75e9707977c91aa38e22b81d065710e678e7caebbd7903f7494216eb95560d9c4e4c73459c17fffffe3d368ec7d04b89e39c5d842127ec216c9799b4f
data/README.md CHANGED
@@ -23,7 +23,7 @@ Ruby gem CLI tool used to manage JIRA workflows leveraging git
23
23
  jira new # Creates a new ticket in JIRA and checks out the git branch
24
24
  jira rename # Updates the summary of the input ticket
25
25
  jira sprint # Lists sprint info
26
- jira tickets # List the tickets of the input username
26
+ jira tickets [jql] # List the tickets of the input username (or jql)
27
27
  jira transition # Transitions the input ticket to the next state
28
28
  jira version # Displays the version
29
29
  jira vote <command> # Commands for voting operations in JIRA
data/lib/jira/command.rb CHANGED
@@ -22,11 +22,12 @@ module Jira
22
22
  @auth_api ||= Jira::AuthAPI.new
23
23
  end
24
24
 
25
+ # TODO: Move this to relevant subcommand Base
25
26
  def body
26
27
  @body ||= (
27
28
  comment = io.ask("Leave a comment for ticket #{ticket}:").strip
28
- comment = comment.gsub(/\@[a-zA-Z]+/,'[~\0]') || comment
29
- comment.gsub('[~@','[~') || comment
29
+ comment = comment.gsub(/\@[a-zA-Z]+/, '[~\0]') || comment
30
+ comment.gsub('[~@', '[~') || comment
30
31
  )
31
32
  end
32
33
 
@@ -39,7 +40,7 @@ module Jira
39
40
  end
40
41
 
41
42
  def render_table(header, rows)
42
- puts TTY::Table.new(header, rows).render(:ascii, padding: [0,1])
43
+ puts TTY::Table.new(header, rows).render(:ascii, padding: [0, 1])
43
44
  end
44
45
 
45
46
  def truncate(string, limit=80)
@@ -35,7 +35,7 @@ module Jira
35
35
  end
36
36
  end
37
37
 
38
- private
38
+ private
39
39
 
40
40
  def metadata
41
41
  @metadata ||= api.get("issue/#{ticket}")
@@ -30,7 +30,7 @@ module Jira
30
30
  failure: on_failure
31
31
  end
32
32
 
33
- private
33
+ private
34
34
 
35
35
  def on_success
36
36
  -> do
@@ -46,7 +46,7 @@ module Jira
46
46
  def branches
47
47
  branches = `git branch --list 2> /dev/null`.split(' ')
48
48
  branches.delete("*")
49
- branches.delete("#{ticket}")
49
+ branches.delete(ticket.to_s)
50
50
  branches
51
51
  end
52
52
 
@@ -36,7 +36,7 @@ module Jira
36
36
  def base_params
37
37
  {
38
38
  url: url,
39
- username: username,
39
+ username: username
40
40
  }
41
41
  end
42
42
 
@@ -33,7 +33,7 @@ module Jira
33
33
  end
34
34
  end
35
35
 
36
- private
36
+ private
37
37
 
38
38
  def params
39
39
  {
@@ -82,8 +82,7 @@ module Jira
82
82
  end
83
83
 
84
84
  def invalid_ticket?
85
- return true unless Jira::Core.ticket?(outward_ticket)
86
- return false
85
+ !Jira::Core.ticket?(outward_ticket)
87
86
  end
88
87
 
89
88
  def metadata
@@ -19,7 +19,6 @@ module Jira
19
19
  return if issue_type.empty?
20
20
  return if assign_parent? && parent.empty?
21
21
  return if summary.empty?
22
- return if description.empty?
23
22
 
24
23
  api.post 'issue',
25
24
  params: params,
@@ -74,7 +73,7 @@ module Jira
74
73
  end
75
74
 
76
75
  def metadata
77
- # TODO - {} on 200 but jira error
76
+ # TODO: {} on 200 but jira error
78
77
  @metadata ||= api.get('issue/createmeta')
79
78
  end
80
79
 
@@ -141,11 +140,11 @@ module Jira
141
140
  end
142
141
 
143
142
  def summary
144
- @summary ||= io.ask("Summary:")
143
+ @summary ||= io.ask("Summary:", default: '')
145
144
  end
146
145
 
147
146
  def description
148
- @description ||= io.ask("Description:")
147
+ @description ||= io.ask("Description:", default: '')
149
148
  end
150
149
 
151
150
  end
@@ -28,7 +28,7 @@ module Jira
28
28
  puts "The #{rapid_view['name']} board has no sprints."
29
29
  return true
30
30
  end
31
- return false
31
+ false
32
32
  end
33
33
 
34
34
  def info
@@ -1,42 +1,48 @@
1
1
  module Jira
2
2
  class CLI < Thor
3
3
 
4
- desc "tickets", "List the tickets of the input username"
5
- def tickets(username=Jira::Core.username)
6
- Command::Tickets.new(username).run
4
+ desc "tickets [jql]", "List the tickets of the input jql"
5
+ def tickets(jql="assignee=#{Jira::Core.username}")
6
+ Command::Tickets.new(jql).run
7
7
  end
8
+
8
9
  end
9
10
 
10
11
  module Command
11
12
  class Tickets < Base
12
13
 
13
- attr_accessor :username
14
+ attr_accessor :jql
14
15
 
15
- def initialize(username)
16
- self.username = username
16
+ def initialize(jql)
17
+ self.jql = jql
17
18
  end
18
19
 
19
20
  def run
20
- return if username.empty?
21
+ return if jql.empty?
21
22
  return if metadata.empty?
23
+ puts "There are no tickets for jql=#{jql}." and return if rows.empty?
24
+ render_table(header, rows)
25
+ end
22
26
 
23
- issues = metadata['issues']
24
- if !issues.nil? and issues.count > 0
25
- issues.each do |issue|
26
- ticket = issue['key']
27
+ private
27
28
 
28
- printf "[%2d]", issues.index(issue)
29
- puts " #{Jira::Format.ticket(ticket)}"
30
- end
31
- else
32
- puts "There are no tickets for username #{username}."
33
- end
29
+ def header
30
+ [ 'Ticket', 'Assignee', 'Status', 'Summary']
34
31
  end
35
32
 
36
- private
33
+ def rows
34
+ metadata['issues'].map do |issue|
35
+ [
36
+ issue['key'],
37
+ issue['fields']['assignee']['name'] || 'Unassigned',
38
+ issue['fields']['status']['name'] || 'Unknown',
39
+ truncate(issue['fields']['summary'], 45)
40
+ ]
41
+ end
42
+ end
37
43
 
38
44
  def metadata
39
- @metadata ||= api.get("search?jql=assignee=#{username}")
45
+ @metadata ||= api.get("search?jql=#{jql}")
40
46
  end
41
47
 
42
48
  end
@@ -46,7 +46,7 @@ module Jira
46
46
  puts "There are no votes on ticket #{ticket}."
47
47
  return true
48
48
  end
49
- return false
49
+ false
50
50
  end
51
51
 
52
52
  def voters
@@ -1,5 +1,5 @@
1
1
  module Jira
2
2
 
3
- VERSION = '0.3.0'
3
+ VERSION = '0.3.1'.freeze
4
4
 
5
5
  end
data/lib/jira/core.rb CHANGED
@@ -60,7 +60,7 @@ module Jira
60
60
  if verbose
61
61
  puts "#{Jira::Format.ticket(ticket)} is not a valid JIRA ticket."
62
62
  end
63
- return false
63
+ false
64
64
  end
65
65
 
66
66
  ### Relevant Paths
@@ -84,7 +84,7 @@ module Jira
84
84
 
85
85
  def config
86
86
  @config ||= (
87
- raise InstallationException unless File.exists?(cli_path)
87
+ raise InstallationException unless File.exist?(cli_path)
88
88
  IniFile.load(cli_path, comment: '#', encoding: 'UTF-8')
89
89
  )
90
90
  end
data/lib/jira/format.rb CHANGED
@@ -38,7 +38,7 @@ module Jira
38
38
 
39
39
  def time(time)
40
40
  "#{Thor::Shell::Color::BLUE}"\
41
- "#{time.strftime("%l:%M%P on %b %d, %Y").strip}"\
41
+ "#{time.strftime('%l:%M%P on %b %d, %Y').strip}"\
42
42
  "#{Thor::Shell::Color::CLEAR}"
43
43
  end
44
44
 
@@ -59,7 +59,7 @@ module Jira
59
59
  ")"\
60
60
  "#{Thor::Shell::Color::CLEAR}"
61
61
  )
62
- return comment
62
+ comment
63
63
  end
64
64
 
65
65
  def wrap(text)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jira-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darren Cheng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -124,21 +124,7 @@ dependencies:
124
124
  - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: 2.0.2
127
- - !ruby/object:Gem::Dependency
128
- name: pry
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- version: '0'
141
- description: CLI used to manage JIRA workflows leveraging git
127
+ description: Ruby CLI managing git-based JIRA workflows
142
128
  email: darren@thanx.com
143
129
  executables:
144
130
  - jira