Skip to content

Commit 6a17c93

Browse files
committed
style: add lint
1 parent 124c254 commit 6a17c93

24 files changed

+142
-160
lines changed

.rubocop.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
AllCops:
22
Exclude:
3+
- 'bin/*'
34
- '*.gemspec'
5+
- 'lib/terjira/ext/**/*'
6+
- 'Rakefile'
47

58
Style/Documentation:
69
Enabled: false
@@ -9,6 +12,8 @@ Style/EachWithObject:
912

1013
Lint/AssignmentInCondition:
1114
Enabled: false
15+
Lint/Eval:
16+
Enabled: false
1217

1318
Metrics/BlockLength:
1419
Enabled: false

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,39 @@
55

66
# Terjira
77

8-
Terjira is a very interactive and easy to use command line interface for Jira.
8+
Terjira is interactive and easy to use command line interface (or Application) for Jira. You do not need to remember reosurce key or id. Terjira suggests with interactive prompt.
99

1010

11-
I'm working now..
11+
**I'm working now..**
1212

1313
## Installation
1414

15-
Add this line to your application's Gemfile:
15+
Install it yourself as:
1616

17-
```ruby
18-
gem 'terjira'
19-
```
17+
$ gem install terjira
2018

21-
And then execute:
19+
If you have permission problem,
2220

23-
$ bundle
21+
$ sudo gem install terjira
2422

25-
Or install it yourself as:
23+
# or
2624

27-
$ gem install terjira
25+
$ gem install terjira --user-install
26+
# You need to export your gem path
2827

2928
## Usage
3029

31-
TODO: Write usage instructions here
3230

33-
* Mock data is from jira-ruby
3431

3532
## Development
3633

37-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
3835

39-
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).
36+
To install this gem onto your local machine, run `bundle exec rake install`.
4037

4138
## Contributing
4239

43-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/terjira. 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.
40+
Bug reports and pull requests are welcome on GitHub at https://github.com/keepcosmos/terjira. 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.
4441

4542

4643
## License

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env ruby
22
# Do I need bundler setup?
3-
# require "bundler/setup"
3+
require "bundler/setup"
44
require "terjira"
55

66
# You can add fixtures and/or initialization code here to make experimenting

lib/terjira/base_cli.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
require 'thor'
22

33
require_relative 'option_supportable'
4-
Dir[File.dirname(__FILE__) + "/presenters/*.rb"].each { |f| require f }
4+
Dir[File.dirname(__FILE__) + '/presenters/*.rb'].each { |f| require f }
55

66
module Terjira
7+
# Jira client based on jira-ruby gem
78
module Client
8-
%w[Base Field Project Board Sprint Issue User Status Resolution Priority RapidView Agile].each do |klass|
9+
%w(Base Field Project Board Sprint Issue User
10+
Status Resolution Priority RapidView Agile).each do |klass|
911
autoload klass, "terjira/client/#{klass.gsub(/(.)([A-Z](?=[a-z]))/,'\1_\2').downcase}"
1012
end
1113
end
@@ -19,7 +21,7 @@ class BaseCLI < Thor
1921
include BoardPresenter
2022
include SprintPresenter
2123

22-
def self.banner(command, namespace = nil, subcommand = false)
24+
def self.banner(command, _namespace = nil, _subcommand = false)
2325
"#{basename} #{subcommand_prefix} #{command.usage}"
2426
end
2527

lib/terjira/client/agile.rb

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ class << self
77
delegate :all, :get_sprints, :backlog_issues, to: :resource
88

99
def project_by_board(board_id)
10-
resp = agile_api_get("board/#{board_id}/project")
10+
agile_api_get("board/#{board_id}/project")
1111
end
1212

1313
def boards
14-
all["values"]
14+
all['values']
1515
end
1616

17-
def sprints(board_id, options = {})
18-
sprints = get_sprints(board_id)["values"]
17+
def sprints(board_id)
18+
sprints = get_sprints(board_id)['values']
1919
sprints.sort_by do |sprint|
20-
if sprint["state"] == 'active'
21-
[0, sprint["id"]]
22-
elsif sprint["state"] == 'future'
23-
[1, sprint["id"]]
24-
elsif sprint["state"] == 'closed'
25-
[2, sprint["id"] * -1]
20+
if sprint['state'] == 'active'
21+
[0, sprint['id']]
22+
elsif sprint['state'] == 'future'
23+
[1, sprint['id']]
24+
elsif sprint['state'] == 'closed'
25+
[2, sprint['id'] * -1]
2626
else
2727
[3, 0]
2828
end
@@ -32,9 +32,6 @@ def sprints(board_id, options = {})
3232
def backlog_issues(board_id)
3333
get_backlog_issues(board_id)
3434
end
35-
36-
def sprint_issues(board_id)
37-
end
3835
end
3936
end
4037
end

lib/terjira/client/base.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@ class Base
99
extend AuthOptionBuilder
1010

1111
DEFAULT_CACHE_SEC = 60
12-
DEFAULT_API_PATH = "/rest/api/2/"
13-
AGILE_API_PATH = "/rest/agile/1.0/"
12+
DEFAULT_API_PATH = '/rest/api/2/'.freeze
13+
AGILE_API_PATH = '/rest/agile/1.0/'.freeze
1414

1515
class << self
16-
1716
delegate :build, to: :resource
1817

1918
def client
20-
@@client ||= JIRA::Client.new(build_auth_options)
19+
@client ||= JIRA::Client.new(build_auth_options)
2120
end
2221

2322
def resource
@@ -29,7 +28,7 @@ def username
2928
end
3029

3130
def class_name
32-
self.to_s.split("::").last
31+
to_s.split('::').last
3332
end
3433

3534
def cache(options = {})
@@ -38,16 +37,14 @@ def cache(options = {})
3837
end
3938

4039
# define `#api_get(post, put, delete)` and `#agile_api_get(post, put, delete)`
41-
{ DEFAULT_API_PATH => "api_",
42-
AGILE_API_PATH => "agile_api_"
43-
}.each do |url_prefix, method_prefix|
44-
40+
{ DEFAULT_API_PATH => 'api_',
41+
AGILE_API_PATH => 'agile_api_' }.each do |url_prefix, method_prefix|
4542
[:get, :delete].each do |http_method|
4643
method_name = "#{method_prefix}#{http_method}"
4744
define_method(method_name) do |path, params = {}, headers = {}|
4845
url = url_prefix + path
4946
if params.present?
50-
params.reject! { |k, v| v.blank? }
47+
params.reject! { |_k, v| v.blank? }
5148
url += "?#{URI.encode_www_form(params)}"
5249
end
5350
parse_body client.send(http_method, url, headers)

lib/terjira/client/board.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ class << self
66

77
def all(options = {})
88
params = options.slice(:type)
9-
resp = agile_api_get("board", params)
10-
resp["values"].map { |value| build(value) }
9+
resp = agile_api_get('board', params)
10+
resp['values'].map { |value| build(value) }
1111
end
1212

1313
def find(board_id)
1414
resp = agile_api_get("board/#{board_id}")
15-
self.build(resp)
15+
build(resp)
1616
end
1717
end
1818
end

lib/terjira/client/field.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def all
99
end
1010

1111
def epic_name
12-
all.find { |field| field.name == "Epic Name" }
12+
all.find { |field| field.name == 'Epic Name' }
1313
end
1414
end
1515
end

lib/terjira/client/issue.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ module Client
55
class Issue < Base
66
class << self
77
delegate :build, :find, to: :resource
8-
ISSUE_JQL_KEYS = [:sprint, :assignee, :reporter, :project, :issuetype, :priority, :status, :statusCategory]
98

109
def all(options = {})
11-
opts = options.slice(*ISSUE_JQL_KEYS)
1210
return resource.all if options.blank?
1311
max_results = options.delete(:max_results) || 500
14-
resource.jql(build_jql_query(opts), max_results: max_results)
12+
resource.jql(build_jql_query(options), max_results: max_results)
1513
end
1614

1715
def find(issue, options = {})
@@ -20,7 +18,7 @@ def find(issue, options = {})
2018
end
2119

2220
def current_my_issues
23-
jql("assignee = #{self.key_value} AND statusCategory != 'Done'")
21+
jql("assignee = #{key_value} AND statusCategory != 'Done'")
2422
end
2523

2624
def assign(issue, assignee)
@@ -29,7 +27,7 @@ def assign(issue, assignee)
2927
end
3028

3129
def write_comment(issue, message)
32-
resp = api_post("issue/#{issue.key_value}/comment", { body: message }.to_json)
30+
api_post("issue/#{issue.key_value}/comment", { body: message }.to_json)
3331
find(issue)
3432
end
3533

@@ -39,9 +37,8 @@ def create(options = {})
3937
params.merge!(transition_param)
4038
end
4139

42-
resp = api_post "issue", params.to_json
43-
result_id = resp["id"]
44-
find(result_id)
40+
resp = api_post 'issue', params.to_json
41+
find(resp['id'])
4542
end
4643

4744
def update(issue, options = {})
@@ -80,7 +77,7 @@ def extract_to_fields_params(options = {})
8077
params = {}
8178

8279
custom_fields = options.keys.select { |k| k.to_s =~ /^customfield/ }
83-
(custom_fields + [:summary, :description]).each do |k, v|
80+
(custom_fields + [:summary, :description]).each do |k, _v|
8481
params[k] = opts.delete(k) if opts.key?(k)
8582
end
8683

lib/terjira/client/jql_query_builer.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ module JQLQueryBuilder
44
JQL_KEYS = %w(board sprint assignee issuetype priority project status statusCategory).freeze
55

66
def build_jql_query(options = {})
7-
q_options = options.inject({}) do |memo,(k,v)|
7+
q_options = options.inject({}) do |memo, (k, v)|
88
memo[k.to_s] = v
99
memo
1010
end.slice(*JQL_KEYS)
1111

1212
query = q_options.map do |key, value|
1313
if value.is_a? Array
14-
values = value.map { |v| "\"#{v.key_value}\""}.join(",")
14+
values = value.map { |v| "\"#{v.key_value}\"" }.join(',')
1515
"#{key} IN (#{values})"
1616
else
1717
"#{key}=#{value.key_value}"
1818
end
19-
end.reject(&:blank?).join(" AND ")
19+
end.reject(&:blank?).join(' AND ')
2020

2121
query
2222
end

lib/terjira/client/priority.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Client
55
class Priority < Base
66
class << self
77
def all
8-
resp = api_get "priority"
8+
resp = api_get 'priority'
99
resp.map { |priority| build(priority) }
1010
end
1111
end

lib/terjira/client/resolution.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Client
55
class Resolution < Base
66
class << self
77
def all
8-
resp = api_get("resolution")
8+
resp = api_get('resolution')
99
resp.map { |resolution| build(resolution) }
1010
end
1111
end

lib/terjira/client/status.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Status < Base
66
class << self
77
def all(project)
88
resp = api_get "project/#{project.key_value}/statuses"
9-
statuses_json = resp.map { |issuetype| issuetype["statuses"] }.flatten.uniq
9+
statuses_json = resp.map { |issuetype| issuetype['statuses'] }.flatten.uniq
1010
statuses_json.map { |status| build(status) }
1111
end
1212
end

lib/terjira/client/user.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class User < Base
66
class << self
77
def assignables_by_project(project)
88
if project.is_a? Array
9-
keys = project.map(&:key_value).join(",")
10-
fetch_assignables "user/assignable/multiProjectSearch", {projectKeys: keys }
9+
keys = project.map(&:key_value).join(',')
10+
fetch_assignables 'user/assignable/multiProjectSearch', projectKeys: keys
1111
else
12-
fetch_assignables "user/assignable/search", { project: project.key_value }
12+
fetch_assignables 'user/assignable/search', project: project.key_value
1313
end
1414
end
1515

@@ -28,15 +28,14 @@ def assignables_by_sprint(sprint)
2828
end
2929

3030
def assignables_by_issue(issue)
31-
fetch_assignables "user/assignable/search", {issueKey: issue.key_value }
31+
fetch_assignables 'user/assignable/search', issueKey: issue.key_value
3232
end
3333

3434
private
3535

3636
def fetch_assignables(path, params)
3737
resp = api_get(path, params)
38-
resp.map { |user| build(user) }.
39-
reject { |user| user.key_value =~ /^addon/ }
38+
resp.map { |user| build(user) }.reject { |user| user.key_value =~ /^addon/ }
4039
end
4140
end
4241
end

lib/terjira/ext/tty_prompt.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
module TTY
44
class Prompt
55
class Question
6-
# Decide how to handle input from user
7-
#
8-
# @api private
96
def process_input
107
@input = read_input
118
if Utils.blank?(@input)

lib/terjira/option_support/option_selector.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ def select_issue_status
7979
fetch(:status) do
8080
statuses = fetch(:statuses) do
8181
project = if issue = get(:issue)
82-
if issue.respond_to?(:project)
83-
issue.project
84-
else
85-
set(:issue, Client::Issue.find(issue)).project
86-
end
87-
else
88-
select_project
89-
end
82+
if issue.respond_to?(:project)
83+
issue.project
84+
else
85+
set(:issue, Client::Issue.find(issue)).project
86+
end
87+
else
88+
select_project
89+
end
9090
Client::Status.all(project)
9191
end
9292

0 commit comments

Comments
 (0)