source-tools 0.6.0 → 0.6.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -6
- data/.gitmodules +3 -0
- data/CHANGES.md +14 -0
- data/{README → README.md} +14 -13
- data/Rakefile +11 -50
- data/{TODO → TODO.md} +1 -1
- data/bin/source-tools +0 -0
- data/lib/source-tools.rb +1 -1
- data/lib/source-tools/bin.rb +3 -0
- data/lib/source-tools/default.rb +1 -0
- data/lib/source-tools/tasks/template.rb +1 -0
- data/lib/source-tools/templates/t.profile.erb +3 -0
- data/lib/source-tools/templates/tRakefile.erb +21 -33
- data/lib/source-tools/templates/tnginx-for-unicorn.conf.erb +61 -0
- data/lib/source-tools/version.rb +2 -1
- data/source-tools.gemspec +50 -21
- data/task/README.md +54 -0
- data/task/gemgem.rb +258 -0
- metadata +50 -85
- data/CHANGES +0 -10
- data/lib/source-tools/templates/t.bashrc.erb +0 -5
- data/tasks/ann.rake +0 -80
- data/tasks/bones.rake +0 -20
- data/tasks/gem.rake +0 -201
- data/tasks/git.rake +0 -40
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -51
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -292
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/zentest.rake +0 -36
data/task/gemgem.rb
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
|
|
2
|
+
module Gemgem
|
|
3
|
+
class << self
|
|
4
|
+
attr_accessor :dir, :spec, :spec_create
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
module_function
|
|
8
|
+
def gem_tag ; "#{spec.name}-#{spec.version}" ; end
|
|
9
|
+
def gem_path ; "#{pkg_dir}/#{gem_tag}.gem" ; end
|
|
10
|
+
def spec_path ; "#{dir}/#{spec.name}.gemspec" ; end
|
|
11
|
+
def pkg_dir ; "#{dir}/pkg" ; end
|
|
12
|
+
def escaped_dir; @escaped_dir ||= Regexp.escape(dir); end
|
|
13
|
+
|
|
14
|
+
def init dir, &block
|
|
15
|
+
self.dir = dir
|
|
16
|
+
$LOAD_PATH.unshift("#{dir}/lib")
|
|
17
|
+
ENV['RUBYLIB'] = "#{dir}/lib:#{ENV['RUBYLIB']}"
|
|
18
|
+
ENV['PATH'] = "#{dir}/bin:#{ENV['PATH']}"
|
|
19
|
+
self.spec_create = block
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create
|
|
23
|
+
spec = Gem::Specification.new do |s|
|
|
24
|
+
s.authors = ['Lin Jen-Shin (godfat)']
|
|
25
|
+
s.email = ['godfat (XD) godfat.org']
|
|
26
|
+
|
|
27
|
+
s.description = description.join
|
|
28
|
+
s.summary = description.first
|
|
29
|
+
s.license = readme['LICENSE'].sub(/.+\n\n/, '').lines.first.strip
|
|
30
|
+
|
|
31
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
|
32
|
+
s.files = gem_files
|
|
33
|
+
s.test_files = test_files
|
|
34
|
+
s.executables = bin_files
|
|
35
|
+
end
|
|
36
|
+
spec_create.call(spec)
|
|
37
|
+
spec.homepage ||= "https://github.com/godfat/#{spec.name}"
|
|
38
|
+
self.spec = spec
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def write
|
|
42
|
+
File.open(spec_path, 'w'){ |f| f << split_lines(spec.to_ruby) }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def split_lines ruby
|
|
46
|
+
ruby.gsub(/(.+?)\s*=\s*\[(.+?)\]/){ |s|
|
|
47
|
+
if $2.index(',')
|
|
48
|
+
"#{$1} = [\n #{$2.split(',').map(&:strip).join(",\n ")}]"
|
|
49
|
+
else
|
|
50
|
+
s
|
|
51
|
+
end
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def strip_path path
|
|
56
|
+
strip_home_path(strip_cwd_path(path))
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def strip_home_path path
|
|
60
|
+
path.sub(ENV['HOME'], '~')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def strip_cwd_path path
|
|
64
|
+
path.sub(Dir.pwd, '.')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def git *args
|
|
68
|
+
`git --git-dir=#{dir}/.git #{args.join(' ')}`
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def sh_git *args
|
|
72
|
+
Rake.sh('git', "--git-dir=#{dir}/.git", *args)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def sh_gem *args
|
|
76
|
+
Rake.sh(Gem.ruby, '-S', 'gem', *args)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def glob path=dir
|
|
80
|
+
Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def readme
|
|
84
|
+
@readme ||=
|
|
85
|
+
if (path = "#{Gemgem.dir}/README.md") && File.exist?(path)
|
|
86
|
+
ps = "##{File.read(path)}".
|
|
87
|
+
scan(/((#+)[^\n]+\n\n.+?(?=(\n\n\2[^#\n]+\n)|\Z))/m).map(&:first)
|
|
88
|
+
ps.inject('HEADER' => ps.first){ |r, s, i|
|
|
89
|
+
r[s[/\w+/]] = s
|
|
90
|
+
r
|
|
91
|
+
}
|
|
92
|
+
else
|
|
93
|
+
{}
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def description
|
|
98
|
+
# JRuby String#lines is returning an enumerator
|
|
99
|
+
@description ||= (readme['DESCRIPTION']||'').sub(/.+\n\n/, '').lines.to_a
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def all_files
|
|
103
|
+
@all_files ||= fold_files(glob).sort
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def fold_files files
|
|
107
|
+
files.inject([]){ |r, path|
|
|
108
|
+
if File.file?(path) && path !~ %r{/\.git(/|$)} &&
|
|
109
|
+
(rpath = path[%r{^#{escaped_dir}/(.*$)}, 1])
|
|
110
|
+
r << rpath
|
|
111
|
+
elsif File.symlink?(path) # walk into symlinks...
|
|
112
|
+
r.concat(fold_files(glob(File.expand_path(path,
|
|
113
|
+
File.readlink(path)))))
|
|
114
|
+
else
|
|
115
|
+
r
|
|
116
|
+
end
|
|
117
|
+
}
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def gem_files
|
|
121
|
+
@gem_files ||= all_files.reject{ |f|
|
|
122
|
+
f =~ ignored_pattern && !git_files.include?(f)
|
|
123
|
+
}
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def test_files
|
|
127
|
+
@test_files ||= gem_files.grep(%r{^test/(.+?/)*test_.+?\.rb$})
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def bin_files
|
|
131
|
+
@bin_files ||= gem_files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def git_files
|
|
135
|
+
@git_files ||= if File.exist?("#{dir}/.git")
|
|
136
|
+
git('ls-files').split("\n")
|
|
137
|
+
else
|
|
138
|
+
[]
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def ignored_files
|
|
143
|
+
@ignored_files ||= all_files.grep(ignored_pattern)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def ignored_pattern
|
|
147
|
+
@ignored_pattern ||= if gitignore.empty?
|
|
148
|
+
/^$/
|
|
149
|
+
else
|
|
150
|
+
Regexp.new(expand_patterns(gitignore).join('|'))
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def expand_patterns pathes
|
|
155
|
+
# http://git-scm.com/docs/gitignore
|
|
156
|
+
pathes.flat_map{ |path|
|
|
157
|
+
# we didn't implement negative pattern for now
|
|
158
|
+
Regexp.escape(path).sub(%r{^/}, '^').gsub(/\\\*/, '[^/]*')
|
|
159
|
+
}
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def gitignore
|
|
163
|
+
@gitignore ||= if File.exist?(path = "#{dir}/.gitignore")
|
|
164
|
+
File.read(path).lines.
|
|
165
|
+
reject{ |l| l == /^\s*(#|\s+$)/ }.map(&:strip)
|
|
166
|
+
else
|
|
167
|
+
[]
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
namespace :gem do
|
|
173
|
+
|
|
174
|
+
desc 'Install gem'
|
|
175
|
+
task :install => [:build] do
|
|
176
|
+
Gemgem.sh_gem('install', Gemgem.gem_path)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
desc 'Build gem'
|
|
180
|
+
task :build => [:spec] do
|
|
181
|
+
require 'fileutils'
|
|
182
|
+
require 'rubygems/package'
|
|
183
|
+
gem = nil
|
|
184
|
+
Dir.chdir(Gemgem.dir) do
|
|
185
|
+
gem = Gem::Package.build(Gem::Specification.load(Gemgem.spec_path))
|
|
186
|
+
FileUtils.mkdir_p(Gemgem.pkg_dir)
|
|
187
|
+
FileUtils.mv(gem, Gemgem.pkg_dir) # gem is relative path, but might be ok
|
|
188
|
+
end
|
|
189
|
+
puts "\e[35mGem built: \e[33m" \
|
|
190
|
+
"#{Gemgem.strip_path("#{Gemgem.pkg_dir}/#{gem}")}\e[0m"
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
desc 'Generate gemspec'
|
|
194
|
+
task :spec do
|
|
195
|
+
Gemgem.create
|
|
196
|
+
Gemgem.write
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
desc 'Release gem'
|
|
200
|
+
task :release => [:spec, :check, :build] do
|
|
201
|
+
Gemgem.module_eval do
|
|
202
|
+
sh_git('tag', Gemgem.gem_tag)
|
|
203
|
+
sh_git('push')
|
|
204
|
+
sh_git('push', '--tags')
|
|
205
|
+
sh_gem('push', Gemgem.gem_path)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
task :check do
|
|
210
|
+
ver = Gemgem.spec.version.to_s
|
|
211
|
+
|
|
212
|
+
if ENV['VERSION'].nil?
|
|
213
|
+
puts("\e[35mExpected " \
|
|
214
|
+
"\e[33mVERSION\e[35m=\e[33m#{ver}\e[0m")
|
|
215
|
+
exit(1)
|
|
216
|
+
|
|
217
|
+
elsif ENV['VERSION'] != ver
|
|
218
|
+
puts("\e[35mExpected \e[33mVERSION\e[35m=\e[33m#{ver} " \
|
|
219
|
+
"\e[35mbut got\n " \
|
|
220
|
+
"\e[33mVERSION\e[35m=\e[33m#{ENV['VERSION']}\e[0m")
|
|
221
|
+
exit(2)
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
end # of gem namespace
|
|
226
|
+
|
|
227
|
+
desc 'Run tests'
|
|
228
|
+
task :test do
|
|
229
|
+
next if Gemgem.test_files.empty?
|
|
230
|
+
Gemgem.test_files.each{ |file| require "#{Gemgem.dir}/#{file[0..-4]}" }
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
desc 'Trash ignored files'
|
|
234
|
+
task :clean => ['gem:spec'] do
|
|
235
|
+
next if Gemgem.ignored_files.empty?
|
|
236
|
+
|
|
237
|
+
require 'fileutils'
|
|
238
|
+
trash = File.expand_path("~/.Trash/#{Gemgem.spec.name}")
|
|
239
|
+
puts "Move the following files into:" \
|
|
240
|
+
" \e[35m#{Gemgem.strip_path(trash)}\e[33m"
|
|
241
|
+
|
|
242
|
+
Gemgem.ignored_files.each do |file|
|
|
243
|
+
from = "#{Gemgem.dir}/#{file}"
|
|
244
|
+
to = "#{trash}/#{File.dirname(file)}"
|
|
245
|
+
puts Gemgem.strip_path(from)
|
|
246
|
+
|
|
247
|
+
FileUtils.mkdir_p(to)
|
|
248
|
+
FileUtils.mv(from, to)
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
print "\e[0m"
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
task :default do
|
|
255
|
+
# Is there a reliable way to do this in the current process?
|
|
256
|
+
# It failed miserably before between Rake versions...
|
|
257
|
+
exec "#{Gem.ruby} -S #{$PROGRAM_NAME} -f #{Rake.application.rakefile} -T"
|
|
258
|
+
end
|
metadata
CHANGED
|
@@ -1,57 +1,43 @@
|
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: source-tools
|
|
3
|
-
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.6.1
|
|
5
5
|
platform: ruby
|
|
6
|
-
authors:
|
|
7
|
-
-
|
|
6
|
+
authors:
|
|
7
|
+
- Lin Jen-Shin (godfat)
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
type: :development
|
|
18
|
-
version_requirement:
|
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
20
|
-
requirements:
|
|
11
|
+
date: 2014-10-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rake
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
21
17
|
- - ">="
|
|
22
|
-
- !ruby/object:Gem::Version
|
|
23
|
-
version:
|
|
24
|
-
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '10'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '10'
|
|
25
27
|
description: " source code tools collection"
|
|
26
|
-
email:
|
|
27
|
-
|
|
28
|
+
email:
|
|
29
|
+
- godfat (XD) godfat.org
|
|
30
|
+
executables:
|
|
28
31
|
- source-tools
|
|
29
32
|
extensions: []
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
- .gitignore
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
36
|
-
- bin/source-tools
|
|
37
|
-
- lib/source-tools/templates/t.bashrc.erb
|
|
38
|
-
- lib/source-tools/templates/t.config/fish/config.fish.erb
|
|
39
|
-
- lib/source-tools/templates/t.gemrc.erb
|
|
40
|
-
- lib/source-tools/templates/t.gitconfig.erb
|
|
41
|
-
- lib/source-tools/templates/t.gitignore.erb
|
|
42
|
-
- lib/source-tools/templates/t.profile.erb
|
|
43
|
-
- lib/source-tools/templates/t.screenrc.erb
|
|
44
|
-
- lib/source-tools/templates/t.vimrc.erb
|
|
45
|
-
- lib/source-tools/templates/tconfig/mime.types.erb
|
|
46
|
-
- lib/source-tools/templates/tconfig/nginx.conf.erb
|
|
47
|
-
- source-tools.gemspec
|
|
48
|
-
- lib/source-tools/templates/t.git/hooks/post-receive.erb
|
|
49
|
-
files:
|
|
50
|
-
- .gitignore
|
|
51
|
-
- CHANGES
|
|
52
|
-
- README
|
|
33
|
+
extra_rdoc_files: []
|
|
34
|
+
files:
|
|
35
|
+
- ".gitignore"
|
|
36
|
+
- ".gitmodules"
|
|
37
|
+
- CHANGES.md
|
|
38
|
+
- README.md
|
|
53
39
|
- Rakefile
|
|
54
|
-
- TODO
|
|
40
|
+
- TODO.md
|
|
55
41
|
- bin/source-tools
|
|
56
42
|
- lib/source-tools.rb
|
|
57
43
|
- lib/source-tools/bin.rb
|
|
@@ -62,7 +48,6 @@ files:
|
|
|
62
48
|
- lib/source-tools/tasks/ruby_magic_encoding.rb
|
|
63
49
|
- lib/source-tools/tasks/strip.rb
|
|
64
50
|
- lib/source-tools/tasks/template.rb
|
|
65
|
-
- lib/source-tools/templates/t.bashrc.erb
|
|
66
51
|
- lib/source-tools/templates/t.config/fish/config.fish.erb
|
|
67
52
|
- lib/source-tools/templates/t.gemrc.erb
|
|
68
53
|
- lib/source-tools/templates/t.git/hooks/post-receive.erb
|
|
@@ -74,53 +59,33 @@ files:
|
|
|
74
59
|
- lib/source-tools/templates/tRakefile.erb
|
|
75
60
|
- lib/source-tools/templates/tconfig/mime.types.erb
|
|
76
61
|
- lib/source-tools/templates/tconfig/nginx.conf.erb
|
|
62
|
+
- lib/source-tools/templates/tnginx-for-unicorn.conf.erb
|
|
77
63
|
- lib/source-tools/version.rb
|
|
78
64
|
- source-tools.gemspec
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
- tasks/rdoc.rake
|
|
86
|
-
- tasks/rubyforge.rake
|
|
87
|
-
- tasks/setup.rb
|
|
88
|
-
- tasks/spec.rake
|
|
89
|
-
- tasks/svn.rake
|
|
90
|
-
- tasks/test.rake
|
|
91
|
-
- tasks/zentest.rake
|
|
92
|
-
has_rdoc: true
|
|
93
|
-
homepage: http://github.com/godfat/source-tools
|
|
94
|
-
licenses: []
|
|
95
|
-
|
|
65
|
+
- task/README.md
|
|
66
|
+
- task/gemgem.rb
|
|
67
|
+
homepage: https://github.com/godfat/source-tools
|
|
68
|
+
licenses:
|
|
69
|
+
- Apache License 2.0
|
|
70
|
+
metadata: {}
|
|
96
71
|
post_install_message:
|
|
97
|
-
rdoc_options:
|
|
98
|
-
|
|
99
|
-
- --inline-source
|
|
100
|
-
- --line-numbers
|
|
101
|
-
- --promiscuous
|
|
102
|
-
- --main
|
|
103
|
-
- README
|
|
104
|
-
require_paths:
|
|
72
|
+
rdoc_options: []
|
|
73
|
+
require_paths:
|
|
105
74
|
- lib
|
|
106
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
108
77
|
- - ">="
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
requirements:
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: '0'
|
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
114
82
|
- - ">="
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version:
|
|
117
|
-
version:
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: '0'
|
|
118
85
|
requirements: []
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
rubygems_version: 1.3.5
|
|
86
|
+
rubyforge_project:
|
|
87
|
+
rubygems_version: 2.4.2
|
|
122
88
|
signing_key:
|
|
123
|
-
specification_version:
|
|
89
|
+
specification_version: 4
|
|
124
90
|
summary: source code tools collection
|
|
125
91
|
test_files: []
|
|
126
|
-
|
data/CHANGES
DELETED
data/tasks/ann.rake
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
begin
|
|
3
|
-
require 'bones/smtp_tls'
|
|
4
|
-
rescue LoadError
|
|
5
|
-
require 'net/smtp'
|
|
6
|
-
end
|
|
7
|
-
require 'time'
|
|
8
|
-
|
|
9
|
-
namespace :ann do
|
|
10
|
-
|
|
11
|
-
# A prerequisites task that all other tasks depend upon
|
|
12
|
-
task :prereqs
|
|
13
|
-
|
|
14
|
-
file PROJ.ann.file do
|
|
15
|
-
ann = PROJ.ann
|
|
16
|
-
puts "Generating #{ann.file}"
|
|
17
|
-
File.open(ann.file,'w') do |fd|
|
|
18
|
-
fd.puts("#{PROJ.name} version #{PROJ.version}")
|
|
19
|
-
fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
|
|
20
|
-
fd.puts(" #{PROJ.url}") if PROJ.url.valid?
|
|
21
|
-
fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
|
|
22
|
-
fd.puts
|
|
23
|
-
fd.puts("== DESCRIPTION")
|
|
24
|
-
fd.puts
|
|
25
|
-
fd.puts(PROJ.description)
|
|
26
|
-
fd.puts
|
|
27
|
-
fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
|
|
28
|
-
fd.puts
|
|
29
|
-
ann.paragraphs.each do |p|
|
|
30
|
-
fd.puts "== #{p.upcase}"
|
|
31
|
-
fd.puts
|
|
32
|
-
fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
|
|
33
|
-
fd.puts
|
|
34
|
-
end
|
|
35
|
-
fd.puts ann.text if ann.text
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
desc "Create an announcement file"
|
|
40
|
-
task :announcement => ['ann:prereqs', PROJ.ann.file]
|
|
41
|
-
|
|
42
|
-
desc "Send an email announcement"
|
|
43
|
-
task :email => ['ann:prereqs', PROJ.ann.file] do
|
|
44
|
-
ann = PROJ.ann
|
|
45
|
-
from = ann.email[:from] || Array(PROJ.authors).first || PROJ.email
|
|
46
|
-
to = Array(ann.email[:to])
|
|
47
|
-
|
|
48
|
-
### build a mail header for RFC 822
|
|
49
|
-
rfc822msg = "From: #{from}\n"
|
|
50
|
-
rfc822msg << "To: #{to.join(',')}\n"
|
|
51
|
-
rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
|
|
52
|
-
rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
|
|
53
|
-
rfc822msg << "\n"
|
|
54
|
-
rfc822msg << "Date: #{Time.new.rfc822}\n"
|
|
55
|
-
rfc822msg << "Message-Id: "
|
|
56
|
-
rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
|
|
57
|
-
rfc822msg << File.read(ann.file)
|
|
58
|
-
|
|
59
|
-
params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
|
|
60
|
-
ann.email[key]
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
params[3] = PROJ.email if params[3].nil?
|
|
64
|
-
|
|
65
|
-
if params[4].nil?
|
|
66
|
-
STDOUT.write "Please enter your e-mail password (#{params[3]}): "
|
|
67
|
-
params[4] = STDIN.gets.chomp
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
### send email
|
|
71
|
-
Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
|
|
72
|
-
end
|
|
73
|
-
end # namespace :ann
|
|
74
|
-
|
|
75
|
-
desc 'Alias to ann:announcement'
|
|
76
|
-
task :ann => 'ann:announcement'
|
|
77
|
-
|
|
78
|
-
CLOBBER << PROJ.ann.file
|
|
79
|
-
|
|
80
|
-
# EOF
|