jira_report 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -8
- data/lib/jira_report/cli.rb +5 -5
- data/lib/jira_report/reporter.rb +32 -6
- data/lib/jira_report/version.rb +1 -1
- data/spec/jira_report/reporter_spec.rb +55 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a2cc760a498627ad4172cb75097419cd553ebbb
|
4
|
+
data.tar.gz: e73c6a9e1bc11770fb9a26159fe3b02960d2d090
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbaf3b2ab946def5d299930734ffee1c2f9f320c55f7adcc53d60798590127cf6e9ebc2ce22b64eef03e90778ddb39592c4a7a0da782c6eb52e3c8aedb2aabe5
|
7
|
+
data.tar.gz: 6bc5650ad49443dfd03613f199db006b309654270377b066f359f03f7dd88094f6690c3f26cfa71e16ff31e3531d4ef1c2f62439462ef94d3737d163826ca37d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
#x.x.x
|
2
|
+
* Now user can pass url with `http` or `https` prefixes.
|
3
|
+
* Now port and path are correctly resolved in url.
|
4
|
+
* `jira-report` cli becomes more user friendly.
|
5
|
+
|
1
6
|
#0.1.3
|
2
7
|
* Fixed error when configuration file not exist.
|
3
8
|
* Now version is properly printed.
|
data/README.md
CHANGED
@@ -9,16 +9,16 @@ $ gem install jira_report
|
|
9
9
|
|
10
10
|
##Usage
|
11
11
|
|
12
|
-
Just run it. `jira-report` will ask
|
12
|
+
Just run it. `jira-report` will ask your jira site address, who you are and what's your password:
|
13
13
|
|
14
14
|
```
|
15
15
|
$ jira-report
|
16
|
-
Jira
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
Jira site address: https://jira.company.com
|
17
|
+
Username for 'https://jira.company.com': admin
|
18
|
+
Password for 'https://jira.company.com':
|
19
|
+
Connecting to 'https://jira.company.com'. Pls wait...
|
20
20
|
|
21
|
-
|
21
|
+
What was [admin] doing:
|
22
22
|
|
23
23
|
Created: 2
|
24
24
|
WFM-7180 - Provide static context for log property in BasicHashAnalyzer
|
@@ -46,7 +46,7 @@ Closed: 5
|
|
46
46
|
|
47
47
|
`url`, `username`, `password` and some other parameters can be added to [configuration file](#configuration). Also you can use mixed approach (keep some options in file, others enter from command line). For example if you do not want to keep password in configuration file, just don't, you will be asked.
|
48
48
|
|
49
|
-
Also you can use it directly in ruby:
|
49
|
+
Also you can use it directly in ruby code:
|
50
50
|
|
51
51
|
```ruby
|
52
52
|
require 'jira_report'
|
@@ -82,7 +82,7 @@ username=username
|
|
82
82
|
password=s3cr3t
|
83
83
|
```
|
84
84
|
|
85
|
-
|
85
|
+
You may pass all those options (or some of them) in command line mode.
|
86
86
|
|
87
87
|
Period is set by two options `period_from` and `period_till`. Both options support [advanced jira searching](https://confluence.atlassian.com/display/JIRA/Advanced+Searching) and accept dates, jira functions, aliasing. For example:
|
88
88
|
|
data/lib/jira_report/cli.rb
CHANGED
@@ -43,7 +43,7 @@ module JiraReport
|
|
43
43
|
@config[:url], @config[:username], @config[:password]
|
44
44
|
)
|
45
45
|
|
46
|
-
puts "\
|
46
|
+
puts "\nConnecting to '#{@config[:url]}'. Pls wait..."
|
47
47
|
|
48
48
|
created = reporter.created(
|
49
49
|
@config[:usr], @config[:period_from], @config[:period_till]
|
@@ -58,7 +58,7 @@ module JiraReport
|
|
58
58
|
@config[:usr], @config[:period_from], @config[:period_till]
|
59
59
|
)
|
60
60
|
|
61
|
-
puts "\
|
61
|
+
puts "\nWhat was [#{@config[:usr]}] doing:"
|
62
62
|
|
63
63
|
puts "\nCreated: #{created.length}"
|
64
64
|
print_issues(created)
|
@@ -102,9 +102,9 @@ module JiraReport
|
|
102
102
|
# Reads required options from user input if those
|
103
103
|
# were missed.
|
104
104
|
def ask_missing_options
|
105
|
-
@config[:url] = ask('Jira
|
106
|
-
@config[:username] = ask('
|
107
|
-
@config[:password] = ask('
|
105
|
+
@config[:url] = ask('Jira site address: ') unless @config[:url]
|
106
|
+
@config[:username] = ask("Username for '#{@config[:url]}': ") unless @config[:username]
|
107
|
+
@config[:password] = ask("Password for '#{@config[:url]}': "){
|
108
108
|
STDIN.noecho(&:gets).chomp!
|
109
109
|
} unless @config[:password]
|
110
110
|
if !@config[:period_from] && !@config[:period_till]
|
data/lib/jira_report/reporter.rb
CHANGED
@@ -20,15 +20,21 @@ module JiraReport
|
|
20
20
|
# # from two weeks ago and ending one week ago.
|
21
21
|
# reopened = reporter.reopened('usr', '-2w', '-1w')
|
22
22
|
class Reporter
|
23
|
+
REST_API_SEARCH_URL = 'rest/api/2/search?'
|
24
|
+
|
23
25
|
# Initializes reporter.
|
24
26
|
#
|
25
27
|
# ==== Attributes
|
26
28
|
#
|
27
|
-
# * +
|
29
|
+
# * +site+ - jira site address.
|
28
30
|
# * +usr+ - jira username.
|
29
31
|
# * +pass+ - jira password.
|
30
|
-
def initialize(
|
31
|
-
|
32
|
+
def initialize(site, usr, pass)
|
33
|
+
fail 'url can\'t be nil' unless site
|
34
|
+
fail 'usr can\'t be nil' unless usr
|
35
|
+
fail 'pass can\'t be nil' unless pass
|
36
|
+
|
37
|
+
@search_url = jira_api_url(site, usr, pass);
|
32
38
|
end
|
33
39
|
|
34
40
|
# Queries created issues by usr in specified period.
|
@@ -90,9 +96,29 @@ module JiraReport
|
|
90
96
|
|
91
97
|
private
|
92
98
|
|
93
|
-
# Returns jira rest api search url
|
94
|
-
def jira_api_url(
|
95
|
-
|
99
|
+
# Returns jira full rest api search url
|
100
|
+
def jira_api_url(site, username, password)
|
101
|
+
url = format_url(site, username, password)
|
102
|
+
"#{url}/#{REST_API_SEARCH_URL}"
|
103
|
+
end
|
104
|
+
|
105
|
+
# Formats url in the following format:
|
106
|
+
# scheme://username:password@site
|
107
|
+
#
|
108
|
+
# If `site` parameter does not define scheme `http` will be used.
|
109
|
+
def format_url(site, username, password)
|
110
|
+
s = site.dup
|
111
|
+
if !s.start_with? 'http'
|
112
|
+
s = "http://#{s}"
|
113
|
+
end
|
114
|
+
|
115
|
+
u = URI.parse(s)
|
116
|
+
|
117
|
+
<<-EOU.gsub(/\s+/, '').strip
|
118
|
+
#{u.scheme + '://' if u.scheme}
|
119
|
+
#{username}:#{password}@
|
120
|
+
#{u.host}:#{u.port}#{u.path}
|
121
|
+
EOU
|
96
122
|
end
|
97
123
|
|
98
124
|
# Prepares jql query based on parameters to
|
data/lib/jira_report/version.rb
CHANGED
@@ -2,7 +2,19 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module JiraReport
|
4
4
|
describe JiraReport do
|
5
|
-
let(:jrep) { Reporter.new('
|
5
|
+
let(:jrep) { Reporter.new('site', 'admin', '*****') }
|
6
|
+
|
7
|
+
describe '#new' do
|
8
|
+
it 'raises error if site is nil' do
|
9
|
+
expect{ Reporter.new(nil, '1', '2') }.to raise_error RuntimeError
|
10
|
+
end
|
11
|
+
it 'raises error if usr is nil' do
|
12
|
+
expect{ Reporter.new('mysite', nil, '2') }.to raise_error RuntimeError
|
13
|
+
end
|
14
|
+
it 'raises error if pas is nil' do
|
15
|
+
expect{ Reporter.new('mysite', 'usr', nil) }.to raise_error RuntimeError
|
16
|
+
end
|
17
|
+
end
|
6
18
|
|
7
19
|
describe '#query_issues' do
|
8
20
|
it 'should throw exception' do
|
@@ -16,29 +28,54 @@ module JiraReport
|
|
16
28
|
end
|
17
29
|
|
18
30
|
describe '#jira_api_url' do
|
19
|
-
def jira_api_url(
|
20
|
-
jrep.send(:jira_api_url,
|
31
|
+
def jira_api_url(site=nil, user=nil, pass=nil)
|
32
|
+
jrep.send(:jira_api_url, site, user, pass)
|
21
33
|
end
|
22
34
|
|
23
|
-
it '
|
24
|
-
url
|
25
|
-
|
26
|
-
expect(url).to start_with 'http'
|
35
|
+
it 'ends with jira rest api search url' do
|
36
|
+
expect(jira_api_url 'url', 'usr', 'pas').
|
37
|
+
to end_with Reporter::REST_API_SEARCH_URL
|
27
38
|
end
|
28
39
|
|
29
|
-
|
30
|
-
|
40
|
+
describe 'scheme' do
|
41
|
+
['http', 'https'].each do |s|
|
42
|
+
it 'correctly detects scheme' do
|
43
|
+
site = "jira.mycom.com"
|
44
|
+
url = jira_api_url("#{s}://#{site}")
|
45
|
+
expect(url).to start_with "#{s}://"
|
46
|
+
expect(url).to include site
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'is ok when no scheme passed' do
|
51
|
+
site = 'jira.mycom.com'
|
52
|
+
expect(jira_api_url(site)).to include site
|
53
|
+
end
|
31
54
|
end
|
32
55
|
|
33
|
-
context 'when we
|
34
|
-
let(:usr)
|
35
|
-
let(:
|
36
|
-
let(:
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
56
|
+
context 'when we define all parameters' do
|
57
|
+
let(:usr) { 'admin_username' }
|
58
|
+
let(:pas) { 'password' }
|
59
|
+
let(:host) { 'localhost' }
|
60
|
+
let(:port) { 8000 }
|
61
|
+
let(:path) { 'myjira' }
|
62
|
+
|
63
|
+
def expected_url(prefix)
|
64
|
+
"#{prefix}#{usr}:#{pas}@#{host}:#{port}/#{path}/#{Reporter::REST_API_SEARCH_URL}"
|
65
|
+
end
|
66
|
+
|
67
|
+
['http://', 'https://'].each do |prefix|
|
68
|
+
it "correctly prepares #{prefix} url" do
|
69
|
+
site = "#{prefix}#{host}:#{port}/#{path}"
|
70
|
+
url = jira_api_url(site, usr, pas)
|
71
|
+
expect(url).to eq ( expected_url prefix )
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'correctly prepares url without scheme' do
|
76
|
+
site = "#{host}:#{port}/#{path}"
|
77
|
+
url = jira_api_url(site, usr, pas)
|
78
|
+
expect(url).to eq ( expected_url 'http://' )
|
42
79
|
end
|
43
80
|
end
|
44
81
|
end
|
@@ -177,5 +214,4 @@ module JiraReport
|
|
177
214
|
end
|
178
215
|
end
|
179
216
|
end
|
180
|
-
|
181
217
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira_report
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitalii Elenhaupt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parseconfig
|