terjira 0.2.6 → 0.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a25d4e42aca093fd16ddd3aa3a653132f7716549
4
- data.tar.gz: f1d2c6ff0b4c3aa3ee421f73d0d153cb67fc73f0
3
+ metadata.gz: dbde3ec56e09285e05737a7fa9b04bb696f6a343
4
+ data.tar.gz: 1357fd83a6d0d4aafbc3d8900852a651d12558bf
5
5
  SHA512:
6
- metadata.gz: f621c41ba152ddada71cd29cfd993ebbef00351a5a56e54ec4b9989db2de2297232c48fc977bc7dd86cd35741d49f362aadff7cf34081508310c41cae179b60c
7
- data.tar.gz: a78015b6021e980146aa79dd1b55a7cf7a89975df31ddee8076b68126748b3088e3ce205956efa29a73f1c0acec26fe780565ed6409aef70d45a2c41bb283dcf
6
+ metadata.gz: 7b9802b1f64d38f141695c02566f9c4c1f7adee68f3980e69515e1bf7b7ecd933c0782006c26c1722d0a267b5118b8d5146c8ba6c2430df14fc994cf935cd495
7
+ data.tar.gz: 433252922de158d3033c3a2441200c644f73c25c36e047c6d286556b5a44c4e9ae1c9a7a18d722e05d6385ef3e4ba81dac94eaba706fec8f6e03c53069f7f1d1
data/README.md CHANGED
@@ -61,6 +61,7 @@ Issue:
61
61
  jira issue jql "[QUERY]" # Search issues with JQL
62
62
  # ex)
63
63
  # jira issue jql "project = 'TEST' AND summary ~ 'authentication'"
64
+ jira issue search "[SUMMARY]" # Search for an issues by summary
64
65
  jira issue [ISSUE_KEY] # Show detail of the issue
65
66
  jira issue assign [ISSUE_KEY] ([ASSIGNEE]) # Assign the issue to user
66
67
  jira issue comment [ISSUE_KEY] # Write comment on the issue
@@ -76,6 +77,7 @@ Issue:
76
77
  ## Todo
77
78
  **Contributions are welcome!**
78
79
  - [x] Add JQL command for find issues
80
+ - [x] Search issues by keyword
79
81
  - [ ] Manage worklog and estimate of issues
80
82
  - [ ] Manage component and version of issues
81
83
  - [ ] Track history of transitions
@@ -22,6 +22,10 @@ module Terjira
22
22
  build(resp)
23
23
  end
24
24
 
25
+ def search(options = {})
26
+ resource.jql(build_jql(options))
27
+ end
28
+
25
29
  def delete(issue)
26
30
  api_delete("issue/#{issue.key_value}")
27
31
  end
@@ -1,13 +1,26 @@
1
1
  module Terjira
2
2
  module Client
3
3
  module JQLBuilder
4
- JQL_KEYS = %w(sprint assignee issuetype priority project status statusCategory).freeze
4
+ STRICT_KEYS = %w(sprint assignee issuetype priority project status statusCategory).freeze
5
+ SEARCH_KEYS = %w(summary description).freeze
5
6
 
6
7
  def build_jql(options = {})
8
+ search = options.select { |k, _v| SEARCH_KEYS.include?(k.to_s) }
9
+ strict = options.select { |k, _v| STRICT_KEYS.include?(k.to_s) }
10
+
11
+ query = [strict_matching(strict), search_matching(search)]
12
+ .reject(&:blank?).join(' AND ')
13
+
14
+ query
15
+ end
16
+
17
+ private
18
+
19
+ def strict_matching(options = {})
7
20
  q_options = options.inject({}) do |memo, (k, v)|
8
21
  memo[k.to_s] = v
9
22
  memo
10
- end.slice(*JQL_KEYS)
23
+ end.slice(*STRICT_KEYS)
11
24
 
12
25
  query = q_options.map do |key, value|
13
26
  if value.is_a? Array
@@ -24,6 +37,19 @@ module Terjira
24
37
 
25
38
  query
26
39
  end
40
+
41
+ def search_matching(options = {})
42
+ q_options = options.inject({}) do |memo, (k, v)|
43
+ memo[k.to_s] = v
44
+ memo
45
+ end.slice(*SEARCH_KEYS)
46
+
47
+ query = q_options.map do |key, value|
48
+ "#{key}~\"#{value.key_value}\""
49
+ end.reject(&:blank?).join(' AND ')
50
+
51
+ query
52
+ end
27
53
  end
28
54
  end
29
55
  end
@@ -109,6 +109,12 @@ module Terjira
109
109
  show(issue.key_value)
110
110
  end
111
111
 
112
+ desc 'search [SUMMARY]', 'Search for issues by summary'
113
+ def search(*keys)
114
+ search_term = client_class.search(summary: keys[0])
115
+ render_issues(search_term)
116
+ end
117
+
112
118
  desc 'trans [ISSUE_KEY] ([STATUS])', 'Do transition'
113
119
  jira_options :comment, :assignee, :resolution
114
120
  def trans(*args)
@@ -34,7 +34,7 @@ module Terjira
34
34
  if user.nil?
35
35
  dim_none
36
36
  else
37
- "#{user.name}, #{user.displayName}"
37
+ "#{user.displayName}(#{user.name})"
38
38
  end
39
39
  end
40
40
 
@@ -62,32 +62,31 @@ module Terjira
62
62
  def issue_detail_template
63
63
  %{<%= bold(issue.key) + ' in ' + issue.project.name %>
64
64
 
65
- <%= pastel.underline.bold(issue.summary) %>
65
+ <%= bold(issue.summary) %>
66
66
 
67
- <%= bold('Type') %>: <%= colorize_issue_type(issue.issuetype) %>\s\s\s<%= bold('Status') %>: <%= colorize_issue_stastus(issue.status) %>\s\s\s<%= bold('Priority') %>: <%= colorize_priority(issue.priority, title: true) %>
67
+ Type: <%= colorize_issue_type(issue.issuetype) %>\s\sStatus: <%= colorize_issue_stastus(issue.status) %>\s\sPriority: <%= colorize_priority(issue.priority, title: true) %>
68
68
  <% if issue.parent.nil? -%>
69
69
 
70
- <%= bold('Epic Link') %>: <%= issue.try(:epic).try(:key) %> <%= issue.try(:epic).try(:name) || dim_none %>
70
+ Epic: <%= issue.try(:epic).try(:key) %> <%= issue.try(:epic).try(:name) || dim_none %>
71
71
  <% end -%>
72
72
  <% if issue.try(:parent) && issue.epic.nil? -%>
73
- <%= bold('Parent') %>: <%= issue.parent.key %>
73
+ Parent: <%= issue.parent.key %>
74
74
  <% end %>
75
75
  <% if issue.try(:sprint) -%>
76
- <%= bold('Sprint') %>: <%= colorize_sprint_state(issue.try(:sprint).try(:state)) %> <%= issue.try(:sprint).try(:id) %>. <%= issue.try(:sprint).try(:name) %>
76
+ Sprint: <%= colorize_sprint_state(issue.try(:sprint).try(:state)) %> <%= issue.try(:sprint).try(:id) %>. <%= issue.try(:sprint).try(:name) %>
77
77
  <% end -%>
78
78
  <% if estimate = issue_estimate(issue) -%>
79
79
 
80
80
  <%= estimate[0] %>: <%= estimate[1] %>
81
81
  <% end -%>
82
82
 
83
- <%= bold('Assignee') %>: <%= username(issue.assignee) %>
84
- <%= bold('Reporter') %>: <%= username(issue.reporter) %>
83
+ Assignee: <%= username(issue.assignee) %>
84
+ Reporter: <%= username(issue.reporter) %>
85
85
 
86
- <%= bold('Description') %>
87
- <%= issue.description || dim_none %>
86
+ <%= issue.description || dim("No description") %>
88
87
  <% if issue.try(:environment) -%>
89
88
 
90
- <%= bold('Environment') %>
89
+ <%= Environment %>:
91
90
  <%= issue.environment %>
92
91
  <% end -%>
93
92
  <% if issue.try(:attachment).present? -%>
@@ -116,7 +115,7 @@ module Terjira
116
115
  """
117
116
  <% remain_comments = issue.comments -%>
118
117
  <% visiable_comments = remain_comments.pop(COMMENTS_SIZE) -%>
119
- <%= bold('Comments') %>
118
+ Comments:
120
119
  <% if visiable_comments.empty? -%>
121
120
  <%= dim_none %>
122
121
  <% elsif remain_comments.size != 0 -%>
@@ -185,15 +184,15 @@ module Terjira
185
184
  def issue_estimate(issue)
186
185
  field = Client::Field.story_points
187
186
  story_points = issue.try(field.key) if field.respond_to? :key
188
- return [bold('Story Points'), story_points] if story_points
187
+ return ['Story Points', story_points] if story_points
189
188
 
190
189
  return unless issue.try(:timetracking).is_a? Hash
191
190
 
192
191
  if origin = issue.timetracking['originalEstimate']
193
192
  remain = issue.timetracking['remainingEstimate']
194
- [bold('Estimate'), "#{remain} / #{origin}"]
193
+ ['Estimate', "#{remain} / #{origin}"]
195
194
  else
196
- [bold('Estimate'), dim_none]
195
+ ['Estimate', dim_none]
197
196
  end
198
197
  end
199
198
 
@@ -1,7 +1,7 @@
1
1
  require 'terjira/utils/file_cache'
2
2
 
3
3
  module Terjira
4
- VERSION = '0.2.6'.freeze
4
+ VERSION = '0.2.7'.freeze
5
5
 
6
6
  class VersionChecker
7
7
  VERSION_CHECK_DURATION = (60 * 60 * 24 * 5).freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terjira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaehyun Shin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-26 00:00:00.000000000 Z
11
+ date: 2017-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor