git-timesheet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15767b3bbbda54fca1b6de3def0333ef118d8745
4
+ data.tar.gz: 150c5ec80b329cf588ec9af502f075dea3a282ab
5
+ SHA512:
6
+ metadata.gz: 1d65d97f7d97df64eff1ff75048fc5fe995d455ad74b6885f35d46f53b88b2af8808608dcf8dca495195addc17ac1e70ace18c5fcb62a31fc24d96827dfe9548
7
+ data.tar.gz: 6bd61af169049bc582967ae0826658d210fdb9fe098ffe2444b8fe8abbafec1dcaae392e8eee6f1bde23b309f4aff6f197a08a91925b976312bd7fa3e773e69d
@@ -0,0 +1,22 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in git-timesheet.gemspec
4
+ gemspec
@@ -0,0 +1,55 @@
1
+ # RubyDNS
2
+
3
+ Generate a timesheet from one or more git repositories.
4
+
5
+ ## Installation
6
+
7
+ Install it yourself as:
8
+
9
+ $ gem install git-timesheet
10
+
11
+ ## Usage
12
+
13
+ $ git-timesheet.rb --help
14
+ Usage: git-timesheet [options]
15
+ -s, --since [TIME] Start date for the report (default is 1 week ago)
16
+ -a, --author [EMAIL] User for the report (default is the author set in git config)
17
+ --authors List all available authors
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
26
+
27
+ ### Desired Features
28
+
29
+ * Support for more features of DNS such as zone transfer.
30
+ * Support reverse records more easily.
31
+ * Some kind of system level integration, e.g. registering a DNS server with the currently running system resolver.
32
+
33
+ ## License
34
+
35
+ Released under the MIT license.
36
+
37
+ Copyright, 2009, 2012, 2014, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
38
+
39
+ Permission is hereby granted, free of charge, to any person obtaining a copy
40
+ of this software and associated documentation files (the "Software"), to deal
41
+ in the Software without restriction, including without limitation the rights
42
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43
+ copies of the Software, and to permit persons to whom the Software is
44
+ furnished to do so, subject to the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be included in
47
+ all copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
55
+ THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'git/timesheet/entry'
4
+
5
+ require 'optparse'
6
+ require 'time'
7
+
8
+ options = {}
9
+
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: git-timesheet [options]"
12
+
13
+ opts.on("-s", "--since [TIME]", "Start date for the report (default is 1 week ago)") do |time|
14
+ options[:since] = time
15
+ end
16
+
17
+ opts.on("-a", "--author [EMAIL]", "User for the report (default is the author set in git config)") do |author|
18
+ options[:author] = author
19
+ end
20
+
21
+ opts.on(nil, '--authors', 'List all available authors') do |authors|
22
+ options[:authors] = authors
23
+ end
24
+ end.parse!
25
+
26
+ options[:since] ||= '1 week ago'
27
+
28
+ BLOCK_SLOP_DURATION = 3600 * 4
29
+
30
+ if options[:authors]
31
+ authors = `git log --no-merges --simplify-merges --format="%an (%ae)" --since="#{options[:since].gsub('"','\\"')}"`.strip.split("\n").uniq
32
+ puts authors.join("\n")
33
+ else
34
+ options[:author] ||= `git config --get user.email`.strip
35
+
36
+ entries = []
37
+
38
+ ARGV.each do |path|
39
+ if File.exist? path
40
+ puts "Loading #{path}..."
41
+ entries << Git::Timesheet::Entry.load(path, since: options[:since], author: options[:author])
42
+ end
43
+ end
44
+
45
+ entries.flatten!
46
+
47
+ if entries.empty?
48
+ puts "No entries..."
49
+ exit(0)
50
+ end
51
+
52
+ entries.sort!
53
+
54
+ previous_entry = entries.shift
55
+ blocks = []
56
+ block = [previous_entry]
57
+
58
+ entries.each do |entry|
59
+ if (entry.timestamp - previous_entry.timestamp) > BLOCK_SLOP_DURATION
60
+ blocks << block
61
+ block = []
62
+ end
63
+
64
+ block << entry
65
+
66
+ previous_entry = entry
67
+ end
68
+
69
+ # Add the last block
70
+ blocks << block
71
+ total_hours = 0
72
+ blocks.each do |block|
73
+ if block != blocks.first
74
+ puts
75
+ end
76
+
77
+ duration = (block.last.timestamp - block.first.timestamp) / 3600.0
78
+ total_hours += duration
79
+
80
+ puts "For period #{block.first.timestamp} -> #{block.last.timestamp}: #{duration.round(2)} hours (#{block.first.timestamp.strftime("%A")})"
81
+
82
+ block.each do |entry|
83
+ puts "\t#{entry.timestamp}: #{entry.message} (#{entry.repository})"
84
+ end
85
+ end
86
+
87
+ puts "TOTAL: #{total_hours.round(2)}"
88
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'git/timesheet/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "git-timesheet"
8
+ spec.version = Git::Timesheet::VERSION
9
+ spec.authors = ["Samuel Williams"]
10
+ spec.email = ["samuel.williams@oriontransfer.co.nz"]
11
+ spec.summary = %q{Computes a timesheet for a given set of git repositories.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,7 @@
1
+ require "git/timesheet/version"
2
+
3
+ module Git
4
+ module Timesheet
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,54 @@
1
+ # Copyright, 2015, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ # of this software and associated documentation files (the "Software"), to deal
5
+ # in the Software without restriction, including without limitation the rights
6
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ # copies of the Software, and to permit persons to whom the Software is
8
+ # furnished to do so, subject to the following conditions:
9
+ #
10
+ # The above copyright notice and this permission notice shall be included in
11
+ # all copies or substantial portions of the Software.
12
+ #
13
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ # THE SOFTWARE.
20
+
21
+ module Git
22
+ module Timesheet
23
+ class Entry
24
+ def initialize(timestamp, message, repository)
25
+ @timestamp = timestamp
26
+ @message = message
27
+ @repository = repository
28
+ end
29
+
30
+ attr :timestamp
31
+ attr :message
32
+ attr :repository
33
+
34
+ def <=> other
35
+ self.timestamp <=> other.timestamp
36
+ end
37
+
38
+ def self.load(git_root, since: nil, author: nil)
39
+ log_lines = []
40
+
41
+ Dir.chdir(git_root) do
42
+ log_lines = `git log --no-merges --simplify-merges --author="#{author.gsub('"','\\"')}" --format="%ad %s <%h>" --date=iso --since="#{since.gsub('"','\\"')}"`.split("\n")
43
+ end
44
+
45
+ log_lines.collect do |line|
46
+ timestamp = Time.parse line.slice!(0,25)
47
+ message = line
48
+
49
+ Entry.new(timestamp, message, git_root)
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module Git
2
+ module Timesheet
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git-timesheet
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Williams
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description:
42
+ email:
43
+ - samuel.williams@oriontransfer.co.nz
44
+ executables:
45
+ - git-timesheet
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - bin/git-timesheet
54
+ - git-timesheet.gemspec
55
+ - lib/git/timesheet.rb
56
+ - lib/git/timesheet/entry.rb
57
+ - lib/git/timesheet/version.rb
58
+ homepage: ''
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.6
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Computes a timesheet for a given set of git repositories.
82
+ test_files: []