precis 1.0.2 → 1.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.
Files changed (3) hide show
  1. data/bin/precis +12 -12
  2. data/lib/precis.rb +2 -0
  3. metadata +2 -2
data/bin/precis CHANGED
@@ -8,10 +8,12 @@
8
8
  # Author: Rob Miller <rob@bigfish.co.uk>
9
9
 
10
10
  require 'date'
11
+ require 'erb'
12
+ require 'letters'
11
13
 
12
14
  require_relative '../lib/precis'
13
15
 
14
- output = ""
16
+ template = ERB.new File.new(File.dirname(__FILE__) + "/../templates/email.html.erb").read, nil, "%"
15
17
 
16
18
  period = ARGV.shift
17
19
  unless ["daily", "weekly", "monthly"].include? period
@@ -41,9 +43,6 @@ end
41
43
 
42
44
  since = since.strftime("%Y-%m-%d")
43
45
 
44
- output += "Oh joy! It's the #{period} Git update.\n"
45
- output += "These are the stats since #{since}.\n\n"
46
-
47
46
  repos = []
48
47
 
49
48
  ARGV.each do |path|
@@ -52,27 +51,28 @@ ARGV.each do |path|
52
51
  end
53
52
  end
54
53
 
54
+ with_commits = []
55
55
  zero_commits = []
56
56
 
57
57
  repos.each do |repo|
58
58
  Dir.chdir(repo)
59
59
 
60
+ # Take the last two parts of the path as the short version of the
61
+ # repo.
62
+ nice_name = File.basename(File.dirname(repo)) + "/" + File.basename(repo)
63
+
60
64
  total_commits = `git log --oneline --since="#{since}" | wc -l`.strip
61
65
 
62
66
  if total_commits == "0"
63
- zero_commits << File.basename(repo)
67
+ zero_commits << nice_name
64
68
  else
65
- total_commits = total_commits == "1" ? "was #{total_commits} commit" : "were #{total_commits} commits"
66
-
67
- output += "There #{total_commits} in #{File.basename(repo)}:\n\n"
68
- output += `git shortlog -ne --since="#{since}"`.strip.indent("\t")
69
+ log_output = `git shortlog -ne --since="#{since}"`.strip.indent("\t")
69
70
 
70
- output += "\n\n"
71
+ with_commits << { :path => repo, :nice_name => nice_name, :num_commits => total_commits, :log => log_output }
71
72
  end
72
73
  end
73
74
 
74
- # Display the repositories with zero commits at the bottom.
75
- output += "Repositories with zero commits: #{zero_commits.join(', ')}"
75
+ output = template.result(binding)
76
76
 
77
77
  emails.each do |email|
78
78
  send_email email, :subject => "#{period.capitalize} Git update", :body => output
data/lib/precis.rb CHANGED
@@ -19,6 +19,8 @@ def send_email(to, opts = {})
19
19
  msg = <<END_OF_MESSAGE
20
20
  From: #{opts[:from_alias]} <#{opts[:from]}>
21
21
  To: <#{to}>
22
+ MIME-Version: 1.0
23
+ Content-type: text/html; charset=UTF-8
22
24
  Subject: #{opts[:subject]}
23
25
 
24
26
  #{opts[:body]}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: precis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-20 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Watches the Git repositories you tell it to, and then emails you a weekly
15
15
  summary of activity.