-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
186 lines (146 loc) · 4.2 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# Rakefile for currency -*- ruby -*-
# Adapted from RubyGems/Rakefile
# For release
"
rake make_manifest
rake update_version
rake test
svn status
rake package
rake release VERSION=x.x.x
rake svn_release
rake publish_docs
rake announce
"
#################################################################
require 'rubygems'
require 'hoe'
PKG_Name = 'Currency'
PKG_DESCRIPTION = %{Currency models currencies, monetary values, foreign exchanges rates.
Pulls live and historical rates from http://xe.com/, http://newyorkfed.org/, http://thefinancials.com/.
Can store/retrieve historical rate data from database using ActiveRecord.
Can store/retrieve Money values using ActiveRecord.
For more details, see:
http://rubyforge.org/projects/currency/
http://currency.rubyforge.org/
http://currency.rubyforge.org/files/README_txt.html
}
#################################################################
# Release notes
#
def get_release_notes(relfile = "Releases.txt")
release = nil
notes = [ ]
File.open(relfile) do |f|
while ! f.eof && line = f.readline
if md = /^== Release ([\d\.]+)/i.match(line)
release = md[1]
notes << line
break
end
end
while ! f.eof && line = f.readline
if md = /^== Release ([\d\.]+)/i.match(line)
break
end
notes << line
end
end
[ release, notes.join('') ]
end
#################################################################
PKG_NAME = PKG_Name.gsub(/[a-z][A-Z]/) {|x| "#{x[0,1]}_#{x[1,1]}"}.downcase
PKG_SVN_ROOT="svn+ssh://rubyforge.org/var/svn/#{PKG_NAME}/#{PKG_NAME}"
release, release_notes = get_release_notes
hoe = Hoe.new(PKG_Name.downcase, release) do |p|
p.author = 'Kurt Stephens'
p.description = PKG_DESCRIPTION
p.email = "ruby-#{PKG_NAME}@umleta.com"
p.summary = p.description
p.changes = release_notes
p.url = "http://rubyforge.org/projects/#{PKG_NAME}"
p.test_globs = ['test/**/*.rb']
p.remote_rdoc_dir = '.'
end
PKG_VERSION = hoe.version
#################################################################
# Version file
#
def announce(msg='')
STDERR.puts msg
end
version_rb = "lib/#{PKG_NAME}/#{PKG_NAME}_version.rb"
task :update_version do
announce "Updating #{PKG_Name} version to #{PKG_VERSION}: #{version_rb}"
open(version_rb, "w") do |f|
f.puts "module #{PKG_Name}"
f.puts " #{PKG_Name}Version = '#{PKG_VERSION}'"
f.puts "end"
f.puts "# DO NOT EDIT"
f.puts "# This file is auto-generated by build scripts."
f.puts "# See: rake update_version"
end
if ENV['RELTEST']
announce "Release Task Testing, skipping commiting of new version"
else
sh %{svn commit -m "Updated to version #{PKG_VERSION}" #{version_rb} Releases.txt ChangeLog Rakefile Manifest.txt}
end
end
task version_rb => :update_version
#################################################################
# SVN
#
task :svn_release do
sh %{svn cp -m 'Release #{PKG_VERSION}' . #{PKG_SVN_ROOT}/release/#{PKG_VERSION}}
end
# task :test => :update_version
# Misc Tasks ---------------------------------------------------------
def egrep(pattern)
Dir['**/*.rb'].each do |fn|
count = 0
open(fn) do |f|
while line = f.gets
count += 1
if line =~ pattern
puts "#{fn}:#{count}:#{line}"
end
end
end
end
end
desc "Look for TODO and FIXME tags in the code"
task :todo do
egrep /#.*(FIXME|TODO|TBD)/
end
desc "Look for Debugging print lines"
task :dbg do
egrep /\bDBG|\bbreakpoint\b/
end
desc "List all ruby files"
task :rubyfiles do
puts Dir['**/*.rb'].reject { |fn| fn =~ /^pkg/ }
puts Dir['bin/*'].reject { |fn| fn =~ /CVS|.svn|(~$)|(\.rb$)/ }
end
task :make_manifest do
open("Manifest.txt", "w") do |f|
f.puts Dir['**/*'].reject { |fn|
fn == 'email.txt' ||
! test(?f, fn) ||
fn =~ /CVS|.svn|([#~]$)|(.gem$)|(^pkg\/)|(^doc\/)/
}.sort.join("\n") + "\n"
end
end
# task :docs => :rcov_test
desc "Run tests under rcov"
task :rcov_test do
test = ENV['test'] || 'test/**/*.rb'
rcov_opts = "-Ilib --html"
rcov_opts << " -i '\\Atest/,\\Alib/'"
tests = Dir[test].sort
tests.each do | t |
out_dir = "doc/rcov/#{t}"
sh "mkdir -p #{out_dir}"
sh "rm -rf #{out_dir}/*"
sh "rcov #{rcov_opts} -o #{out_dir} #{t}"
end
end