ramaze 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -259
- data/bin/ramaze +52 -25
- data/doc/AUTHORS +6 -0
- data/doc/CHANGELOG +1363 -42
- data/doc/INSTALL +1 -1
- data/doc/README +48 -35
- data/doc/README.html +637 -0
- data/doc/TODO +7 -16
- data/doc/allison/allison.css +6 -7
- data/doc/allison/allison.gif +0 -0
- data/doc/allison/cache/STYLE +1 -2
- data/doc/changes.txt +3375 -0
- data/doc/changes.xml +3378 -0
- data/doc/meta/announcement.txt +47 -0
- data/doc/meta/configuration.txt +179 -0
- data/doc/meta/internals.txt +111 -0
- data/doc/readme_chunks/features.txt +8 -16
- data/doc/readme_chunks/installing.txt +7 -1
- data/doc/tutorial/todolist.txt +2 -3
- data/examples/blog/main.rb +9 -8
- data/examples/blog/public/styles/blog.css +132 -0
- data/examples/blog/src/controller.rb +14 -41
- data/examples/blog/src/model.rb +12 -13
- data/examples/blog/src/view.rb +16 -0
- data/examples/blog/template/edit.xhtml +19 -8
- data/examples/blog/template/index.xhtml +14 -22
- data/examples/blog/template/new.xhtml +18 -5
- data/examples/caching.rb +5 -8
- data/examples/element.rb +3 -3
- data/examples/hello.rb +3 -5
- data/examples/simple.rb +4 -7
- data/examples/templates/template/external.haml +8 -7
- data/examples/templates/template/external.mab +11 -8
- data/examples/templates/template_amrita2.rb +4 -4
- data/examples/templates/template_erubis.rb +3 -3
- data/examples/templates/template_ezamar.rb +1 -2
- data/examples/templates/template_haml.rb +24 -23
- data/examples/templates/template_liquid.rb +3 -1
- data/examples/templates/template_markaby.rb +15 -9
- data/examples/todolist/src/element/page.rb +1 -1
- data/lib/proto/conf/benchmark.yaml +6 -20
- data/lib/proto/conf/debug.yaml +6 -19
- data/lib/proto/conf/live.yaml +7 -19
- data/lib/proto/conf/silent.yaml +6 -16
- data/lib/proto/conf/stage.yaml +6 -18
- data/lib/proto/public/error.zmr +2 -2
- data/lib/ramaze.rb +34 -72
- data/lib/ramaze/adapter.rb +21 -18
- data/lib/ramaze/adapter/mongrel.rb +0 -3
- data/lib/ramaze/adapter/webrick.rb +6 -6
- data/lib/ramaze/cache/memcached.rb +3 -0
- data/lib/ramaze/controller.rb +227 -183
- data/lib/ramaze/dispatcher.rb +34 -129
- data/lib/ramaze/dispatcher/action.rb +28 -0
- data/lib/ramaze/dispatcher/error.rb +43 -0
- data/lib/ramaze/dispatcher/file.rb +34 -0
- data/lib/ramaze/global.rb +89 -48
- data/lib/ramaze/helper/aspect.rb +8 -6
- data/lib/ramaze/helper/auth.rb +3 -3
- data/lib/ramaze/helper/cache.rb +2 -2
- data/lib/ramaze/helper/file.rb +14 -0
- data/lib/ramaze/helper/inform.rb +36 -0
- data/lib/ramaze/helper/link.rb +7 -3
- data/lib/ramaze/helper/markaby.rb +30 -0
- data/lib/ramaze/helper/redirect.rb +2 -0
- data/lib/ramaze/inform.rb +8 -182
- data/lib/ramaze/inform/analogger.rb +19 -0
- data/lib/ramaze/inform/growl.rb +28 -0
- data/lib/ramaze/inform/hub.rb +26 -0
- data/lib/ramaze/inform/informer.rb +92 -0
- data/lib/ramaze/inform/informing.rb +44 -0
- data/lib/ramaze/inform/syslog.rb +27 -0
- data/lib/ramaze/inform/xosd.rb +42 -0
- data/lib/ramaze/snippets.rb +6 -2
- data/lib/ramaze/snippets/object/traits.rb +13 -1
- data/lib/ramaze/snippets/ramaze/autoreload.rb +58 -2
- data/lib/ramaze/snippets/string/color.rb +27 -0
- data/lib/ramaze/snippets/string/each.rb +6 -0
- data/lib/ramaze/snippets/struct/fill.rb +15 -0
- data/lib/ramaze/template/ezamar.rb +13 -22
- data/lib/ramaze/template/ezamar/element.rb +12 -12
- data/lib/ramaze/template/liquid.rb +19 -18
- data/lib/ramaze/template/markaby.rb +37 -58
- data/lib/ramaze/tool/localize.rb +128 -0
- data/lib/ramaze/tool/tidy.rb +51 -21
- data/lib/ramaze/trinity.rb +3 -3
- data/lib/ramaze/trinity/request.rb +41 -23
- data/lib/ramaze/trinity/response.rb +10 -5
- data/lib/ramaze/trinity/session.rb +17 -3
- data/lib/ramaze/version.rb +2 -2
- data/rake_tasks/conf.rake +56 -0
- data/rake_tasks/gem.rake +44 -0
- data/rake_tasks/maintaince.rake +187 -0
- data/spec/all.rb +32 -0
- data/spec/examples/caching.rb +19 -0
- data/spec/examples/element.rb +15 -0
- data/spec/examples/hello.rb +11 -0
- data/spec/examples/simple.rb +51 -0
- data/spec/examples/templates/template_amrita2.rb +14 -0
- data/spec/examples/templates/template_erubis.rb +21 -0
- data/spec/examples/templates/template_ezamar.rb +22 -0
- data/spec/examples/templates/template_haml.rb +23 -0
- data/spec/examples/templates/template_liquid.rb +24 -0
- data/spec/examples/templates/template_markaby.rb +21 -0
- data/spec/helper.rb +81 -0
- data/spec/{spec_helper_context.rb → helper/context.rb} +1 -1
- data/spec/helper/layout.rb +55 -0
- data/spec/helper/mock_http.rb +66 -0
- data/spec/{spec_helper_requester.rb → helper/requester.rb} +0 -6
- data/spec/{spec_helper_simple_http.rb → helper/simple_http.rb} +57 -57
- data/spec/helper/wrap.rb +193 -0
- data/spec/{adapter_spec.rb → ramaze/adapter.rb} +7 -5
- data/spec/{tc_adapter_mongrel.rb → ramaze/adapter/mongrel.rb} +2 -2
- data/spec/{tc_adapter_webrick.rb → ramaze/adapter/webrick.rb} +2 -2
- data/spec/{tc_cache.rb → ramaze/cache.rb} +16 -16
- data/spec/ramaze/conf/locale_de.yaml +6 -0
- data/spec/ramaze/conf/locale_en.yaml +6 -0
- data/spec/ramaze/controller.rb +184 -0
- data/spec/ramaze/controller/template/greet.xhtml +1 -0
- data/spec/ramaze/controller/template_resolving.rb +54 -0
- data/spec/ramaze/dependencies.rb +16 -0
- data/spec/{tc_element.rb → ramaze/element.rb} +21 -19
- data/spec/ramaze/error.rb +64 -0
- data/spec/{tc_gestalt.rb → ramaze/gestalt.rb} +10 -10
- data/spec/{tc_global.rb → ramaze/global.rb} +7 -7
- data/spec/{tc_helper_aspect.rb → ramaze/helper/aspect.rb} +22 -14
- data/spec/{tc_helper_auth.rb → ramaze/helper/auth.rb} +9 -7
- data/spec/{tc_helper_cache.rb → ramaze/helper/cache.rb} +14 -24
- data/spec/{tc_helper_feed.rb → ramaze/helper/feed.rb} +12 -12
- data/spec/ramaze/helper/file.rb +17 -0
- data/spec/{tc_helper_flash.rb → ramaze/helper/flash.rb} +16 -17
- data/spec/{tc_helper_form.rb → ramaze/helper/form.rb} +25 -26
- data/spec/{tc_helper_link.rb → ramaze/helper/link.rb} +9 -9
- data/spec/{tc_helper_redirect.rb → ramaze/helper/redirect.rb} +11 -10
- data/spec/{tc_helper_stack.rb → ramaze/helper/stack.rb} +10 -11
- data/spec/ramaze/inform/informer.rb +40 -0
- data/spec/ramaze/inform/syslog.rb +10 -0
- data/spec/ramaze/localize.rb +40 -0
- data/spec/ramaze/morpher.rb +82 -0
- data/spec/ramaze/params.rb +124 -0
- data/spec/{public → ramaze/public}/error404.xhtml +0 -0
- data/spec/{public → ramaze/public}/favicon.ico +0 -0
- data/spec/{public → ramaze/public}/ramaze.png +0 -0
- data/spec/{public → ramaze/public}/test_download.css +0 -0
- data/spec/ramaze/request.rb +129 -0
- data/spec/{tc_request_mongrel.rb → ramaze/request/mongrel.rb} +2 -2
- data/spec/{tc_request_webrick.rb → ramaze/request/webrick.rb} +1 -1
- data/spec/{tc_session.rb → ramaze/session.rb} +18 -18
- data/spec/{tc_store.rb → ramaze/store/default.rb} +10 -10
- data/spec/{tc_store_yaml.rb → ramaze/store/yaml.rb} +9 -9
- data/spec/ramaze/template.rb +86 -0
- data/spec/{tc_template_amrita2.rb → ramaze/template/amrita2.rb} +5 -5
- data/spec/{template → ramaze/template}/amrita2/data.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/index.amrita +0 -0
- data/spec/{template → ramaze/template}/amrita2/sum.amrita +0 -0
- data/spec/{tc_template_erubis.rb → ramaze/template/erubis.rb} +9 -9
- data/spec/{template → ramaze/template}/erubis/sum.rhtml +0 -0
- data/spec/ramaze/template/ezamar.rb +62 -0
- data/spec/{template → ramaze/template}/ezamar/another/long/action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/combined.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/file_only.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/index.zmr +0 -0
- data/spec/ramaze/template/ezamar/nested.zmr +1 -0
- data/spec/{template → ramaze/template}/ezamar/some__long__action.zmr +0 -0
- data/spec/{template → ramaze/template}/ezamar/sum.zmr +0 -0
- data/spec/{tc_template_haml.rb → ramaze/template/haml.rb} +7 -7
- data/spec/{template → ramaze/template}/haml/index.haml +0 -0
- data/spec/{template → ramaze/template}/haml/with_vars.haml +0 -0
- data/spec/{tc_template_liquid.rb → ramaze/template/liquid.rb} +7 -7
- data/spec/{template → ramaze/template}/liquid/index.liquid +0 -0
- data/spec/{template → ramaze/template}/liquid/products.liquid +0 -0
- data/spec/ramaze/template/markaby.rb +59 -0
- data/spec/{template → ramaze/template}/markaby/external.mab +0 -0
- data/spec/{template → ramaze/template}/markaby/sum.mab +0 -0
- data/spec/ramaze/template/ramaze/external.test +1 -0
- data/spec/{tc_tidy.rb → ramaze/tidy.rb} +3 -3
- metadata +145 -81
- data/examples/blog/public/screen.css +0 -106
- data/examples/blog/src/element.rb +0 -58
- data/examples/blog/template/view.xhtml +0 -15
- data/examples/blog/test/tc_entry.rb +0 -18
- data/lib/proto/public/404.jpg +0 -0
- data/spec/request_tc_helper.rb +0 -135
- data/spec/spec_all.rb +0 -118
- data/spec/spec_helper.rb +0 -66
- data/spec/tc_controller.rb +0 -49
- data/spec/tc_dependencies.rb +0 -13
- data/spec/tc_error.rb +0 -43
- data/spec/tc_morpher.rb +0 -88
- data/spec/tc_params.rb +0 -125
- data/spec/tc_template_ezamar.rb +0 -64
- data/spec/tc_template_markaby.rb +0 -72
- data/spec/template/ezamar/nested.zmr +0 -1
@@ -4,13 +4,15 @@
|
|
4
4
|
require 'cgi'
|
5
5
|
require 'tmpdir'
|
6
6
|
require 'digest/md5'
|
7
|
+
require 'rack'
|
8
|
+
require 'rack/request'
|
7
9
|
|
8
10
|
module Ramaze
|
9
11
|
|
10
12
|
# The purpose of this class is to act as a simple wrapper for Rack::Request
|
11
13
|
# and provide some convinient methods for our own use.
|
12
14
|
|
13
|
-
|
15
|
+
module Request
|
14
16
|
class << self
|
15
17
|
|
16
18
|
# get the current request out of Thread.current[:request]
|
@@ -22,23 +24,16 @@ module Ramaze
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
# create a new instance of Request, takes the original Rack::Request
|
26
|
-
# instance
|
27
|
-
|
28
|
-
def initialize request = {}
|
29
|
-
@request = request
|
30
|
-
end
|
31
|
-
|
32
27
|
# shortcut for request.params[key]
|
33
28
|
|
34
29
|
def [](key)
|
35
|
-
params[key]
|
30
|
+
params[key.to_s]
|
36
31
|
end
|
37
32
|
|
38
33
|
# shortcut for request.params[key] = value
|
39
34
|
|
40
35
|
def []=(key, value)
|
41
|
-
params[key] = value
|
36
|
+
params[key.to_s] = value
|
42
37
|
end
|
43
38
|
|
44
39
|
# like Hash#values_at
|
@@ -47,6 +42,7 @@ module Ramaze
|
|
47
42
|
keys.map{|key| params[key] }
|
48
43
|
end
|
49
44
|
|
45
|
+
|
50
46
|
# the referer of the client or '/'
|
51
47
|
|
52
48
|
def referer
|
@@ -55,24 +51,46 @@ module Ramaze
|
|
55
51
|
|
56
52
|
alias referrer referer
|
57
53
|
|
58
|
-
def fullpath
|
59
|
-
path = script_name + path_info
|
60
|
-
path << "?" << query_string unless query_string.empty?
|
61
|
-
path
|
62
|
-
end
|
63
|
-
|
64
|
-
def env
|
65
|
-
@request.env
|
66
|
-
end
|
67
|
-
|
68
54
|
# you can access the original @request via this method_missing,
|
69
55
|
# first it tries to match your method with any of the HTTP parameters
|
70
56
|
# then, in case that fails, it will relay to @request
|
71
57
|
|
72
58
|
def method_missing meth, *args, &block
|
73
|
-
|
74
|
-
|
75
|
-
|
59
|
+
key = meth.to_s.upcase
|
60
|
+
return env[key] if env.has_key?(key)
|
61
|
+
super
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.included(klass)
|
65
|
+
klass.class_eval do
|
66
|
+
unless defined?(fullpath)
|
67
|
+
def fullpath
|
68
|
+
path = script_name + path_info
|
69
|
+
path << "?" << query_string unless query_string.empty?
|
70
|
+
path
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
unless defined?(rack_params)
|
75
|
+
alias rack_params params
|
76
|
+
|
77
|
+
def params
|
78
|
+
ps = rack_params
|
79
|
+
temp = Hash.new{|h,k| h[k] = {}}
|
80
|
+
|
81
|
+
ps.each do |key, value|
|
82
|
+
outer_key, inner_key = key.scan(/^(.+)\[(.*?)\]$/).first
|
83
|
+
if outer_key and inner_key
|
84
|
+
temp[outer_key][inner_key] = value
|
85
|
+
else
|
86
|
+
temp[key] = value
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
temp
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
76
94
|
end
|
77
95
|
end
|
78
96
|
end
|
@@ -2,11 +2,16 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
module Ramaze
|
5
|
-
|
6
|
-
|
7
|
-
# You can call this from everywhere with Ramaze::Response.current
|
5
|
+
module Response
|
6
|
+
class << self
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
# get the current response out of Thread.current[:response]
|
9
|
+
#
|
10
|
+
# You can call this from everywhere with Ramaze::Response.current
|
11
|
+
|
12
|
+
def current
|
13
|
+
Thread.current[:response]
|
14
|
+
end
|
15
|
+
end
|
11
16
|
end
|
12
17
|
end
|
@@ -55,6 +55,10 @@ module Ramaze
|
|
55
55
|
|
56
56
|
trait :finalize => [:finalize_flash]
|
57
57
|
|
58
|
+
trait :ip_cache => Hash.new{|h,k| h[k] = []}
|
59
|
+
|
60
|
+
trait :ip_cache_limit => 1000
|
61
|
+
|
58
62
|
class << self
|
59
63
|
|
60
64
|
# answers with Thread.current[:session] which holds the current session
|
@@ -75,6 +79,14 @@ module Ramaze
|
|
75
79
|
|
76
80
|
def initialize request
|
77
81
|
@session_id = (request.cookies[SESSION_KEY] || random_key)
|
82
|
+
ip_cache = ancestral_trait[:ip_cache]
|
83
|
+
ip = request.remote_addr
|
84
|
+
ip_cache[ip] << @session_id
|
85
|
+
|
86
|
+
if ip_cache[ip].size >= ancestral_trait[:ip_cache_limit]
|
87
|
+
sessions.delete(ip_cache[ip].shift)
|
88
|
+
end
|
89
|
+
|
78
90
|
@flash = Ramaze::SessionFlash.new
|
79
91
|
|
80
92
|
unless sessions
|
@@ -120,7 +132,7 @@ module Ramaze
|
|
120
132
|
|
121
133
|
def random_key
|
122
134
|
h = [
|
123
|
-
Time.now.to_f.to_s
|
135
|
+
Time.now.to_f.to_s, rand,
|
124
136
|
Thread.current[:request].hash, rand,
|
125
137
|
Process.pid, rand,
|
126
138
|
object_id, rand
|
@@ -191,7 +203,9 @@ module Ramaze
|
|
191
203
|
end
|
192
204
|
|
193
205
|
def []=(key, value)
|
194
|
-
|
206
|
+
prev = session[:FLASH] || {}
|
207
|
+
prev[key] = value
|
208
|
+
session[:FLASH] = prev
|
195
209
|
end
|
196
210
|
|
197
211
|
def inspect
|
@@ -201,7 +215,7 @@ module Ramaze
|
|
201
215
|
private
|
202
216
|
|
203
217
|
def session
|
204
|
-
Ramaze::Session.current
|
218
|
+
Ramaze::Session.current || {}
|
205
219
|
end
|
206
220
|
end
|
207
221
|
end
|
data/lib/ramaze/version.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
AUTHOR = "manveru"
|
2
|
+
EMAIL = "m.fellinger@gmail.com"
|
3
|
+
DESCRIPTION = "Ramaze tries to be a very simple Webframework without the voodoo"
|
4
|
+
HOMEPATH = 'http://ramaze.rubyforge.org'
|
5
|
+
BIN_FILES = %w( ramaze )
|
6
|
+
|
7
|
+
BASEDIR = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
8
|
+
|
9
|
+
NAME = "ramaze"
|
10
|
+
REV = File.read(".svn/entries")[/committed-rev="(d+)"/, 1] rescue nil
|
11
|
+
VERS = ENV['VERSION'] || (Ramaze::VERSION + (REV ? ".#{REV}" : ""))
|
12
|
+
COPYRIGHT = [
|
13
|
+
"# Copyright (c) 2006 Michael Fellinger m.fellinger@gmail.com",
|
14
|
+
"# All files in this distribution are subject to the terms of the Ruby license."
|
15
|
+
]
|
16
|
+
CLEAN.include %w[
|
17
|
+
**/.*.sw?
|
18
|
+
*.gem
|
19
|
+
.config
|
20
|
+
**/*~
|
21
|
+
**/{data.db,cache.yaml}
|
22
|
+
*.yaml
|
23
|
+
pkg
|
24
|
+
rdoc
|
25
|
+
]
|
26
|
+
RDOC_OPTS = %w[
|
27
|
+
--all
|
28
|
+
--quiet
|
29
|
+
--op rdoc
|
30
|
+
--line-numbers
|
31
|
+
--inline-source
|
32
|
+
--main doc/README
|
33
|
+
--opname index.html
|
34
|
+
--title "Ramaze\ documentation"
|
35
|
+
--exclude "^(_darcs|spec|examples|bin|pkg)/"
|
36
|
+
--exclude "lib/proto"
|
37
|
+
--include "doc"
|
38
|
+
--accessor "trait"
|
39
|
+
]
|
40
|
+
RDOC_FILES = %w[
|
41
|
+
lib doc doc/README doc/FAQ doc/CHANGELOG
|
42
|
+
]
|
43
|
+
POST_INSTALL_MESSAGE = %{
|
44
|
+
#{'=' * 60}
|
45
|
+
|
46
|
+
Thank you for installing Ramaze!
|
47
|
+
You can now do following:
|
48
|
+
|
49
|
+
* Create a new project using the `ramaze' command:
|
50
|
+
ramaze --create yourproject
|
51
|
+
|
52
|
+
* Browse and try the Examples in
|
53
|
+
#{File.join(Gem.path, 'gems', 'ramaze-' + VERS, 'examples')}
|
54
|
+
|
55
|
+
#{'=' * 60}
|
56
|
+
}.strip
|
data/rake_tasks/gem.rake
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
spec =
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = NAME
|
4
|
+
s.version = VERS
|
5
|
+
s.platform = Gem::Platform::RUBY
|
6
|
+
s.has_rdoc = true
|
7
|
+
s.extra_rdoc_files = RDOC_FILES
|
8
|
+
s.rdoc_options += RDOC_OPTS
|
9
|
+
s.summary = DESCRIPTION
|
10
|
+
s.description = DESCRIPTION
|
11
|
+
s.author = AUTHOR
|
12
|
+
s.email = EMAIL
|
13
|
+
s.homepage = HOMEPATH
|
14
|
+
s.executables = BIN_FILES
|
15
|
+
s.bindir = "bin"
|
16
|
+
s.require_path = "lib"
|
17
|
+
s.post_install_message = POST_INSTALL_MESSAGE
|
18
|
+
|
19
|
+
s.add_dependency('rake', '>=0.7.3')
|
20
|
+
s.add_dependency('rspec', '>=0.9.1')
|
21
|
+
s.add_dependency('rack', '>=0.1.0')
|
22
|
+
# s.required_ruby_version = '>= 1.8.5'
|
23
|
+
|
24
|
+
s.files = (RDOC_FILES + %w[Rakefile] + Dir["{examples,bin,doc,spec,lib,rake_tasks}/**/*"]).uniq
|
25
|
+
|
26
|
+
# s.extensions = FileList["ext/**/extconf.rb"].to_a
|
27
|
+
end
|
28
|
+
|
29
|
+
Rake::GemPackageTask.new(spec) do |p|
|
30
|
+
p.need_tar = true
|
31
|
+
p.gem_spec = spec
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "package and install ramaze"
|
35
|
+
task :install do
|
36
|
+
name = "#{NAME}-#{VERS}.gem"
|
37
|
+
sh %{rake package}
|
38
|
+
sh %{sudo gem install pkg/#{name}}
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "uninstall the ramaze gem"
|
42
|
+
task :uninstall => [:clean] do
|
43
|
+
sh %{sudo gem uninstall #{NAME}}
|
44
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
desc "add copyright to all .rb files in the distribution"
|
2
|
+
task 'add-copyright' do
|
3
|
+
puts "adding copyright to files that don't have it currently"
|
4
|
+
Dir['{lib,test}/**/*{.rb}'].each do |file|
|
5
|
+
next if file =~ /_darcs/
|
6
|
+
lines = File.readlines(file).map{|l| l.chomp}
|
7
|
+
unless lines.first(COPYRIGHT.size) == COPYRIGHT
|
8
|
+
puts "fixing #{file}"
|
9
|
+
File.open(file, 'w+') do |f|
|
10
|
+
(COPYRIGHT + ["\n"] + lines).each do |line|
|
11
|
+
f.puts(line)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "doc/README to html"
|
19
|
+
Rake::RDocTask.new('readme2html-build') do |rd|
|
20
|
+
rd.options = %w[
|
21
|
+
--quiet
|
22
|
+
--opname readme.html
|
23
|
+
]
|
24
|
+
|
25
|
+
rd.rdoc_dir = 'readme'
|
26
|
+
rd.rdoc_files = ['doc/README']
|
27
|
+
rd.main = 'doc/README'
|
28
|
+
rd.title = "Ramaze documentation"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "doc/README to doc/README.html"
|
32
|
+
task 'readme2html' => ['readme-build', 'readme2html-build'] do
|
33
|
+
cp('readme/files/doc/README.html', 'doc/README.html')
|
34
|
+
rm_rf('readme')
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "generate doc/TODO from the TODO tags in the source"
|
38
|
+
task 'todolist' do
|
39
|
+
list = `rake todo`
|
40
|
+
tasks = {}
|
41
|
+
current = nil
|
42
|
+
|
43
|
+
list.split("\n")[2..-1].each do |line|
|
44
|
+
if line =~ /TODO/ or line.empty?
|
45
|
+
elsif line =~ /^vim/
|
46
|
+
current = line.split[1]
|
47
|
+
tasks[current] = []
|
48
|
+
else
|
49
|
+
tasks[current] << line
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
lines = tasks.map{ |name, items| [name, items, ''] }.flatten
|
54
|
+
lines.pop
|
55
|
+
|
56
|
+
File.open(File.join('doc', 'TODO'), 'w+') do |f|
|
57
|
+
f.puts "This list is programmaticly generated by `rake todolist`"
|
58
|
+
f.puts "If you want to add/remove items from the list, change them at the"
|
59
|
+
f.puts "position specified in the list."
|
60
|
+
f.puts
|
61
|
+
f.puts(lines)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "remove those annoying spaces at the end of lines"
|
66
|
+
task 'fix-end-spaces' do
|
67
|
+
Dir['{lib,spec}/**/*.rb'].each do |file|
|
68
|
+
next if file =~ /_darcs/
|
69
|
+
lines = File.readlines(file)
|
70
|
+
new = lines.dup
|
71
|
+
lines.each_with_index do |line, i|
|
72
|
+
if line =~ /\s+\n/
|
73
|
+
puts "fixing #{file}:#{i + 1}"
|
74
|
+
p line
|
75
|
+
new[i] = line.rstrip
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
unless new == lines
|
80
|
+
File.open(file, 'w+') do |f|
|
81
|
+
new.each do |line|
|
82
|
+
f.puts(line)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Compile the doc/README from the parts of doc/readme"
|
90
|
+
task 'readme-build' do
|
91
|
+
require 'enumerator'
|
92
|
+
|
93
|
+
chapters = [
|
94
|
+
'About Ramaze', 'introduction',
|
95
|
+
'Features Overview', 'features',
|
96
|
+
'Basic Principles', 'principles',
|
97
|
+
'Installation', 'installing',
|
98
|
+
'Getting Started', 'getting_started',
|
99
|
+
'A couple of Examples', 'examples',
|
100
|
+
'How to find Help', 'getting_help',
|
101
|
+
'Appendix', 'appendix',
|
102
|
+
'And thanks to...', 'thanks',
|
103
|
+
]
|
104
|
+
|
105
|
+
File.open('doc/README', 'w+') do |readme|
|
106
|
+
readme.puts COPYRIGHT.map{|l| l[1..-1]}, ''
|
107
|
+
|
108
|
+
chapters.each_slice(2) do |title, file|
|
109
|
+
file = File.join('doc', 'readme_chunks', "#{file}.txt")
|
110
|
+
chapter = File.read(file)
|
111
|
+
readme.puts "= #{title}", '', chapter
|
112
|
+
readme.puts '', '' unless title == chapters[-2]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
task 'tutorial2html' do
|
118
|
+
require 'bluecloth'
|
119
|
+
|
120
|
+
basefile = File.join('doc', 'tutorial', 'todolist')
|
121
|
+
|
122
|
+
content = File.read(basefile + '.txt')
|
123
|
+
|
124
|
+
html = BlueCloth.new(content).to_html
|
125
|
+
|
126
|
+
wrap = %{
|
127
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
128
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
129
|
+
<html>
|
130
|
+
<head>
|
131
|
+
<title>Ramaze Tutorial: Todolist</title>
|
132
|
+
<style>
|
133
|
+
body {
|
134
|
+
background: #eee;
|
135
|
+
}
|
136
|
+
code {
|
137
|
+
background: #ddd;
|
138
|
+
}
|
139
|
+
pre code {
|
140
|
+
background: #ddd;
|
141
|
+
width: 70%;
|
142
|
+
display: block;
|
143
|
+
margin: 1em;
|
144
|
+
padding: 0.7em;
|
145
|
+
overflow: auto;
|
146
|
+
}
|
147
|
+
</style>
|
148
|
+
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
|
149
|
+
</head>
|
150
|
+
<body>
|
151
|
+
#{html}
|
152
|
+
</body>
|
153
|
+
</html>
|
154
|
+
}.strip
|
155
|
+
|
156
|
+
File.open(basefile + '.html', 'w+'){|f| f.puts(wrap) }
|
157
|
+
end
|
158
|
+
|
159
|
+
task 'authors' do
|
160
|
+
changes = `darcs changes`
|
161
|
+
authors = []
|
162
|
+
mapping = {}
|
163
|
+
author_map = {
|
164
|
+
'm.fellinger@gmail.com' => 'Michael Fellinger',
|
165
|
+
'manveru@weez-int.com' => 'Michael Fellinger',
|
166
|
+
'clive@crous.co.za' => 'Clive Crous'
|
167
|
+
}
|
168
|
+
changes.split("\n").grep(/^\w/).each do |line|
|
169
|
+
splat = line.split
|
170
|
+
author = splat[6..-1]
|
171
|
+
email = author.pop
|
172
|
+
email.gsub!(/<(.*?)>/, '\1')
|
173
|
+
name = author.join(' ')
|
174
|
+
name = author_map[email] if name.empty?
|
175
|
+
mapping[name] = email
|
176
|
+
end
|
177
|
+
|
178
|
+
max = mapping.map{|k,v| k.size}.max
|
179
|
+
|
180
|
+
File.open('doc/AUTHORS', 'w+') do |fp|
|
181
|
+
fp.puts("Following persons have contributed to Ramaze:")
|
182
|
+
fp.puts
|
183
|
+
mapping.sort_by{|k,v| v}.each do |name, email|
|
184
|
+
fp.puts("#{name.ljust(max)} - #{email}")
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|