worklogger 2.5

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: 8203518dc88ad1196fa94b4816a6cf675bbac3c3
4
+ data.tar.gz: c80c6c06e8971cd2c18c7ad8358d6db4e2e299e8
5
+ SHA512:
6
+ metadata.gz: 03dec8e67b0abe0e5379be1fa43d1b379c6ac8d4cf20bda08a0f1c665d8ad08554086c4ddeb4f3d5ebdf1265bbd4f363c2d90d11678c90a619f057fcfcaf926d
7
+ data.tar.gz: c75f5cb6044ff3d32bfafaa4e426b5e677970713166597e2a46cef03ddfe8b7733fea722ef29654cfde429acff21b6a5bcc01a19e466214464694cae85f160e9
data/README.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = WorkLogger
2
+ Worklogger is a system that logs your work in JIRA automatically when you commit changes in git. Work can be logged also when you don't want to commit your code but still log your work against any issue on JIRA.
3
+
4
+ == Installation
5
+ Once your project is initialized with Git, your project folder shall contain a hidden folder called .git
6
+
7
+ Install ruby through RVM.
8
+ rvm install <version_name>
9
+
10
+ Save your JIRA username and password in environment. (For linux, run "sudo vim ~/.bashrc" and add the following lines at the end of file)
11
+ export USER_NAME="your user name"
12
+ export PASSWORD="your jira password"
13
+ export CORPORATE_URL="your corporate url"
14
+
15
+ Restart the terminal window after setting up the above credentials.
16
+ Install worklogger
17
+
18
+ gem install worklogger
19
+
20
+ == Usage
21
+ To begin using with git commit, do
22
+
23
+ worklogger init
24
+
25
+ Now every time you wish to log your work, just commit with following syntax and see the magic happen:
26
+
27
+ git commit -m "issue=ABC-100 time=3h30m commit message goes here"
28
+
29
+ For standalone logging of work,
30
+
31
+ worklogger log
32
+
33
+ == Note on Patches/Pull Requests
34
+
35
+ * Fork the project.
36
+ * Make your feature addition or bug fix.
37
+ * Send me a pull request.
38
+
39
+
40
+ == Contributers
41
+
42
+ Thanks to everyone for their interest and their valuable feedback.
43
+ * vivektripathi (Vivek Tripathi) - vivek.tripathi@softway.com
44
+ * abhilash (Abhilash M Kurup) - abhilashm.kurup@softway.com
45
+ * amitkumarjangu (Amit kumar Jangu) - amitkumarjangu@softway.com
46
+
47
+ == Copyright
48
+
49
+ Copyright (c) 2016, released under the MIT license.
data/bin/worklogger ADDED
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'worklogger'
4
+ require 'pry'
5
+ require 'rubygems'
6
+ require 'net/http'
7
+ require 'net/https'
8
+ require 'json'
9
+ require 'uri'
10
+ require 'date'
11
+
12
+
13
+ def log_work issue_key, time_spent, commit_message
14
+ jira_username = ENV['USER_NAME']
15
+ jira_password = ENV['PASSWORD']
16
+ corporate_url= ENV['CORPORATE_URL']
17
+
18
+ ## format time spent from say 2h10m to 2h 10m(added space)
19
+ time_spent_dup = time_spent.dup
20
+ index_of_h = time_spent_dup.index('h')
21
+ if !index_of_h.nil?
22
+ time_spent = time_spent_dup.insert(index_of_h + 1, ' ')
23
+ end
24
+
25
+ jira_url = "#{corporate_url}/rest/api/latest/issue/"
26
+ issue_keys = %w[issue_key]
27
+ json_ext = ".json"
28
+
29
+ for issue in issue_keys
30
+
31
+ uri = URI.parse("#{corporate_url}/rest/auth/1/session")
32
+ http = Net::HTTP.new(uri.host, uri.port)
33
+ http.use_ssl = true
34
+ request = Net::HTTP::Get.new(uri.to_s)
35
+ request.basic_auth jira_username.to_s, URI.decode(jira_password.to_s)
36
+ request['Content-Type'] = 'application/json'
37
+ response = http.request(request)
38
+ worklog = {
39
+ comment: commit_message.to_s,
40
+ started: DateTime.now.strftime("%Y-%m-%dT%H:%M:%S.%L%z"),
41
+ timeSpent: time_spent.to_s,
42
+ }.to_json
43
+
44
+
45
+ if response.code =~ /20[0-9]{1}/
46
+ data = JSON.parse(response.body)
47
+ fields = data.keys
48
+
49
+ uri = URI.parse("#{corporate_url}/rest/api/2/issue/#{issue_key}/worklog")
50
+ https = Net::HTTP.new(uri.host, uri.port)
51
+ https.use_ssl = true
52
+ req = Net::HTTP::Post.new(uri.path, initheader = {'Content-Type' =>'application/json'})
53
+ req.basic_auth jira_username.to_s, URI.decode(jira_password.to_s)
54
+ req.body = "#{worklog}"
55
+ res = https.request(req)
56
+ puts "Response #{res.code} #{res.message}: #{res.body}"
57
+
58
+ puts "\n"#extra line feed for readability
59
+ case res
60
+ when Net::HTTPRedirection
61
+ # repeat the request using response['Location']
62
+ when Net::HTTPSuccess
63
+ repo_info = JSON.parse res.body
64
+ else
65
+ # response code isn't a 200; raise an exception
66
+ res.error!
67
+ end
68
+ else
69
+ raise StandardError, "Unsuccessful response code " + response.code + " for issue " + issue
70
+ end
71
+ end
72
+ end
73
+
74
+ command = ARGV[0]
75
+
76
+ case command
77
+ when nil
78
+ file = File.open('../options.txt', 'rb')
79
+ content = file.read
80
+ puts content
81
+
82
+ when '-h', '--help'
83
+ file = File.open('../README.rdoc', 'rb')
84
+ content = file.read
85
+ puts content
86
+
87
+ when 'init', 'initialize'
88
+ Worklogger.make_me_lazy
89
+
90
+ when 'log'
91
+ puts 'Enter issue_key'
92
+ issue_key = STDIN.gets.chomp.upcase
93
+
94
+ puts 'Enter time spent:'
95
+ time_spent = STDIN.gets.chomp
96
+
97
+ puts 'Enter message for work log:'
98
+ message = STDIN.gets.chomp
99
+
100
+ log_work(issue_key, time_spent, message)
101
+ end
data/lib/worklogger.rb ADDED
@@ -0,0 +1,5 @@
1
+ class Worklogger
2
+ def self.make_me_lazy
3
+ system 'cp post-commit .git/hooks/'
4
+ end
5
+ end
data/options.txt ADDED
@@ -0,0 +1,14 @@
1
+ available options:
2
+ [-h, --help] -> help
3
+ [init, intialize] -> setup
4
+ [log] -> log work
5
+
6
+ ####################################################
7
+ For standalone logging without committing your code
8
+
9
+ worklogger log
10
+ ####################################################
11
+
12
+ After Setup, every time you wish to log your work, just commit with following syntax and see the magic happen:
13
+
14
+ git commit -m "issue=ABC-100 time=3h30m commit message goes here"
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: worklogger
3
+ version: !ruby/object:Gem::Version
4
+ version: '2.5'
5
+ platform: ruby
6
+ authors:
7
+ - Vivek
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Git to JIRA work logger
14
+ email: vivek.tripathi@softway.com
15
+ executables:
16
+ - worklogger
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - README.rdoc
21
+ - bin/worklogger
22
+ - lib/worklogger.rb
23
+ - options.txt
24
+ homepage: http://rubygems.org/gems/worklogger
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.6.4
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: JIRA Work Logger
48
+ test_files: []