precis 1.0.0 → 1.0.1
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/bin/precis +9 -10
- data/lib/precis.rb +31 -0
- metadata +2 -1
data/bin/precis
CHANGED
@@ -9,22 +9,19 @@
|
|
9
9
|
|
10
10
|
require 'date'
|
11
11
|
|
12
|
-
|
12
|
+
require_relative '../lib/precis'
|
13
13
|
|
14
|
-
|
15
|
-
# git shortlog output.
|
16
|
-
class String
|
17
|
-
def indent(char, level = nil)
|
18
|
-
level ||= 1
|
19
|
-
"#{char * level}" + self.gsub(/\n/, "\n#{char * level}")
|
20
|
-
end
|
21
|
-
end
|
14
|
+
output = ""
|
22
15
|
|
23
16
|
period = ARGV.shift
|
24
17
|
unless ["daily", "weekly", "monthly"].include? period
|
25
18
|
period = "weekly"
|
26
19
|
end
|
27
20
|
|
21
|
+
emails = ARGV.shift
|
22
|
+
emails = emails.split(/,/)
|
23
|
+
emails = emails.map { |e| e.strip }
|
24
|
+
|
28
25
|
# Git expects a "since" date, so we need to map our periods to a date
|
29
26
|
now = Date.today
|
30
27
|
|
@@ -72,4 +69,6 @@ repos.each do |repo|
|
|
72
69
|
end
|
73
70
|
end
|
74
71
|
|
75
|
-
|
72
|
+
emails.each do |email|
|
73
|
+
send_email email, :subject => "#{period.capitalize} Git update", :body => output
|
74
|
+
end
|
data/lib/precis.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# A quick 'n' dirty function for indenting a string; we use it for the
|
2
|
+
# git shortlog output.
|
3
|
+
class String
|
4
|
+
def indent(char, level = nil)
|
5
|
+
level ||= 1
|
6
|
+
"#{char * level}" + self.gsub(/\n/, "\n#{char * level}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def send_email(to, opts = {})
|
11
|
+
require 'net/smtp'
|
12
|
+
|
13
|
+
opts[:server] ||= 'localhost'
|
14
|
+
opts[:from] ||= 'robot@localhost'
|
15
|
+
opts[:from_alias] ||= 'The Git Summary Robot'
|
16
|
+
opts[:subject] ||= ""
|
17
|
+
opts[:body] ||= ""
|
18
|
+
|
19
|
+
msg = <<END_OF_MESSAGE
|
20
|
+
From: #{opts[:from_alias]} <#{opts[:from]}>
|
21
|
+
To: <#{to}>
|
22
|
+
Subject: #{opts[:subject]}
|
23
|
+
|
24
|
+
#{opts[:body]}
|
25
|
+
END_OF_MESSAGE
|
26
|
+
|
27
|
+
Net::SMTP.start(opts[:server]) do |smtp|
|
28
|
+
smtp.send_message msg, opts[:from], to
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
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.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -20,6 +20,7 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- bin/precis
|
23
|
+
- lib/precis.rb
|
23
24
|
homepage: https://github.com/robmiller/precis
|
24
25
|
licenses: []
|
25
26
|
post_install_message:
|