git_timelog 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: 1ad5a0fd175534fbb4452af0d37fdf542609548d
4
+ data.tar.gz: 5a5482d4613e43d9e55364db4ea459a3d8b2d799
5
+ SHA512:
6
+ metadata.gz: 6781fb989628dab50fc7ff986d5d4dba60e895749e395f613c8ca84af5e1695b4d28269cca5c507c55bec58393a97a04f52f1b9878d0af31ef1339ade7e4999b
7
+ data.tar.gz: e0ad94957492610755710c9b185cd52155082ea24e4bb336e7d11fe0f1b30b99aae540bd8d8885656080501cd32509192cd62957754de1ec0dff38f0e7617e4e
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,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem "rspec"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Sushil Shrestha
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,31 @@
1
+ # GitTimelog
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'git_timelog'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install git_timelog
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/git_timelog/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git_timelog/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "git_timelog"
8
+ spec.version = GitTimelog::VERSION
9
+ spec.authors = ["Sushil Shrestha", "Ganesh Kunwar", "Surya Siwakoti"]
10
+ spec.email = ["sushil@jyaasa.com", "ganesh@jyaasa.com", "surya@jyaasa.com"]
11
+ spec.summary = "A tool to extract daily update from GIT commits."
12
+ spec.description = "The tool can return json of the tasks done along with start and end time. As well as simply copy the list of commits done as plain-text list which can be ordered or unordered."
13
+ spec.homepage = "http://jyaasa.com/git_timelog"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git 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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.4"
24
+ end
@@ -0,0 +1,49 @@
1
+ require "date"
2
+
3
+ class GitFormatter
4
+ def initialize(data)
5
+ @data = data
6
+ end
7
+
8
+ def commit_array
9
+ data = @data
10
+ commit_array = []
11
+ unless data.empty?
12
+ commit_array = data.split(/git__title:/)
13
+ commit_array.reject!(&:empty?)
14
+ else
15
+ []
16
+ end
17
+ end
18
+
19
+ # TODO: Refactor
20
+ def json_formatted
21
+ commits = commit_array
22
+ hash_array = []
23
+ commits.each do |c|
24
+ commit_hash = {}
25
+ title = c[/.+?(?=git__description)/m]
26
+ hours_logged = title[/(?<=\[)((\d*[.])?\d+)(?=\])/].to_f
27
+ end_time = DateTime.parse(c[/(?<=git__date:)(.*)/])
28
+ start_time = end_time - hours_logged/24.0
29
+
30
+ commit_hash[:title] = title.gsub(/\[((\d*[.])?\d+)\]/, '')
31
+ commit_hash[:description] = c[/(?<=git__description:)(.*)(?=git__date:)/m]
32
+ commit_hash[:end_time] = end_time.to_s
33
+ commit_hash[:start_time] = start_time.to_s
34
+ hash_array.push(commit_hash)
35
+ end
36
+ hash_array
37
+ end
38
+
39
+ # list_style = 'ordered' || 'unordered'
40
+ def title_list(list_style)
41
+ hash_array = json_formatted
42
+ commit_titles = hash_array.map{ |commit| commit[:title] }
43
+ if list_style == 'unordered'
44
+ commit_titles.join("\n")
45
+ else
46
+ commit_titles.each_with_index.map { |title,number| "#{number + 1}. #{title}" }.join("\n")
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ module GitTimelog
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ require "git_timelog/version"
2
+ require "git_formatter"
3
+ require "json"
4
+
5
+ module GitTimelog
6
+ # TODO: make the time changeable
7
+ def git_timelog(from_time = '6am')
8
+ `git log --pretty=format:"git__title:%sgit__description:%bgit__date:%cd" --author="#{current_author}" --since={#{from_time}} --reverse`
9
+ end
10
+
11
+ def current_author
12
+ `git config user.name`
13
+ end
14
+
15
+ def json_format
16
+ data = git_timelog
17
+ gf = GitFormatter.new(data)
18
+ gf.json_formatted.to_json
19
+ end
20
+
21
+ # list_style = 'ordered' || 'unordered'
22
+ def to_clipboard(list_style = 'ordered')
23
+ data = git_timelog
24
+ gf = GitFormatter.new(data)
25
+ `echo "#{gf.title_list(list_style)}" | pbcopy`
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ require "spec_helper"
2
+
3
+ describe GitTimelog do
4
+
5
+ # TODO: Refactor
6
+ describe '#git_timelog' do
7
+ it "should extract git commits" do
8
+ expect(git_timelog).to eql(`git log --pretty=format:"git__title:%sgit__description:%bgit__date:%cd" --author="#{current_author}" --since={6am} --reverse`)
9
+ end
10
+ end
11
+
12
+ # TODO: Refactor
13
+ describe '#current_author' do
14
+ it "should return authors name" do
15
+ expect(current_author).to eql(`git config user.name`)
16
+ end
17
+ end
18
+
19
+ describe '#json_format' do
20
+ it "should return json formatted update" do
21
+ formatted_json = json_format
22
+ puts formatted_json
23
+ expect(formatted_json).to eql(formatted_json) # LOL
24
+ end
25
+ end
26
+
27
+ describe '#to_clipboard' do
28
+ it "should copy ordered list to clipboard" do
29
+ to_clipboard
30
+ puts "Ordered List copied to clipboard. Paste to test."
31
+ end
32
+ it "should copy unordered list to clipboard" do
33
+ to_clipboard('unordered')
34
+ puts "Unordered List copied to clipboard"
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+ require "git_timelog"
2
+ require "json"
3
+
4
+ RSpec.configure do |c|
5
+ c.include(GitTimelog)
6
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_timelog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sushil Shrestha
8
+ - Ganesh Kunwar
9
+ - Surya Siwakoti
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2016-02-20 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.7'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '10.0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '10.0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rspec
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '3.4'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '3.4'
57
+ description: The tool can return json of the tasks done along with start and end time.
58
+ As well as simply copy the list of commits done as plain-text list which can be
59
+ ordered or unordered.
60
+ email:
61
+ - sushil@jyaasa.com
62
+ - ganesh@jyaasa.com
63
+ - surya@jyaasa.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - Gemfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - git_timelog.gemspec
74
+ - lib/git_formatter.rb
75
+ - lib/git_timelog.rb
76
+ - lib/git_timelog/version.rb
77
+ - spec/git_log_extraction_spec.rb
78
+ - spec/spec_helper.rb
79
+ homepage: http://jyaasa.com/git_timelog
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.5
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A tool to extract daily update from GIT commits.
103
+ test_files:
104
+ - spec/git_log_extraction_spec.rb
105
+ - spec/spec_helper.rb