captainslog 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2011 by John Thomas Marino
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.
data/README.md ADDED
@@ -0,0 +1,23 @@
1
+ captainslog
2
+ ======
3
+
4
+ captainslog is a command line utility that prints git logs by day and by author. This is especially usefully when filling out time logs and emailing summaries of commits to clients.
5
+
6
+ Install
7
+ -------
8
+
9
+ gem install captainslog
10
+
11
+ Commands
12
+ --------
13
+
14
+ Within a git repository:
15
+
16
+ $ captainslog
17
+ > prints out the past 7 formatted day logs including today
18
+
19
+ $ captainslog 2
20
+ > prints out the past 2 formatted day logs including today
21
+
22
+ $ captainslog 20
23
+ > prints out the past 20 formatted day logs including today
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/captainslog ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'captainslog'
4
+ Captainslog::Runner.execute(*ARGV)
@@ -0,0 +1,3 @@
1
+ module Captainslog
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,66 @@
1
+ require 'date'
2
+
3
+ module Captainslog
4
+ class Runner
5
+ attr_accessor :args, :start_day
6
+
7
+ def initialize(*args)
8
+ @args = args.dup
9
+ @start_day = day_back 7
10
+ run(args)
11
+ end
12
+
13
+ def self.execute(*args)
14
+ new(*args).execute
15
+ end
16
+
17
+ def execute
18
+ days.each_with_index do |day, i|
19
+ return if i == days.size - 1
20
+ puts day_header_for day
21
+ authors_for(day).each do |author|
22
+ puts author
23
+ print commits_for_author_on(author, day)
24
+ end
25
+ puts "\n"
26
+ end
27
+ exit($?.exitstatus || 0)
28
+ end
29
+
30
+ def run(args)
31
+ @start_day = day_back args.shift.to_i if args.any?
32
+ end
33
+
34
+ private
35
+
36
+ def authors_for(day)
37
+ %x[ git log --no-merges --format=\"%an\" --since=#{day_before(day)} --until=#{day}
38
+ ].split("\n").uniq
39
+ end
40
+
41
+ def commits_for_author_on(author, day)
42
+ %x[ git log --no-merges --author=\"#{author}\" --format=\" - %s\" --since=#{day_before(day)} --until=#{day} ]
43
+ end
44
+
45
+ def days
46
+ %x[ git log --no-merges --format="%cd" --date=short --since=#{start_day} | sort -u -r
47
+ ].split("\n").push(start_day)
48
+ end
49
+
50
+ def day_back(count)
51
+ (Date.today - count.to_i).strftime('%Y-%m-%d')
52
+ end
53
+
54
+ def day_before(day)
55
+ (Date.parse(day) - 1).strftime('%Y-%m-%d')
56
+ end
57
+
58
+ def day_header_for(day)
59
+ "#{day} (#{day_word_for(day)})"
60
+ end
61
+
62
+ def day_word_for(day)
63
+ Date.parse(day).strftime('%A')
64
+ end
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: captainslog
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - John Thomas Marino
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-19 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "\n captainslog is a command line utility that prints git logs by day and by author. This is especially usefully when filling out time logs and emailing summaries of commits to clients.\n "
23
+ email: writejm@gmail.com
24
+ executables:
25
+ - captainslog
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - README.md
32
+ - Rakefile
33
+ - LICENSE
34
+ - lib/captainslog/version.rb
35
+ - lib/captainslog.rb
36
+ - bin/captainslog
37
+ has_rdoc: true
38
+ homepage: http://github.com/johmas/captainslog
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project: captainslog
67
+ rubygems_version: 1.3.7
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: captainslog formats git logs by day and author
71
+ test_files: []
72
+