jira_tracker 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a53e61037a87639447f28b21bf4b0caabf0ba0f
4
+ data.tar.gz: e31ce21a42f3c9f24785f1233eeedb238c2d7e7e
5
+ SHA512:
6
+ metadata.gz: 878109ceb12a1a1c7830eb10c9d6095c3f270e02dcf82e79f3e0cc1c2d745a470f9db288043c0499dd44ee5237f29209acf88967838c93a4a30ff3147c3d5b98
7
+ data.tar.gz: 33a1309b2e0f05ae10949e429b29680df960954a61e270b5f1bbb7cadb4b8417b7e621babb2292362fc42c6210b4972e2f2472232ac8fcebcb26dec67b3ed330
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jira_tracker.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ziga Vidic
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,36 @@
1
+ # JiraTracker
2
+
3
+ Simple tool to track the time you spent on Jira issues.
4
+
5
+ ## Installation and setup
6
+
7
+ ```
8
+ gem install jira_tracker
9
+ rbenv rehash
10
+ jira_tracker initialize
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```
16
+ jira_tracker <ticket/project> <time-spent>
17
+ ```
18
+
19
+ When you work on specific ticket
20
+
21
+ ```
22
+ jira_tracker xoya-10 1h
23
+ ```
24
+
25
+ When you don't have any ticket but you work on a project
26
+
27
+ ```
28
+ jira_tracker xoya 1h
29
+ ```
30
+
31
+
32
+ If you put `-` in a first argument, program will try to find a specific ticket,
33
+ otherwise will look for a project with ticket that has summary `Time Tracking Ticket`.
34
+
35
+ *You can specify a time unit after a time value 'X', such as Xw, Xd, Xh or Xm,
36
+ to represent weeks (w), days (d), hours (h) and minutes (m), respectively.*
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/jira_tracker ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'jira_tracker'
4
+ require 'yaml'
5
+
6
+ if ARGV[0] == 'initialize'
7
+ settings_file = "#{Dir.home}/.jira_tracker.yml"
8
+
9
+ if File.exists?(settings_file)
10
+ p "#{settings_file} already exists. If you want to change settings delete it or edit it."
11
+ exit
12
+ end
13
+
14
+ settings = {
15
+ 'site' => 'https://your-jira-domain.com',
16
+ 'username' => 'your-jira-username',
17
+ 'password' => 'your-jira-password',
18
+ 'time_track_issue_summary' => 'Time Tracking Ticket'
19
+ }
20
+
21
+ p "Please enter your jira site. (Example: #{settings['site']}):"
22
+ settings['site'] = $stdin.gets.chomp
23
+ p 'Please enter your jira username:'
24
+ settings['username'] = $stdin.gets.chomp
25
+ p 'Please enter your jira password:'
26
+ settings['password'] = $stdin.gets.chomp
27
+
28
+ File.write(settings_file, settings.to_yaml)
29
+ p "Writing #{settings_file}"
30
+ exit
31
+ end
32
+
33
+ issue = ARGV[0]
34
+ time_spent = ARGV[1]
35
+
36
+ if issue.nil? or issue.length < 4
37
+ p 'You forgot to specify issue/project or it is to short.'
38
+ exit
39
+ end
40
+
41
+ if time_spent.nil? or time_spent.length < 2
42
+ p 'You forgot to specify time spent or it is to short.'
43
+ exit
44
+ end
45
+
46
+ JiraTracker.run(issue, time_spent)
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jira_tracker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jira_tracker'
8
+ spec.version = JiraTracker::VERSION
9
+ spec.authors = %w(zigomir)
10
+ spec.email = %w(zigomir@gmail.com)
11
+ spec.description = %q{Track time on Jira spent on individual issues}
12
+ spec.summary = %q{Track time on Jira spent on individual issues}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
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 = %w(lib)
20
+
21
+ spec.add_runtime_dependency 'jira-ruby'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.3'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'pry'
26
+ end
@@ -0,0 +1,3 @@
1
+ module JiraTracker
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,61 @@
1
+ require 'jira_tracker/version'
2
+ require 'yaml'
3
+ require 'pp'
4
+ require 'jira'
5
+
6
+ module JiraTracker
7
+
8
+ @config = nil
9
+
10
+ def self.run(issue, time_spent)
11
+ begin
12
+ @config = YAML.load(File.open("#{Dir.home}/.jira_tracker.yml"))
13
+ rescue
14
+ p 'Setting file jira_tracker.yml not found!'
15
+ exit
16
+ end
17
+
18
+ options = {
19
+ :username => @config['username'],
20
+ :password => @config['password'],
21
+ :site => @config['site'],
22
+ :context_path => '',
23
+ :rest_base_path => '/rest/api/2',
24
+ :auth_type => :basic
25
+ }
26
+ client = JIRA::Client.new(options)
27
+ JiraTracker.worklog(issue, time_spent, client)
28
+ end
29
+
30
+ def self.worklog(issue, time_spent, client)
31
+ jira_issue = JiraTracker.find do
32
+ if issue.include?('-')
33
+ client.Issue.find(issue)
34
+ else
35
+ project_name = JiraTracker.get_project_name_from_issue(issue)
36
+ jql = "project = #{project_name} AND summary ~ \"#{@config['time_track_issue_summary']}\""
37
+ client.Issue.jql(jql).first
38
+ end
39
+ end
40
+ worklog = jira_issue.worklogs.build
41
+ time_spent_till_now = worklog.issue.timespent / 3600
42
+
43
+ worklog.save({'timeSpent' => time_spent})
44
+ p "Thanks! #{time_spent} was added to #{jira_issue.key} - #{jira_issue.summary}"
45
+ p "Time spent on this issue before #{time_spent_till_now}h"
46
+ end
47
+
48
+ def self.find
49
+ begin
50
+ return yield
51
+ rescue JIRA::HTTPError => e
52
+ p e.response
53
+ exit
54
+ end
55
+ end
56
+
57
+ def self.get_project_name_from_issue(issue)
58
+ issue.split('-').first.upcase
59
+ end
60
+
61
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jira_tracker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - zigomir
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jira-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Track time on Jira spent on individual issues
70
+ email:
71
+ - zigomir@gmail.com
72
+ executables:
73
+ - jira_tracker
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - .ruby-version
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/jira_tracker
84
+ - jira_tracker.gemspec
85
+ - lib/jira_tracker.rb
86
+ - lib/jira_tracker/version.rb
87
+ homepage: ''
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.2
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Track time on Jira spent on individual issues
111
+ test_files: []