captainslog 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  captainslog
2
2
  ======
3
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.
4
+ captainslog is a command line utility that prints git logs by day and by author. This is useful when filling out time logs and emailing summaries of commits to clients.
5
5
 
6
6
  Install
7
7
  -------
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'captainslog'
4
- Captainslog::Runner.execute(*ARGV)
4
+ Captainslog.run(*ARGV)
@@ -1,66 +1,44 @@
1
1
  require 'date'
2
2
 
3
3
  module Captainslog
4
- class Runner
5
- attr_accessor :args, :start_day
4
+ extend self
6
5
 
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
6
+ def history
7
+ @history ||= 6
8
+ end
35
9
 
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
10
+ def today
11
+ @today ||= Date.today
12
+ end
40
13
 
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
14
+ def tomorrow
15
+ @tomorrow ||= today + 1
16
+ end
44
17
 
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
18
+ def run(*args)
19
+ @history = (args.shift.to_i - 1) if args.any?
20
+ execute
21
+ end
49
22
 
50
- def day_back(count)
51
- (Date.today - count.to_i).strftime('%Y-%m-%d')
23
+ def execute
24
+ print "Captain's Log, Stardate #{today - history} to today...\n\n"
25
+ tomorrow.step(tomorrow - history, -1) do |day|
26
+ log = log_for day
27
+ puts header_for(day - 1)
28
+ puts log.empty? ? '*no commits' : log
29
+ puts "\n"
52
30
  end
31
+ exit($?.exitstatus)
32
+ end
53
33
 
54
- def day_before(day)
55
- (Date.parse(day) - 1).strftime('%Y-%m-%d')
56
- end
34
+ private
57
35
 
58
- def day_header_for(day)
59
- "#{day} (#{day_word_for(day)})"
60
- end
36
+ def header_for(day)
37
+ "#{day} (#{day.strftime('%A')})"
38
+ end
61
39
 
62
- def day_word_for(day)
63
- Date.parse(day).strftime('%A')
64
- end
40
+ def log_for(day)
41
+ %x[ git shortlog --since=\"#{(day - 1).to_time}\" --until=\"#{day}\" --no-merges --format=\"- %s\" -w\"80,0\" ]
42
+ .split("\n").reject{|s| s.empty?}.join("\n")
65
43
  end
66
44
  end
@@ -1,3 +1,3 @@
1
1
  module Captainslog
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: captainslog
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - John Thomas Marino
@@ -15,11 +15,11 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-19 00:00:00 -04:00
18
+ date: 2011-04-29 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
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 "
22
+ description: "\n captainslog is a command line utility that prints git logs by day and by author. This is useful when filling out time logs and emailing summaries of commits to clients.\n "
23
23
  email: writejm@gmail.com
24
24
  executables:
25
25
  - captainslog