public
Description: CGIAlt is a re-implementation of cgi.rb
Homepage: http://cgialt.rubyforge.org/
Clone URL: git://github.com/kwatch/cgialt.git
cgialt / Rookbook.yaml
100644 133 lines (120 sloc) 3.639 kb
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
##
## rook --project=cgialt :package
##
 
 
properties:
 
  - project: cgialt
  - release: '1.0.0'
  - copyright: copyright(c) 2007-2008 kuwata-lab.com all rights reserved.
  - rubylib: ''
 
 
recipes:
 
  - product: :package
    method*: |
## create directory
base = "$(project)-$(release)"
dir = "build/#{base}"
rm_rf dir
mkdir_p dir
## copy files
cp %w[README.txt CHANGES.txt bench.rb bench.fcgi], dir
cp %w[$(project).gemspec setup.rb fcgi.README fcgi.README.signals], dir
store 'lib/$(project)/**/*.rb', 'lib/$(project).rb', 'test/test_cgi_*.rb', 'test/testdata/**/*', dir
#rm_rf "#{dir}/lib/cgi/request.rb"
File.open("#{dir}/cgi.rb", 'w') do |f|
f << "require 'cgialt'\n"
f << "begin\n"
f << " require 'cgiext'\n"
f << "rescue LoadError\n"
f << "end\n"
end
File.open("#{dir}/fcgi.rb", 'w') do |f|
f << "require 'cgialt/fcgi'\n"
end
## edit files
chdir dir do
edit '**/*' do |s|
s.gsub!(/\$Release:.*?\$/, "$Release: $(release) $")
s.gsub!(/\$Release\$/, "$(release)")
s.gsub!(/\$Copyright\$/, '$(copyright)')
s
end
end
## create *.gem
require 'rubygems'
require 'rubygems/gem_runner'
chdir dir do
Gem.manage_gems
Gem::GemRunner.new.run ['build', '$(project).gemspec']
mv '$(project)-$(release).gem', '..'
end
## create *.tar.gz
cd 'build' do
tar_czf "#{base}.tar.gz", base
end
 
  - product: :test
    method*: |
#if @rubylib && !@rubylib.empty?
# ENV['RUBYLIB'] = @rubylib
#end
ENV['DEBUG'] = '1'
ENV['CGI'] = 'cgialt'
ENV['RUBYLIB'] = 'lib'
puts "DEBUG=1 CGI=cgialt RUBYLIB=lib testrb test"
sys "testrb test"
#for filename in Dir.glob('test/test_cgi_*.rb')
# filename =~ /_cgi_(.*)\.rb/
# puts "====== #{$1} ======"
# sys "ruby #{filename}"
#end
 
  - product: :index
    ingreds: [ website/index.html ]
 
  - product: website/index.html
    ingreds: [ README.txt ]
    method*: |
filename = @ingred
projname = 'CGIAlt'
download_url = 'http://rubyforge.org/frs/?group_id=5036'
tmpfile = @byprod
sys "rd2 #{filename} #{tmpfile} | tidy -q -i -wrap 9999 -ashtml > #{@product}"
edit @product do |content|
body = (content =~ /<body>.*<\/body>/m) && $&
body.gsub! /<h1>.*<\/h1>/, "<h1>#{projname}: README.txt</h1>"
body.gsub! /README-$(project)/, 'README'
body.gsub! /<!-- RDLabel: ".*" -->/, ''
body.gsub! /(<h\d>)<a name=".*?" id=".*?">/, '\1'
body.gsub! /<\/a>(<\/h\d>)/, '\1'
body.gsub! /\$Release\$/, '$(release)'
body.gsub! /\$Release:.*?\$/, '$Release: $(release) $'
body.gsub! /\$Copyright\$/, '$(copyright)'
body.sub! /http:\/\/rubyforge.org\/projects\/$(project)\//, '<a href="\&">\&</a><br />'
body.sub! /http:\/\/$(project).rubyforge.org\//, '<a href="\&">\&</a><br />'
body.sub! /http:\/\/github.com\/kwatch\/$(project)\//, '<a href="\&">\&</a><br />'
body.sub! /$(project)-$(release)\.tar\.gz/, "<a href=\"#{download_url}\">\\&</a>"
body.gsub! /(with|install) (#{projname})/, '\1 <a href="http://rubyforge.org/projects/$(project)/">\2</a>'
html = <<END
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>#{projname}: README.txt</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
#{body}
</html>
END
content[0..-1] = html
content
end
 
  - product: :try
    method*: |
ENV['DEBUG'] = 'yes'
sys "ruby -e 'p ENV[%q|DEBUG|]'"
 
  - product: :clean
    method*: |
rm_rf '$(project)-?.?.*'
 
  - product: :cgi
    method*: |
if test(?f, 'cgi.rb')
mv 'cgi.rb', 'cgi_rb'
elsif test(?f, 'cgi_rb')
mv 'cgi_rb', 'cgi.rb'
end