ramaze 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +360 -0
- data/bin/ramaze +152 -0
- data/doc/CHANGELOG +2021 -0
- data/doc/COPYING +56 -0
- data/doc/COPYING.ja +51 -0
- data/doc/README +275 -0
- data/doc/TODO +33 -0
- data/doc/allison/LICENSE +184 -0
- data/doc/allison/README +37 -0
- data/doc/allison/allison.css +300 -0
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/allison.js +307 -0
- data/doc/allison/allison.rb +287 -0
- data/doc/allison/cache/BODY +588 -0
- data/doc/allison/cache/CLASS_INDEX +4 -0
- data/doc/allison/cache/CLASS_PAGE +1 -0
- data/doc/allison/cache/FILE_INDEX +4 -0
- data/doc/allison/cache/FILE_PAGE +1 -0
- data/doc/allison/cache/FONTS +1 -0
- data/doc/allison/cache/FR_INDEX_BODY +1 -0
- data/doc/allison/cache/IMGPATH +1 -0
- data/doc/allison/cache/INDEX +1 -0
- data/doc/allison/cache/JAVASCRIPT +307 -0
- data/doc/allison/cache/METHOD_INDEX +4 -0
- data/doc/allison/cache/METHOD_LIST +1 -0
- data/doc/allison/cache/SRC_PAGE +1 -0
- data/doc/allison/cache/STYLE +322 -0
- data/doc/allison/cache/URL +1 -0
- data/examples/blog/main.rb +16 -0
- data/examples/blog/public/screen.css +106 -0
- data/examples/blog/src/controller.rb +50 -0
- data/examples/blog/src/element.rb +53 -0
- data/examples/blog/src/model.rb +29 -0
- data/examples/blog/template/edit.xhtml +6 -0
- data/examples/blog/template/index.xhtml +24 -0
- data/examples/blog/template/new.xhtml +5 -0
- data/examples/blog/template/view.xhtml +15 -0
- data/examples/blog/test/tc_entry.rb +18 -0
- data/examples/caching.rb +23 -0
- data/examples/element.rb +40 -0
- data/examples/hello.rb +23 -0
- data/examples/simple.rb +60 -0
- data/examples/templates/template/external.haml +21 -0
- data/examples/templates/template/external.liquid +28 -0
- data/examples/templates/template/external.mab +27 -0
- data/examples/templates/template/external.rhtml +29 -0
- data/examples/templates/template/external.rmze +24 -0
- data/examples/templates/template_erubis.rb +50 -0
- data/examples/templates/template_haml.rb +48 -0
- data/examples/templates/template_liquid.rb +64 -0
- data/examples/templates/template_markaby.rb +52 -0
- data/examples/templates/template_ramaze.rb +49 -0
- data/examples/whywiki/main.rb +56 -0
- data/examples/whywiki/template/edit.xhtml +14 -0
- data/examples/whywiki/template/show.xhtml +17 -0
- data/lib/proto/conf/benchmark.yaml +35 -0
- data/lib/proto/conf/debug.yaml +34 -0
- data/lib/proto/conf/live.yaml +33 -0
- data/lib/proto/conf/silent.yaml +31 -0
- data/lib/proto/conf/stage.yaml +33 -0
- data/lib/proto/main.rb +18 -0
- data/lib/proto/public/404.jpg +0 -0
- data/lib/proto/public/css/coderay.css +105 -0
- data/lib/proto/public/css/ramaze_error.css +42 -0
- data/lib/proto/public/error.xhtml +74 -0
- data/lib/proto/public/favicon.ico +0 -0
- data/lib/proto/public/js/jquery.js +1923 -0
- data/lib/proto/public/ramaze.png +0 -0
- data/lib/proto/src/controller/main.rb +7 -0
- data/lib/proto/src/element/page.rb +16 -0
- data/lib/proto/src/model.rb +5 -0
- data/lib/proto/template/index.xhtml +6 -0
- data/lib/ramaze.rb +317 -0
- data/lib/ramaze/adapter/mongrel.rb +111 -0
- data/lib/ramaze/adapter/webrick.rb +161 -0
- data/lib/ramaze/cache.rb +11 -0
- data/lib/ramaze/cache/memcached.rb +52 -0
- data/lib/ramaze/cache/memory.rb +6 -0
- data/lib/ramaze/cache/yaml_store.rb +37 -0
- data/lib/ramaze/controller.rb +10 -0
- data/lib/ramaze/dispatcher.rb +315 -0
- data/lib/ramaze/error.rb +11 -0
- data/lib/ramaze/gestalt.rb +108 -0
- data/lib/ramaze/global.rb +120 -0
- data/lib/ramaze/helper.rb +32 -0
- data/lib/ramaze/helper/aspect.rb +189 -0
- data/lib/ramaze/helper/auth.rb +120 -0
- data/lib/ramaze/helper/cache.rb +52 -0
- data/lib/ramaze/helper/feed.rb +135 -0
- data/lib/ramaze/helper/form.rb +204 -0
- data/lib/ramaze/helper/link.rb +80 -0
- data/lib/ramaze/helper/redirect.rb +48 -0
- data/lib/ramaze/helper/stack.rb +67 -0
- data/lib/ramaze/http_status.rb +66 -0
- data/lib/ramaze/inform.rb +166 -0
- data/lib/ramaze/snippets.rb +5 -0
- data/lib/ramaze/snippets/hash/keys_to_sym.rb +19 -0
- data/lib/ramaze/snippets/kernel/aquire.rb +22 -0
- data/lib/ramaze/snippets/kernel/autoreload.rb +79 -0
- data/lib/ramaze/snippets/kernel/caller_lines.rb +58 -0
- data/lib/ramaze/snippets/kernel/constant.rb +24 -0
- data/lib/ramaze/snippets/kernel/rescue_require.rb +12 -0
- data/lib/ramaze/snippets/kernel/self_method.rb +41 -0
- data/lib/ramaze/snippets/kernel/silently.rb +13 -0
- data/lib/ramaze/snippets/object/traits.rb +60 -0
- data/lib/ramaze/snippets/openstruct/temp.rb +10 -0
- data/lib/ramaze/snippets/string/DIVIDE.rb +16 -0
- data/lib/ramaze/snippets/string/camel_case.rb +14 -0
- data/lib/ramaze/snippets/string/snake_case.rb +12 -0
- data/lib/ramaze/snippets/symbol/to_proc.rb +14 -0
- data/lib/ramaze/snippets/thread/deadQUESTIONMARK.rb +11 -0
- data/lib/ramaze/store/default.rb +48 -0
- data/lib/ramaze/template.rb +102 -0
- data/lib/ramaze/template/amrita2.rb +40 -0
- data/lib/ramaze/template/erubis.rb +58 -0
- data/lib/ramaze/template/haml.rb +65 -0
- data/lib/ramaze/template/haml/actionview_stub.rb +20 -0
- data/lib/ramaze/template/liquid.rb +74 -0
- data/lib/ramaze/template/markaby.rb +68 -0
- data/lib/ramaze/template/ramaze.rb +177 -0
- data/lib/ramaze/template/ramaze/element.rb +166 -0
- data/lib/ramaze/template/ramaze/morpher.rb +156 -0
- data/lib/ramaze/tool/create.rb +70 -0
- data/lib/ramaze/tool/tidy.rb +71 -0
- data/lib/ramaze/trinity.rb +38 -0
- data/lib/ramaze/trinity/request.rb +244 -0
- data/lib/ramaze/trinity/response.rb +41 -0
- data/lib/ramaze/trinity/session.rb +129 -0
- data/lib/ramaze/version.rb +14 -0
- data/spec/spec_all.rb +73 -0
- data/spec/spec_helper.rb +215 -0
- data/spec/tc_adapter_mongrel.rb +24 -0
- data/spec/tc_adapter_webrick.rb +22 -0
- data/spec/tc_cache.rb +79 -0
- data/spec/tc_controller.rb +39 -0
- data/spec/tc_element.rb +100 -0
- data/spec/tc_error.rb +23 -0
- data/spec/tc_gestalt.rb +90 -0
- data/spec/tc_global.rb +46 -0
- data/spec/tc_helper_aspect.rb +65 -0
- data/spec/tc_helper_auth.rb +61 -0
- data/spec/tc_helper_cache.rb +81 -0
- data/spec/tc_helper_feed.rb +129 -0
- data/spec/tc_helper_form.rb +146 -0
- data/spec/tc_helper_link.rb +58 -0
- data/spec/tc_helper_redirect.rb +51 -0
- data/spec/tc_helper_stack.rb +55 -0
- data/spec/tc_morpher.rb +90 -0
- data/spec/tc_params.rb +84 -0
- data/spec/tc_request.rb +111 -0
- data/spec/tc_session.rb +56 -0
- data/spec/tc_store.rb +25 -0
- data/spec/tc_template_amrita2.rb +34 -0
- data/spec/tc_template_erubis.rb +41 -0
- data/spec/tc_template_haml.rb +44 -0
- data/spec/tc_template_liquid.rb +98 -0
- data/spec/tc_template_markaby.rb +74 -0
- data/spec/tc_template_ramaze.rb +54 -0
- data/spec/tc_tidy.rb +14 -0
- data/spec/template/amrita2/data.html +6 -0
- data/spec/template/amrita2/index.html +1 -0
- data/spec/template/amrita2/sum.html +1 -0
- data/spec/template/erubis/sum.rhtml +1 -0
- data/spec/template/haml/index.haml +5 -0
- data/spec/template/haml/with_vars.haml +4 -0
- data/spec/template/liquid/index.liquid +1 -0
- data/spec/template/liquid/products.liquid +45 -0
- data/spec/template/markaby/external.mab +8 -0
- data/spec/template/markaby/sum.mab +1 -0
- data/spec/template/ramaze/file_only.rmze +1 -0
- data/spec/template/ramaze/index.rmze +1 -0
- data/spec/template/ramaze/nested.rmze +1 -0
- data/spec/template/ramaze/sum.rmze +1 -0
- metadata +317 -0
data/Rakefile
ADDED
@@ -0,0 +1,360 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/packagetask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/rdoctask'
|
7
|
+
require 'rake/contrib/rubyforgepublisher'
|
8
|
+
require 'fileutils'
|
9
|
+
require 'pp'
|
10
|
+
include FileUtils
|
11
|
+
|
12
|
+
$:.unshift File.join(File.dirname(__FILE__), "lib")
|
13
|
+
require 'ramaze/version'
|
14
|
+
|
15
|
+
AUTHOR = "manveru"
|
16
|
+
EMAIL = "m.fellinger@gmail.com"
|
17
|
+
DESCRIPTION = "Ramaze tries to be a very simple Webframework without the voodoo"
|
18
|
+
HOMEPATH = 'http://ramaze.rubyforge.org'
|
19
|
+
BIN_FILES = %w( ramaze )
|
20
|
+
|
21
|
+
BASEDIR = File.dirname(__FILE__)
|
22
|
+
|
23
|
+
NAME = "ramaze"
|
24
|
+
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
25
|
+
VERS = ENV['VERSION'] || (Ramaze::VERSION + (REV ? ".#{REV}" : ""))
|
26
|
+
CLEAN.include %w[
|
27
|
+
**/.*.sw?
|
28
|
+
*.gem
|
29
|
+
.config
|
30
|
+
**/*~
|
31
|
+
**/{data.db,cache.yaml}
|
32
|
+
pkg
|
33
|
+
rdoc
|
34
|
+
]
|
35
|
+
RDOC_OPTS = %w[
|
36
|
+
--all
|
37
|
+
--quiet
|
38
|
+
--op rdoc
|
39
|
+
--line-numbers
|
40
|
+
--inline-source
|
41
|
+
--main "doc/README"
|
42
|
+
--opname index.html
|
43
|
+
--title "Ramaze documentation"
|
44
|
+
--exclude "^(_darcs|spec|examples|bin|pkg)/"
|
45
|
+
--exclude "lib/proto"
|
46
|
+
--include "doc"
|
47
|
+
--accessor "trait"
|
48
|
+
]
|
49
|
+
|
50
|
+
POST_INSTALL_MESSAGE = %{
|
51
|
+
#{'=' * 60}
|
52
|
+
|
53
|
+
Thank you for installing Ramaze!
|
54
|
+
You can now do following:
|
55
|
+
|
56
|
+
* Create a new project using the `ramaze' command:
|
57
|
+
ramaze --create yourproject
|
58
|
+
|
59
|
+
* Browse and try the Examples in
|
60
|
+
#{File.join(Gem.path, 'gems', 'ramaze-' + VERS, 'examples')}
|
61
|
+
|
62
|
+
#{'=' * 60}
|
63
|
+
}.strip
|
64
|
+
|
65
|
+
desc "Packages up ramaze gem."
|
66
|
+
task :default => [:test]
|
67
|
+
|
68
|
+
desc "clean up temporary files and gems"
|
69
|
+
task :package => [:clean]
|
70
|
+
|
71
|
+
spec =
|
72
|
+
Gem::Specification.new do |s|
|
73
|
+
s.name = NAME
|
74
|
+
s.version = VERS
|
75
|
+
s.platform = Gem::Platform::RUBY
|
76
|
+
s.has_rdoc = true
|
77
|
+
s.extra_rdoc_files = ["doc/TODO", "doc/README", "doc/CHANGELOG"]
|
78
|
+
s.rdoc_options += RDOC_OPTS
|
79
|
+
s.summary = DESCRIPTION
|
80
|
+
s.description = DESCRIPTION
|
81
|
+
s.author = AUTHOR
|
82
|
+
s.email = EMAIL
|
83
|
+
s.homepage = HOMEPATH
|
84
|
+
s.executables = BIN_FILES
|
85
|
+
s.bindir = "bin"
|
86
|
+
s.require_path = "lib"
|
87
|
+
s.post_install_message = POST_INSTALL_MESSAGE
|
88
|
+
|
89
|
+
s.add_dependency('rake', '>=0.7.1')
|
90
|
+
s.add_dependency('rspec', '>=0.7.5.1')
|
91
|
+
#s.required_ruby_version = '>= 1.8.2'
|
92
|
+
|
93
|
+
s.files = %w(doc/COPYING doc/TODO doc/README doc/CHANGELOG Rakefile) +
|
94
|
+
Dir["{examples,bin,doc,spec,lib}/**/*"]
|
95
|
+
|
96
|
+
# s.extensions = FileList["ext/**/extconf.rb"].to_a
|
97
|
+
end
|
98
|
+
|
99
|
+
Rake::GemPackageTask.new(spec) do |p|
|
100
|
+
p.need_tar = true
|
101
|
+
p.gem_spec = spec
|
102
|
+
end
|
103
|
+
|
104
|
+
desc "package and install ramaze"
|
105
|
+
task :install do
|
106
|
+
name = "#{NAME}-#{VERS}.gem"
|
107
|
+
sh %{rake package}
|
108
|
+
sh %{sudo gem install pkg/#{name}}
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "uninstall the ramaze gem"
|
112
|
+
task :uninstall => [:clean] do
|
113
|
+
sh %{sudo gem uninstall #{NAME}}
|
114
|
+
end
|
115
|
+
|
116
|
+
desc "sanitize the code and darcs record"
|
117
|
+
task :record => ['fix-end-spaces', 'add-copyright'] do
|
118
|
+
system("darcs", "record")
|
119
|
+
end
|
120
|
+
|
121
|
+
desc "create the doc/changes.xml"
|
122
|
+
task 'changes-xml' do
|
123
|
+
File.open('doc/changes.xml', 'w+') do |f|
|
124
|
+
f.print(`darcs changes --xml`)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
desc "create the doc/changes.txt"
|
129
|
+
task 'changes-text' do
|
130
|
+
File.open('doc/changes.txt', 'w+') do |f|
|
131
|
+
f.print(`darcs changes --human-readable`)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
desc "create both doc/changes.txt and doc/changes.xml"
|
136
|
+
task :changes => ['changes-xml', 'changes-text'] do
|
137
|
+
puts(`darcs changes`.split("\n").first(25))
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "copy the doc/changes.txt to doc/CHANGELOG"
|
141
|
+
task :changelog => :changes do
|
142
|
+
cp 'doc/changes.txt', 'doc/CHANGELOG'
|
143
|
+
end
|
144
|
+
|
145
|
+
desc "add copyright to all .rb files in the distribution"
|
146
|
+
task 'add-copyright' do
|
147
|
+
puts "adding copyright to files that don't have it currently"
|
148
|
+
Dir['{lib,test}/**/*{.rb}'].each do |file|
|
149
|
+
lines = File.readlines(file).map{|l| l.chomp}
|
150
|
+
copyright = [
|
151
|
+
"# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com",
|
152
|
+
"# All files in this distribution are subject to the terms of the Ruby license."
|
153
|
+
]
|
154
|
+
unless lines.first(2) == copyright
|
155
|
+
puts "fixing #{file}"
|
156
|
+
File.open(file, 'w+') do |f|
|
157
|
+
(copyright + lines).each do |line|
|
158
|
+
f.puts(line)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
task :rcov_dir do
|
166
|
+
mkdir_p 'doc/output/tools/rcov/'
|
167
|
+
end
|
168
|
+
|
169
|
+
require 'spec/rake/spectask'
|
170
|
+
desc "Generate HTML coverage report"
|
171
|
+
Spec::Rake::SpecTask.new(:rcov_summary => :rcov_dir) do |t|
|
172
|
+
t.spec_files = FileList['test/tc_adapter.rb']
|
173
|
+
t.spec_opts = ["--format", "html"]
|
174
|
+
t.out = 'doc/output/tools/rcov/test.html'
|
175
|
+
t.fail_on_error = false
|
176
|
+
end
|
177
|
+
|
178
|
+
desc "run the specs and clean up afterwards"
|
179
|
+
task :test do
|
180
|
+
sh "ruby #{File.dirname(__FILE__)}/spec/spec_all.rb"
|
181
|
+
sh "rake clean"
|
182
|
+
end
|
183
|
+
|
184
|
+
desc "generate rdoc"
|
185
|
+
task :rdoc => :clean do
|
186
|
+
sh "rdoc #{RDOC_OPTS.join(' ')} lib doc doc/README doc/CHANGELOG"
|
187
|
+
end
|
188
|
+
|
189
|
+
desc "generate improved allison-rdoc"
|
190
|
+
task :allison => :clean do
|
191
|
+
opts = RDOC_OPTS
|
192
|
+
opts << %w[--template 'doc/allison/allison.rb']
|
193
|
+
sh "rdoc #{opts.join(' ')} lib doc/TODO doc/README doc/CHANGELOG"
|
194
|
+
end
|
195
|
+
|
196
|
+
desc "create bzip2 and tarball"
|
197
|
+
task :distribute => :gem do
|
198
|
+
sh "rm -rf pkg/ramaze-#{VERS}"
|
199
|
+
sh "mkdir -p pkg/ramaze-#{VERS}"
|
200
|
+
sh "cp -r {bin,doc,lib,examples,spec,Rakefile,setup.rb} pkg/ramaze-#{VERS}/"
|
201
|
+
|
202
|
+
Dir.chdir('pkg') do |pwd|
|
203
|
+
sh "tar -zcvf ramaze-#{VERS}.tar.gz ramaze-#{VERS}"
|
204
|
+
sh "tar -jcvf ramaze-#{VERS}.tar.bz2 ramaze-#{VERS}"
|
205
|
+
end
|
206
|
+
|
207
|
+
sh "rm -rf pkg/ramaze-#{VERS}"
|
208
|
+
end
|
209
|
+
|
210
|
+
desc "doc/README to html"
|
211
|
+
Rake::RDocTask.new('gen-readme2html') do |rd|
|
212
|
+
rd.options = %w[
|
213
|
+
--quiet
|
214
|
+
--opname readme.html
|
215
|
+
]
|
216
|
+
|
217
|
+
rd.rdoc_dir = 'readme'
|
218
|
+
rd.rdoc_files = ['doc/README']
|
219
|
+
rd.main = 'doc/README'
|
220
|
+
rd.title = "Ramaze documentation"
|
221
|
+
end
|
222
|
+
|
223
|
+
desc "doc/README to doc/README.html"
|
224
|
+
task 'readme2html' => 'gen-readme2html' do
|
225
|
+
FileUtils.cp('readme/files/doc/README.html', 'doc/README.html')
|
226
|
+
FileUtils.rm_rf('readme')
|
227
|
+
end
|
228
|
+
|
229
|
+
desc "list all still undocumented methods"
|
230
|
+
task :undocumented do
|
231
|
+
files = Dir[File.join('lib', '**', '*.rb')]
|
232
|
+
|
233
|
+
files.each do |file|
|
234
|
+
puts file
|
235
|
+
lines_till_here = []
|
236
|
+
lines = File.readlines(file).map{|line| line.chomp}
|
237
|
+
|
238
|
+
lines.each do |line|
|
239
|
+
if line =~ /def /
|
240
|
+
indent = line =~ /[^\s]/
|
241
|
+
e = lines_till_here.reverse.find{|l| l =~ /end/}
|
242
|
+
i = lines_till_here.reverse.index(e)
|
243
|
+
lines_till_here = lines_till_here[-(i + 1)..-1] if i
|
244
|
+
unless lines_till_here.any?{|l| l =~ /^\s*#/} or lines_till_here.empty?
|
245
|
+
puts lines_till_here
|
246
|
+
puts line
|
247
|
+
puts "#{' ' * indent}..."
|
248
|
+
puts e
|
249
|
+
end
|
250
|
+
lines_till_here.clear
|
251
|
+
end
|
252
|
+
lines_till_here << line
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
desc "show a todolist from all the TODO tags in the source"
|
258
|
+
task :todo do
|
259
|
+
files = Dir[File.join(BASEDIR, '{lib,test}', '**/*.rb')]
|
260
|
+
|
261
|
+
files.each do |file|
|
262
|
+
lastline = todo = comment = long_comment = false
|
263
|
+
|
264
|
+
File.readlines(file).each_with_index do |line, lineno|
|
265
|
+
lineno += 1
|
266
|
+
comment = line =~ /^\s*?#.*?$/
|
267
|
+
long_comment = line =~ /^=begin/
|
268
|
+
long_comment = line =~ /^=end/
|
269
|
+
todo = true if line =~ /TODO/ and (long_comment or comment)
|
270
|
+
todo = false if line.gsub('#', '').strip.empty?
|
271
|
+
todo = false unless comment or long_comment
|
272
|
+
if todo
|
273
|
+
unless lastline and lastline + 1 == lineno
|
274
|
+
puts
|
275
|
+
puts "vim #{file} +#{lineno}"
|
276
|
+
end
|
277
|
+
|
278
|
+
l = line.strip.gsub(/^#\s*/, '')
|
279
|
+
print ' ' unless l =~ /^-/
|
280
|
+
puts l
|
281
|
+
lastline = lineno
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
desc "generate doc/TODO from the TODO tags in the source"
|
288
|
+
task 'todolist' do
|
289
|
+
list = `rake todo`.split("\n")[2..-1]
|
290
|
+
tasks = {}
|
291
|
+
current = nil
|
292
|
+
|
293
|
+
list.map do |line|
|
294
|
+
if line =~ /TODO/ or line.empty?
|
295
|
+
elsif line =~ /^vim/
|
296
|
+
current = line.split[1]
|
297
|
+
tasks[current] = []
|
298
|
+
else
|
299
|
+
tasks[current] << line
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
lines = tasks.map{ |name, items| [name, items, ''] }.flatten
|
304
|
+
lines.pop
|
305
|
+
|
306
|
+
File.open(File.join('doc', 'TODO'), 'w+') do |f|
|
307
|
+
f.puts "This list is programmaticly generated by `rake todolist`"
|
308
|
+
f.puts "If you want to add/remove items from the list, change them at the"
|
309
|
+
f.puts "position specified in the list."
|
310
|
+
f.puts
|
311
|
+
f.puts(lines)
|
312
|
+
end
|
313
|
+
end
|
314
|
+
|
315
|
+
desc "show how many patches we made so far"
|
316
|
+
task :patchsize do
|
317
|
+
size = `darcs changes`.split("\n").reject{|l| l =~ /^\s/ or l.empty?}.size
|
318
|
+
puts "currently we got #{size} patches"
|
319
|
+
puts "shall i now play some Death-Metal for you?" if size == 666
|
320
|
+
end
|
321
|
+
|
322
|
+
desc "remove those annoying spaces at the end of lines"
|
323
|
+
task 'fix-end-spaces' do
|
324
|
+
Dir['{lib,test}/**/*.rb'].each do |file|
|
325
|
+
lines = File.readlines(file)
|
326
|
+
new = lines.dup
|
327
|
+
lines.each_with_index do |line, i|
|
328
|
+
if line =~ /\s+\n/
|
329
|
+
puts "fixing #{file}:#{i + 1}"
|
330
|
+
p line
|
331
|
+
new[i] = line.rstrip
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
unless new == lines
|
336
|
+
File.open(file, 'w+') do |f|
|
337
|
+
new.each do |line|
|
338
|
+
f.puts(line)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
desc "opens a simple readline that makes making requests easier"
|
346
|
+
task 'request' do
|
347
|
+
ARGV.clear
|
348
|
+
require 'open-uri'
|
349
|
+
require 'pp'
|
350
|
+
|
351
|
+
loop do
|
352
|
+
print 'do request? [enter] '
|
353
|
+
gets
|
354
|
+
begin
|
355
|
+
pp open('http://localhost:7000/xxx').read
|
356
|
+
rescue Object => ex
|
357
|
+
puts ex
|
358
|
+
end
|
359
|
+
end
|
360
|
+
end
|
data/bin/ramaze
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# = Synopsis
|
4
|
+
#
|
5
|
+
# The commandline tool to control ramaze
|
6
|
+
#
|
7
|
+
# = Usage
|
8
|
+
#
|
9
|
+
# ramaze [switches] startfile [arguments]
|
10
|
+
#
|
11
|
+
# --create:: create a new application based on proto
|
12
|
+
#
|
13
|
+
# -m, --mongrel:: use mongrel to process requests
|
14
|
+
# -w, --webrick:: the default
|
15
|
+
#
|
16
|
+
# -b, --benchmark:: inform about :error, :info, :debug, :benchmark
|
17
|
+
# -d, --debug:: inform about :error, info, :debug
|
18
|
+
# -t, --stage:: inform about :info, :error
|
19
|
+
# -l, --live:: inform about :error
|
20
|
+
# -s, --silent:: inform about nothing
|
21
|
+
#
|
22
|
+
# -a, --autoreload:: Set the interval at which autoreload searches
|
23
|
+
# for changes in your files
|
24
|
+
#
|
25
|
+
# -o, --host:: which host should ramaze listen for requests
|
26
|
+
# default is 0.0.0.0
|
27
|
+
# -p, --port:: what port should ramaze use, like 80 or 7000..7005
|
28
|
+
# default is 7000
|
29
|
+
#
|
30
|
+
# -n, --no-errorpage:: don't use the default errorpage of ramaze
|
31
|
+
# helpful if you want to make sure noone can
|
32
|
+
# ever see your code by accident or for testing
|
33
|
+
# --template-root:: set a custom template-root for the whole
|
34
|
+
# application, please note that ~ is not
|
35
|
+
# expanded to your home-directory
|
36
|
+
# -a, --autoreload=N:: set how frequent ramaze should search for
|
37
|
+
# updated files in your application
|
38
|
+
# -r, --run-loose:: don't take control after startup.
|
39
|
+
# this is useful for testcases.
|
40
|
+
# --cache:: use the simple caching based on the signature
|
41
|
+
# of your requests (experimental)
|
42
|
+
# --tidy:: run Tool::Tidy over text/html output
|
43
|
+
#
|
44
|
+
# -h, --help:: print this help
|
45
|
+
# -v, --version:: print the version
|
46
|
+
# -c, --copyright:: print the copyright
|
47
|
+
#
|
48
|
+
# Please report bugs to <m.fellinger at gmail.com>
|
49
|
+
#
|
50
|
+
# = Copyright
|
51
|
+
#
|
52
|
+
# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com
|
53
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
54
|
+
|
55
|
+
require 'ramaze'
|
56
|
+
|
57
|
+
runner = ARGV.find{|file| File.file?(file)} || 'main.rb'
|
58
|
+
|
59
|
+
begin
|
60
|
+
require 'getoptlong'
|
61
|
+
require 'rdoc/ri/ri_paths'
|
62
|
+
require 'rdoc/usage'
|
63
|
+
|
64
|
+
# memo:
|
65
|
+
# REQUIRED_ARGUMENT, NO_ARGUMENT, OPTIONAL_ARGUMENT
|
66
|
+
|
67
|
+
opts = GetoptLong.new *[
|
68
|
+
[ '--create', GetoptLong::REQUIRED_ARGUMENT ],
|
69
|
+
[ '--mongrel', '-m', GetoptLong::NO_ARGUMENT ],
|
70
|
+
[ '--webrick', '-w', GetoptLong::NO_ARGUMENT ],
|
71
|
+
|
72
|
+
[ '--debug', '-d', GetoptLong::NO_ARGUMENT ],
|
73
|
+
[ '--stage', '-t', GetoptLong::NO_ARGUMENT ],
|
74
|
+
[ '--live', '-l', GetoptLong::NO_ARGUMENT ],
|
75
|
+
[ '--silent', '-s', GetoptLong::NO_ARGUMENT ],
|
76
|
+
|
77
|
+
[ '--host', '-o', GetoptLong::REQUIRED_ARGUMENT ],
|
78
|
+
[ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
|
79
|
+
|
80
|
+
[ '--benchmark', '-b', GetoptLong::NO_ARGUMENT ],
|
81
|
+
[ '--no-errorpage', '-n', GetoptLong::NO_ARGUMENT ],
|
82
|
+
[ '--template-root', GetoptLong::REQUIRED_ARGUMENT ],
|
83
|
+
[ '--autoreload', '-a', GetoptLong::REQUIRED_ARGUMENT ],
|
84
|
+
[ '--run-loose', '-r', GetoptLong::NO_ARGUMENT ],
|
85
|
+
|
86
|
+
[ '--console', '-c', GetoptLong::NO_ARGUMENT ],
|
87
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
88
|
+
[ '--version', '-v', GetoptLong::NO_ARGUMENT ],
|
89
|
+
]
|
90
|
+
|
91
|
+
options = {:force_setup => true}
|
92
|
+
|
93
|
+
create = lambda do |app|
|
94
|
+
require 'ramaze/tool/create'
|
95
|
+
Ramaze::Tool::Create.create(app)
|
96
|
+
exit
|
97
|
+
end
|
98
|
+
|
99
|
+
opts.each do |opt, arg|
|
100
|
+
sopt = opt[2..-1].gsub('-', '_').intern
|
101
|
+
|
102
|
+
options[:inform_tags] = Set.new([:debug, :info, :error])
|
103
|
+
|
104
|
+
case sopt
|
105
|
+
when :create : create[arg]
|
106
|
+
when :help : RDoc::usage('Usage')
|
107
|
+
when :version : puts("ramaze #{Ramaze::Version}")
|
108
|
+
when :copyright : RDoc::usage('Copyright')
|
109
|
+
when :mongrel, :webrick : options[:adapter] = sopt
|
110
|
+
|
111
|
+
when :benchmark : options[:inform_tags] << :benchmark
|
112
|
+
when :debug : options
|
113
|
+
when :stage : options[:inform_tags].subtract [:debug]
|
114
|
+
when :live : options[:inform_tags].subtract [:info, :debug]
|
115
|
+
when :silent : options[:inform_tags].subtract options[:inform_tags]
|
116
|
+
|
117
|
+
when :host : options[:host] = arg
|
118
|
+
when :port : options[:port] = arg
|
119
|
+
|
120
|
+
when :no_errorpage : options[:error_page] = false
|
121
|
+
when :template_root : options[:template_root] = arg
|
122
|
+
when :autoreload : options[:autoreload] = arg.to_i
|
123
|
+
when :run_loose : options[:run_loose] = true
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
puts "running #{File.expand_path(runner)}"
|
128
|
+
require runner
|
129
|
+
|
130
|
+
if options.delete(:console)
|
131
|
+
options.merge!(:run_loose => true)
|
132
|
+
|
133
|
+
ARGV.clear # Avoid passing args to IRB
|
134
|
+
|
135
|
+
Ramaze.start(options)
|
136
|
+
|
137
|
+
require 'irb'
|
138
|
+
require 'irb/completion'
|
139
|
+
|
140
|
+
def exit
|
141
|
+
exit!
|
142
|
+
end
|
143
|
+
|
144
|
+
ENV['IRBRC'] = ".irbrc" if File.exists? ".irbrc"
|
145
|
+
IRB.start
|
146
|
+
exit!
|
147
|
+
else
|
148
|
+
Ramaze.start(options)
|
149
|
+
end
|
150
|
+
rescue LoadError => ex
|
151
|
+
puts ex
|
152
|
+
end
|