jira_report 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: da9f8a10bf34661f77ed0fda245da2fff4f45b09
4
+ data.tar.gz: 37c232eede2357b98fb47baea9cdce4b66ce6bab
5
+ SHA512:
6
+ metadata.gz: c1045da422a6ab29b42f09f924745c117dd533e53ed9666391c25b753ab3b19b3a168ff8993519c049748582985b8b22a956b85f7f05ca41bb73fa8d654dcfc4
7
+ data.tar.gz: 0391e1b3a2fc1aa71d923b36180e9ef706b58fbdae9eebbebd9f91dcbcbf44308f40d89adfd5477b0759fcc16d61d86f399f7ebd9cff6ff80599d8deda9b7486
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jira_report.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Vitalii Elenhaupt
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ jira_report
2
+ ===========================
3
+
4
+ Queries user activities for specified period of time and prints it to console.
5
+
6
+ ##Installation
7
+ ```
8
+ $gem install jira_report
9
+ ```
10
+
11
+ ##Usage
12
+ ```sh
13
+ $jira-report -h
14
+ Usage: jira-report [options]
15
+ -u, --username username Username to query activity report.
16
+ -c, --config config Path to config file. USER_HOME/.jira-report is default.
17
+ ```
18
+
19
+ ```
20
+ $jira-report -u admin
21
+ Querying jira...
22
+ Jira activity report for [admin]:
23
+
24
+ Created: 2
25
+ WFM-7180 - Provide static context for log property in BasicHashAnalyzer
26
+ TST-5862 - Unable to install Nginx on HP-UX with Java 6
27
+
28
+ Resolved: 8
29
+ GSM-364 - Migration of existing scenario
30
+ WFM-5865 - NullPointerException while finding categories
31
+ TST-5864 - Some NGinx installation improvements
32
+ TST-5863 - NGinx minimal dependency
33
+ SDK-7139 - Move common interfaces and classes from into individual jar
34
+ SDK-7138 - Move common interfaces and classes from into individual dll
35
+ TST-7111 - Event.getDonotNotify doesn't indicate about agent's state
36
+ TST-6985 - TST classes should have static Log fields
37
+
38
+ Reopened: 0
39
+
40
+ Closed: 5
41
+ TST-6943 - Remove redundant org.apache.log4j dependcy from common part
42
+ TST-5862 - Unable to install NGinx on HP-UX with Java 6
43
+ TST-5857 - Put back support for Jdk 1.6
44
+ TST-5840 - NGinx fails to handle interaction initiated
45
+ GSM-364 - Migration of existing units
46
+ ```
47
+
48
+ ##Configuration
49
+ Default path to configuration file is `~/.jira-report`. All settings are optional and may be read from user input. See [sample](examples/jira-report.sample).
50
+
51
+ 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:
52
+
53
+ ```
54
+ period_from=-3w
55
+ period_till=now()
56
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/jira-report ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'jira_report'
4
+
5
+ parameters = JiraReport::Cli.new
6
+ settings = JiraReport::Settings.new(parameters.ini)
7
+ JiraReport::JiraReport.new(settings, parameters.username).report
@@ -0,0 +1,6 @@
1
+ url=jira.company.com
2
+ username=jira_username
3
+ password=s3cr3t
4
+
5
+ period_from=-1w
6
+ period_till=now()
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jira_report/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jira_report'
8
+ spec.version = JiraReport::VERSION
9
+ spec.authors = ['Vitalii Elenhaupt']
10
+ spec.email = ['velenhaupt@gmail.com']
11
+ spec.summary = %q{Jira activity report generator.}
12
+ spec.description = %q{Generates a productivity report base on activities in jira.}
13
+ spec.homepage = 'https://github.com/veelenga/jira_report.git'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `"C:/Program Files (x86)/Git/bin/git.exe" ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'inifile', '~> 3.0'
22
+ spec.add_runtime_dependency 'rest-client', '~> 1.7'
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ end
@@ -0,0 +1,31 @@
1
+ require 'optparse'
2
+
3
+ module JiraReport
4
+ # Prepares command line parameters using OptionParser
5
+ class Cli
6
+ attr_reader :username, :ini
7
+
8
+ def initialize
9
+ options = parse
10
+ @username = options[:username]
11
+ @ini = options[:ini] ? options[:ini] : "~/.jira-report"
12
+ end
13
+
14
+ private
15
+
16
+ def parse
17
+ options = {}
18
+ OptionParser.new do |opts|
19
+ opts.banner = 'Usage: jira-report [options]'
20
+ opts.on('-u', '--username username', 'Username to query activity report.') do |u|
21
+ options[:username] = u
22
+ end
23
+ opts.on('-c', '--config config', 'Path to config file. ' \
24
+ 'USER_HOME/.jira-report is default.') do |s|
25
+ options[:ini] = s
26
+ end
27
+ end.parse!
28
+ options
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,48 @@
1
+ require 'inifile'
2
+ require 'io/console'
3
+
4
+ # Initializes JiraReport settings.
5
+ module JiraReport
6
+ class Settings
7
+ attr_reader :username, :password, :url,\
8
+ :period_from, :period_till
9
+
10
+ def initialize(path)
11
+ read(path)
12
+ end
13
+
14
+ private
15
+
16
+ def read(path)
17
+ loaded = IniFile.load(File.expand_path(path))
18
+
19
+ global = loaded[:global] if loaded
20
+ global ||= {}
21
+
22
+ @url = global['url']
23
+ @username = global['username']
24
+ @password = global['password']
25
+ @period_from = global['period_from']
26
+ @period_till = global['period_till']
27
+
28
+ @url = ask('Jira url in [jira.company.com] format: ') unless @url
29
+ @username = ask('Jira username: ') unless @username
30
+ @password = ask('Jira password: '){
31
+ STDIN.noecho(&:gets).chomp!
32
+ } unless @password
33
+ @period_from = '-1w' unless @period_from
34
+ @period_till = 'now()' unless @period_till
35
+
36
+ # TODO: attributes verification
37
+ end
38
+
39
+ def ask(message, &block)
40
+ print message
41
+ if block
42
+ yield block
43
+ else
44
+ gets.chomp!
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module JiraReport
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,89 @@
1
+ require 'rest_client'
2
+ require 'json'
3
+ require 'uri'
4
+
5
+ require 'jira_report/settings'
6
+ require 'jira_report/cli'
7
+
8
+ module JiraReport
9
+ # Base class that generate jira activity report
10
+ class JiraReport
11
+ attr_accessor :from, :till, :username
12
+
13
+ def initialize(init_set, username)
14
+ @username = username ? username : init_set.username
15
+ @search_url = jira_search_url(init_set.url,
16
+ init_set.username,
17
+ init_set.password)
18
+
19
+ @from = init_set.period_from.gsub(/'/, '')
20
+ @till = init_set.period_till.gsub(/'/, '')
21
+ end
22
+
23
+ def report
24
+ puts "\nQuerying jira..."
25
+
26
+ created = query(jql_created)
27
+ resolved = query(jql_resolved)
28
+ reopened = query(jql_reopened)
29
+ closed = query(jql_closed)
30
+
31
+ puts "\nJira activity report for [#{@username}]:"
32
+
33
+ puts "\nCreated: #{created.length}"
34
+ print_issues(created)
35
+
36
+ puts "\nResolved: #{resolved.length}"
37
+ print_issues(resolved)
38
+
39
+ puts "\nReopened: #{reopened.length}"
40
+ print_issues(reopened)
41
+
42
+ puts "\nClosed: #{closed.length}"
43
+ print_issues(closed)
44
+ end
45
+
46
+ private
47
+
48
+ def jira_search_url(url, username, password)
49
+ "http://#{username}:#{password}@#{url}/rest/api/2/search?"
50
+ end
51
+
52
+ def jql_created
53
+ "jql=created>=#{@from} " \
54
+ "AND created<=#{@till} "\
55
+ "AND reporter=#{@username}"
56
+ end
57
+
58
+ def jql_resolved
59
+ "jql=resolved>=#{@from} " \
60
+ "AND resolved<=#{@till} "\
61
+ "AND 'First Resolution User'=#{@username}"
62
+ end
63
+
64
+ def jql_closed
65
+ "jql='First Closed Date'>=#{@from} " \
66
+ "AND 'First Closed Date'<=#{@till} "\
67
+ "AND 'First Closed User'=#{@username}"
68
+ end
69
+
70
+ def jql_reopened
71
+ "jql='First Reopened Date'>=#{@from} " \
72
+ "AND 'First Reopened Date'<=#{@till} "\
73
+ "AND 'First Reopened User'=#{@username}"
74
+ end
75
+
76
+ def query(jql)
77
+ response = RestClient.get(@search_url + URI.escape(jql))
78
+ fail "Query unsuccessful. Response code #{response.code}"\
79
+ unless response.code == 200
80
+ JSON.parse(response.body)['issues']
81
+ end
82
+
83
+ def print_issues(issues)
84
+ issues.each do |issue|
85
+ puts " #{issue['key']} - #{issue['fields']['summary']}"
86
+ end
87
+ end
88
+ end
89
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jira_report
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vitalii Elenhaupt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: inifile
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description: Generates a productivity report base on activities in jira.
70
+ email:
71
+ - velenhaupt@gmail.com
72
+ executables:
73
+ - jira-report
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/jira-report
83
+ - examples/jira-report.sample
84
+ - jira_report.gemspec
85
+ - lib/jira_report.rb
86
+ - lib/jira_report/cli.rb
87
+ - lib/jira_report/settings.rb
88
+ - lib/jira_report/version.rb
89
+ homepage: https://github.com/veelenga/jira_report.git
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.14
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Jira activity report generator.
113
+ test_files: []