ramaze 2011.01.30 → 2011.07.25
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.
- data/.gitignore +2 -1
- data/.mailmap +2 -0
- data/.rvmrc +1 -0
- data/README.md +119 -197
- data/Rakefile +14 -97
- data/bin/ramaze +6 -14
- data/doc/AUTHORS +8 -4
- data/doc/CHANGELOG +3784 -3339
- data/examples/app/chat/start.rb +2 -2
- data/lib/proto/app.rb +2 -3
- data/lib/proto/config.ru +4 -5
- data/lib/proto/controller/init.rb +11 -4
- data/lib/proto/controller/main.rb +12 -7
- data/lib/proto/layout/default.xhtml +56 -23
- data/lib/proto/model/init.rb +3 -1
- data/lib/proto/public/css/grid.css +107 -0
- data/lib/proto/public/css/layout.css +81 -0
- data/lib/proto/public/css/reset.css +123 -0
- data/lib/proto/public/css/text.css +109 -0
- data/lib/proto/public/images/bg.png +0 -0
- data/lib/proto/spec/main.rb +2 -2
- data/lib/proto/start.rb +11 -1
- data/lib/proto/view/index.xhtml +27 -23
- data/lib/ramaze.rb +0 -1
- data/lib/ramaze/app.rb +85 -12
- data/lib/ramaze/app_graph.rb +107 -0
- data/lib/ramaze/bin/console.rb +87 -0
- data/lib/ramaze/bin/create.rb +94 -0
- data/lib/ramaze/bin/helper.rb +107 -0
- data/lib/ramaze/bin/restart.rb +95 -0
- data/lib/ramaze/bin/runner.rb +141 -0
- data/lib/ramaze/bin/start.rb +206 -0
- data/lib/ramaze/bin/status.rb +152 -0
- data/lib/ramaze/bin/stop.rb +112 -0
- data/lib/ramaze/cache.rb +9 -4
- data/lib/ramaze/cache/localmemcache.rb +10 -13
- data/lib/ramaze/cache/lru.rb +49 -7
- data/lib/ramaze/cache/memcache.rb +170 -92
- data/lib/ramaze/cache/sequel.rb +301 -118
- data/lib/ramaze/controller.rb +108 -9
- data/lib/ramaze/controller/default.rb +15 -2
- data/lib/ramaze/current.rb +14 -2
- data/lib/ramaze/dependencies.rb +46 -0
- data/lib/ramaze/files.rb +38 -3
- data/lib/ramaze/gestalt.rb +12 -12
- data/lib/ramaze/helper.rb +0 -2
- data/lib/ramaze/helper/auth.rb +30 -23
- data/lib/ramaze/helper/blue_form.rb +175 -126
- data/lib/ramaze/helper/csrf.rb +76 -91
- data/lib/ramaze/helper/email.rb +105 -0
- data/lib/ramaze/helper/erector.rb +16 -15
- data/lib/ramaze/helper/gestalt.rb +2 -2
- data/lib/ramaze/helper/layout.rb +89 -73
- data/lib/ramaze/helper/link.rb +7 -6
- data/lib/ramaze/helper/localize.rb +6 -5
- data/lib/ramaze/helper/markaby.rb +25 -23
- data/lib/ramaze/helper/maruku.rb +3 -3
- data/lib/ramaze/helper/paginate.rb +19 -27
- data/lib/ramaze/helper/remarkably.rb +3 -3
- data/lib/ramaze/helper/request_accessor.rb +3 -3
- data/lib/ramaze/helper/send_file.rb +12 -8
- data/lib/ramaze/helper/simple_captcha.rb +5 -6
- data/lib/ramaze/helper/stack.rb +7 -4
- data/lib/ramaze/helper/tagz.rb +10 -11
- data/lib/ramaze/helper/thread.rb +19 -16
- data/lib/ramaze/helper/ultraviolet.rb +7 -4
- data/lib/ramaze/helper/user.rb +40 -21
- data/lib/ramaze/helper/xhtml.rb +29 -20
- data/lib/ramaze/log.rb +3 -11
- data/lib/ramaze/log/analogger.rb +5 -4
- data/lib/ramaze/log/growl.rb +9 -7
- data/lib/ramaze/log/hub.rb +3 -5
- data/lib/ramaze/log/informer.rb +15 -12
- data/lib/ramaze/log/knotify.rb +3 -5
- data/lib/ramaze/log/logger.rb +3 -5
- data/lib/ramaze/log/logging.rb +6 -8
- data/lib/ramaze/log/rotatinginformer.rb +27 -17
- data/lib/ramaze/log/syslog.rb +7 -7
- data/lib/ramaze/log/xosd.rb +3 -5
- data/lib/ramaze/middleware_compiler.rb +27 -4
- data/lib/ramaze/reloader.rb +50 -12
- data/lib/ramaze/reloader/watch_inotify.rb +4 -5
- data/lib/ramaze/reloader/watch_stat.rb +3 -3
- data/lib/ramaze/request.rb +18 -8
- data/lib/ramaze/response.rb +38 -7
- data/lib/ramaze/rest.rb +36 -0
- data/lib/ramaze/setup.rb +101 -31
- data/lib/ramaze/spec.rb +1 -1
- data/lib/ramaze/spec/bacon.rb +6 -3
- data/lib/ramaze/spec/helper/bacon.rb +0 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +2 -11
- data/lib/ramaze/view/erector.rb +46 -31
- data/lib/ramaze/view/erubis.rb +7 -3
- data/lib/ramaze/view/ezamar.rb +7 -3
- data/lib/ramaze/view/gestalt.rb +9 -3
- data/lib/ramaze/view/haml.rb +7 -3
- data/lib/ramaze/view/liquid.rb +3 -3
- data/lib/ramaze/view/lokar.rb +7 -3
- data/lib/ramaze/view/mustache.rb +11 -5
- data/lib/ramaze/view/nagoro.rb +3 -3
- data/lib/ramaze/view/sass.rb +1 -1
- data/lib/ramaze/view/slippers.rb +40 -13
- data/lib/ramaze/view/tagz.rb +9 -5
- data/ramaze.gemspec +23 -128
- data/spec/helper.rb +5 -0
- data/spec/ramaze/bin/app/config.ru +11 -0
- data/spec/ramaze/bin/create.rb +28 -0
- data/spec/ramaze/bin/runner.rb +30 -0
- data/spec/ramaze/bin/start.rb +38 -0
- data/spec/ramaze/cache/memcache.rb +10 -3
- data/spec/ramaze/cache/sequel.rb +7 -0
- data/spec/ramaze/controller/provide_inheritance.rb +0 -10
- data/spec/ramaze/dispatcher/file.rb +19 -15
- data/spec/ramaze/helper/auth.rb +10 -9
- data/spec/ramaze/helper/blue_form.rb +121 -68
- data/spec/ramaze/helper/email.rb +69 -0
- data/spec/ramaze/helper/layout.rb +12 -15
- data/spec/ramaze/helper/layout/alternative.xhtml +5 -0
- data/spec/ramaze/helper/user.rb +2 -0
- data/spec/ramaze/log/growl.rb +14 -1
- data/spec/{contrib → ramaze}/rest.rb +1 -1
- data/spec/ramaze/session/memcache.rb +2 -2
- data/spec/ramaze/view/sass.rb +1 -1
- data/tasks/bacon.rake +3 -3
- data/tasks/gem.rake +17 -18
- data/tasks/rcov.rake +2 -3
- data/tasks/release.rake +8 -65
- data/tasks/setup.rake +10 -8
- data/tasks/todo.rake +9 -5
- data/tasks/yard.rake +3 -2
- metadata +105 -397
- data/MANIFEST +0 -532
- data/TODO.md +0 -19
- data/benchmark/bench_templates/bench.rb +0 -67
- data/benchmark/bench_templates/view/large.erb +0 -79
- data/benchmark/bench_templates/view/large.haml +0 -41
- data/benchmark/bench_templates/view/large.lok +0 -79
- data/benchmark/bench_templates/view/large.xhtml +0 -79
- data/benchmark/bench_templates/view/small.erb +0 -21
- data/benchmark/bench_templates/view/small.haml +0 -12
- data/benchmark/bench_templates/view/small.lok +0 -21
- data/benchmark/bench_templates/view/small.xhtml +0 -21
- data/benchmark/results.txt +0 -131
- data/benchmark/run.rb +0 -355
- data/benchmark/suite/minimal.rb +0 -11
- data/benchmark/suite/no_informer.rb +0 -7
- data/benchmark/suite/no_sessions.rb +0 -9
- data/benchmark/suite/no_template.rb +0 -7
- data/benchmark/suite/simple.rb +0 -5
- data/benchmark/suite/template_erubis.rb +0 -8
- data/benchmark/suite/template_etanni.rb +0 -8
- data/benchmark/suite/template_ezamar.rb +0 -8
- data/benchmark/suite/template_haml.rb +0 -13
- data/benchmark/suite/template_liquid.rb +0 -11
- data/benchmark/suite/template_markaby.rb +0 -9
- data/benchmark/suite/template_nagoro.rb +0 -8
- data/benchmark/suite/template_redcloth.rb +0 -13
- data/benchmark/suite/template_tenjin.rb +0 -8
- data/benchmark/test.rb +0 -35
- data/doc/FAQ +0 -92
- data/doc/INSTALL +0 -92
- data/doc/TODO +0 -29
- data/doc/meta/announcement.txt +0 -119
- data/doc/meta/configuration.txt +0 -163
- data/doc/meta/internals.txt +0 -278
- data/doc/meta/users.kml +0 -64
- data/doc/tutorial/todolist.html +0 -1512
- data/doc/tutorial/todolist.txt +0 -920
- data/examples/app/sourceview/public/coderay.css +0 -104
- data/examples/app/sourceview/public/images/file.gif +0 -0
- data/examples/app/sourceview/public/images/folder.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-collapsable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-expandable.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item-last.gif +0 -0
- data/examples/app/sourceview/public/images/tv-item.gif +0 -0
- data/examples/app/sourceview/public/jquery.js +0 -11
- data/examples/app/sourceview/public/jquery.treeview.css +0 -48
- data/examples/app/sourceview/public/jquery.treeview.js +0 -223
- data/examples/app/sourceview/public/sourceview.js +0 -52
- data/examples/app/sourceview/start.rb +0 -79
- data/examples/app/sourceview/view/index.haml +0 -59
- data/examples/helpers/httpdigest.rb +0 -107
- data/lib/proto/public/css/screen.css +0 -30
- data/lib/proto/public/js/jquery.js +0 -7179
- data/lib/ramaze/contrib/addressable_route.rb +0 -56
- data/lib/ramaze/contrib/app_graph.rb +0 -64
- data/lib/ramaze/contrib/email.rb +0 -88
- data/lib/ramaze/contrib/facebook.rb +0 -23
- data/lib/ramaze/contrib/facebook/facebook.rb +0 -171
- data/lib/ramaze/contrib/gettext.rb +0 -113
- data/lib/ramaze/contrib/gettext/mo.rb +0 -155
- data/lib/ramaze/contrib/gettext/parser.rb +0 -46
- data/lib/ramaze/contrib/gettext/po.rb +0 -109
- data/lib/ramaze/contrib/gzip_filter.rb +0 -1
- data/lib/ramaze/contrib/maruku_uv.rb +0 -59
- data/lib/ramaze/contrib/profiling.rb +0 -36
- data/lib/ramaze/contrib/rest.rb +0 -23
- data/lib/ramaze/contrib/sequel/create_join.rb +0 -26
- data/lib/ramaze/contrib/sequel/form_field.rb +0 -129
- data/lib/ramaze/contrib/sequel/image.rb +0 -196
- data/lib/ramaze/contrib/sequel/relation.rb +0 -98
- data/lib/ramaze/helper/httpdigest.rb +0 -96
- data/lib/ramaze/tool/bin.rb +0 -340
- data/lib/ramaze/tool/create.rb +0 -48
- data/lib/ramaze/tool/project_creator.rb +0 -120
- data/lib/ramaze/view/less.rb +0 -12
- data/lib/ramaze/view/maruku.rb +0 -15
- data/lib/ramaze/view/redcloth.rb +0 -21
- data/spec/contrib/addressable_route.rb +0 -30
- data/spec/examples/helpers/httpdigest.rb +0 -64
- data/spec/examples/templates/template_redcloth.rb +0 -13
- data/spec/ramaze/bin/ramaze.rb +0 -96
- data/spec/ramaze/helper/httpdigest.rb +0 -176
- data/spec/ramaze/view/less.rb +0 -60
- data/spec/ramaze/view/less/file.css.less +0 -8
- data/spec/ramaze/view/redcloth.rb +0 -66
- data/spec/ramaze/view/redcloth/external.redcloth +0 -8
- data/tasks/copyright.rake +0 -21
- data/tasks/gem_setup.rake +0 -112
- data/tasks/git.rake +0 -46
- data/tasks/grancher.rake +0 -12
- data/tasks/jquery.rake +0 -15
- data/tasks/manifest.rake +0 -4
- data/tasks/metric_changes.rake +0 -24
- data/tasks/reversion.rake +0 -8
- data/tasks/traits.rake +0 -21
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module Ramaze
|
|
2
2
|
class Reloader
|
|
3
|
+
##
|
|
3
4
|
# TODO:
|
|
4
5
|
# * There seems to be a problem somewhere that I couldn't identify yet, a
|
|
5
6
|
# file has to be modified twice initially to make it show up as
|
|
@@ -11,7 +12,6 @@ module Ramaze
|
|
|
11
12
|
# NOTE:
|
|
12
13
|
# * I have changed from using a Mutex to using a Queue, which uses a
|
|
13
14
|
# Mutex internally.
|
|
14
|
-
|
|
15
15
|
class WatchInotify
|
|
16
16
|
POLL_INTERVAL = 2 # seconds
|
|
17
17
|
NOTIFY_MASK = RInotify::MODIFY | RInotify::IN_ONESHOT
|
|
@@ -54,7 +54,6 @@ module Ramaze
|
|
|
54
54
|
# FIXME:
|
|
55
55
|
# Seems like this won't work due to some bug in the rinotify library.
|
|
56
56
|
# Would be cool if someone could make a FFI version.
|
|
57
|
-
|
|
58
57
|
def remove_watch(file)
|
|
59
58
|
@watcher.rm_watch(file)
|
|
60
59
|
end
|
|
@@ -80,6 +79,6 @@ module Ramaze
|
|
|
80
79
|
yield(file)
|
|
81
80
|
end
|
|
82
81
|
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
82
|
+
end # WatchInotify
|
|
83
|
+
end # Reloader
|
|
84
|
+
end # Ramaze
|
data/lib/ramaze/request.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
|
|
4
3
|
module Ramaze
|
|
4
|
+
##
|
|
5
5
|
# The purpose of this class is to act as a simple wrapper for Rack::Request
|
|
6
6
|
# and provide some convinient methods for our own use.
|
|
7
7
|
class Request < Innate::Request
|
|
8
|
-
|
|
8
|
+
##
|
|
9
9
|
# you can access the original @request via this method_missing,
|
|
10
10
|
# first it tries to match your method with any of the HTTP parameters
|
|
11
11
|
# then, in case that fails, it will relay to @request
|
|
@@ -15,6 +15,7 @@ module Ramaze
|
|
|
15
15
|
super
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
##
|
|
18
19
|
# Sets any arguments passed as @instance_variables for the current action.
|
|
19
20
|
#
|
|
20
21
|
# Usage:
|
|
@@ -23,7 +24,7 @@ module Ramaze
|
|
|
23
24
|
# @q # => 'google'
|
|
24
25
|
# @name # => 'manveru'
|
|
25
26
|
# @lang # => nil
|
|
26
|
-
|
|
27
|
+
#
|
|
27
28
|
def to_instance_variables(*args)
|
|
28
29
|
instance = Current.action.instance
|
|
29
30
|
args.each do |arg|
|
|
@@ -39,6 +40,7 @@ module Ramaze
|
|
|
39
40
|
charset == '*' ? default : charset
|
|
40
41
|
end
|
|
41
42
|
|
|
43
|
+
##
|
|
42
44
|
# Try to find out which languages the client would like to have and sort
|
|
43
45
|
# them by weight, (most wanted first).
|
|
44
46
|
#
|
|
@@ -54,6 +56,7 @@ module Ramaze
|
|
|
54
56
|
# @return [Array] list of locales
|
|
55
57
|
# @see Request#accept_language_with_weight
|
|
56
58
|
# @author manveru
|
|
59
|
+
#
|
|
57
60
|
def accept_language(string = env['HTTP_ACCEPT_LANGUAGE'])
|
|
58
61
|
return [] unless string
|
|
59
62
|
|
|
@@ -61,6 +64,7 @@ module Ramaze
|
|
|
61
64
|
end
|
|
62
65
|
alias locales accept_language
|
|
63
66
|
|
|
67
|
+
##
|
|
64
68
|
# Transform the HTTP_ACCEPT_LANGUAGE header into an Array with:
|
|
65
69
|
#
|
|
66
70
|
# [[lang, weight], [lang, weight], ...]
|
|
@@ -76,6 +80,7 @@ module Ramaze
|
|
|
76
80
|
# @return [Array] array of [lang, weight] arrays
|
|
77
81
|
# @see Request#accept_language
|
|
78
82
|
# @author manveru
|
|
83
|
+
#
|
|
79
84
|
def accept_language_with_weight(string = env['HTTP_ACCEPT_LANGUAGE'])
|
|
80
85
|
string.to_s.gsub(/\s+/, '').split(',').
|
|
81
86
|
map{|chunk| chunk.split(';q=', 2) }.
|
|
@@ -102,14 +107,19 @@ module Ramaze
|
|
|
102
107
|
# Pretty prints current action with parameters, cookies and enviroment
|
|
103
108
|
# variables.
|
|
104
109
|
def pretty_print(pp)
|
|
105
|
-
pp.object_group(self)
|
|
106
|
-
group = {
|
|
110
|
+
pp.object_group(self) do
|
|
111
|
+
group = {
|
|
112
|
+
'params' => params,
|
|
113
|
+
'cookies' => cookies,
|
|
114
|
+
'env' => http_variables
|
|
115
|
+
}
|
|
116
|
+
|
|
107
117
|
group.each do |name, hash|
|
|
108
118
|
pp.breakable
|
|
109
119
|
pp.text " @#{name}="
|
|
110
120
|
pp.nest(name.size + 3){ pp.pp_hash(hash) }
|
|
111
121
|
end
|
|
112
|
-
|
|
122
|
+
end
|
|
113
123
|
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
124
|
+
end # Request
|
|
125
|
+
end # Ramaze
|
data/lib/ramaze/response.rb
CHANGED
|
@@ -1,36 +1,67 @@
|
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
|
3
|
-
|
|
4
3
|
module Ramaze
|
|
4
|
+
##
|
|
5
|
+
# Ramaze::Response is a small wrapper around Rack::Response that makes it
|
|
6
|
+
# easier to send response data to the browser from a Ramaze application.
|
|
7
|
+
#
|
|
8
|
+
# @author Michael Fellinger
|
|
9
|
+
# @since 01-03-2008
|
|
10
|
+
#
|
|
5
11
|
class Response < Rack::Response
|
|
6
12
|
# Alias for Current.response
|
|
7
13
|
def self.current; Current.response; end
|
|
8
14
|
|
|
15
|
+
##
|
|
16
|
+
# Creates a new instance of the response class and processes the specified
|
|
17
|
+
# parameters. Once this has been done it calls Rack::Response#initialize.
|
|
18
|
+
#
|
|
19
|
+
# @author Michael Fellinger
|
|
20
|
+
# @since 01-03-2008
|
|
21
|
+
# @param [Array] body An array containing the data for the response body.
|
|
22
|
+
# @param [Fixnum] status The HTPP status code for the response.
|
|
23
|
+
# @param [Hash] header A hash containing additional headers and their
|
|
24
|
+
# values.
|
|
25
|
+
# @param [Proc] &block
|
|
26
|
+
#
|
|
9
27
|
def initialize(body = [], status = 200, header = {}, &block)
|
|
10
28
|
modified_header = Ramaze.options.header.merge(header)
|
|
11
29
|
header.merge!(modified_header)
|
|
12
30
|
super
|
|
13
31
|
end
|
|
14
32
|
|
|
15
|
-
|
|
33
|
+
##
|
|
34
|
+
# Updates the body, status and headers.
|
|
35
|
+
#
|
|
36
|
+
# @author Michael Fellinger
|
|
37
|
+
# @since 01-03-2008
|
|
38
|
+
# @see Ramaze::Response#initialize
|
|
39
|
+
#
|
|
16
40
|
def build(new_body = nil, new_status = nil, new_header = nil)
|
|
17
41
|
self.header.merge!(new_header) if new_header
|
|
18
42
|
|
|
19
|
-
self.body = new_body
|
|
43
|
+
self.body = new_body if new_body
|
|
20
44
|
self.status = new_status if new_status
|
|
21
45
|
end
|
|
22
46
|
|
|
47
|
+
##
|
|
48
|
+
# Sets the body of the response to the given object.
|
|
49
|
+
#
|
|
50
|
+
# @author Michael Fellinger
|
|
51
|
+
# @since 01-03-2008
|
|
52
|
+
# @param [Object] obj The object to use as the response body.
|
|
53
|
+
#
|
|
23
54
|
def body=(obj)
|
|
24
55
|
if obj.respond_to?(:stat)
|
|
25
56
|
@length = obj.stat.size
|
|
26
|
-
@body
|
|
57
|
+
@body = obj
|
|
27
58
|
elsif obj.respond_to?(:size)
|
|
28
|
-
@body
|
|
59
|
+
@body = []
|
|
29
60
|
@length = 0
|
|
30
61
|
write(obj)
|
|
31
62
|
else
|
|
32
63
|
raise(ArgumentError, "Invalid body: %p" % obj)
|
|
33
64
|
end
|
|
34
65
|
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
66
|
+
end # Response
|
|
67
|
+
end # Ramaze
|
data/lib/ramaze/rest.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
##
|
|
2
|
+
# The code in this file adds an extra option and a route to Ramaze that allows
|
|
3
|
+
# REST like HTTP requests. For example, when this file is loaded a GET request
|
|
4
|
+
# to a controller will be mapped to the "show" method while a POST request will
|
|
5
|
+
# be mapped to "create". In order to use this extension you have to load it
|
|
6
|
+
# manually:
|
|
7
|
+
#
|
|
8
|
+
# require 'ramaze/rest'
|
|
9
|
+
#
|
|
10
|
+
# From this point on you can customize the route as following:
|
|
11
|
+
#
|
|
12
|
+
# Ramaze.options.rest_rewrite['GET'] = 'another_method'
|
|
13
|
+
#
|
|
14
|
+
module Ramaze
|
|
15
|
+
# Don't use one option per method, we don't want to turn request_method into a
|
|
16
|
+
# symbol, together with MethodOverride this could lead to a memory leak.
|
|
17
|
+
options.o(
|
|
18
|
+
'REST rewrite mapping',
|
|
19
|
+
:rest_rewrite,
|
|
20
|
+
{
|
|
21
|
+
'GET' => 'show',
|
|
22
|
+
'POST' => 'create',
|
|
23
|
+
'PUT' => 'update',
|
|
24
|
+
'DELETE' => 'destroy'
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Re-write the URLs according to the settings set above
|
|
29
|
+
Rewrite['REST dispatch'] = lambda do |path, request|
|
|
30
|
+
if suffix = Ramaze.options[:rest_rewrite][request.request_method]
|
|
31
|
+
"#{path}/#{suffix}".squeeze('/')
|
|
32
|
+
else
|
|
33
|
+
path
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end # Ramaze
|
data/lib/ramaze/setup.rb
CHANGED
|
@@ -1,35 +1,47 @@
|
|
|
1
1
|
module Ramaze
|
|
2
|
+
##
|
|
2
3
|
# Convenient setup and activation of gems from different sources and specific
|
|
3
|
-
# versions.
|
|
4
|
-
#
|
|
5
|
-
# missing.
|
|
4
|
+
# versions. It's almost like Kernel#gem but also installs automatically if a
|
|
5
|
+
# gem is missing.
|
|
6
6
|
#
|
|
7
7
|
# @example
|
|
8
|
+
# Ramaze.setup :verbose => true do
|
|
9
|
+
# # gem and specific version
|
|
10
|
+
# gem 'makura', '>=2009.01'
|
|
8
11
|
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
# gem 'makura', '>=2009.01'
|
|
12
|
+
# # gem and name for require
|
|
13
|
+
# gem 'aws-s3', :lib => 'aws/s3'
|
|
12
14
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
+
# # gem with specific version from rubyforge (default)
|
|
16
|
+
# gem 'json', :version => '=1.1.3', :source => rubyforge
|
|
17
|
+
# end
|
|
15
18
|
#
|
|
16
|
-
# # gem with specific version from rubyforge (default)
|
|
17
|
-
# gem 'json', :version => '=1.1.3', :source => rubyforge
|
|
18
|
-
#
|
|
19
|
-
# # gem from github
|
|
20
|
-
# gem 'manveru-org', :lib => 'org', :source => github
|
|
21
|
-
# end
|
|
22
|
-
#
|
|
23
|
-
# @option options [boolean] (true) verbose
|
|
24
|
-
# @option options [String] (nil) extconf
|
|
25
|
-
# @yield block
|
|
26
|
-
# @see GemSetup#initialize
|
|
27
19
|
# @author manveru
|
|
20
|
+
# @since 19-05-2009
|
|
21
|
+
# @see GemSetup#initialize
|
|
22
|
+
#
|
|
28
23
|
def self.setup(options = {:verbose => true}, &block)
|
|
29
24
|
GemSetup.new(options, &block)
|
|
30
25
|
end
|
|
31
26
|
|
|
27
|
+
##
|
|
28
|
+
# Class responsible for installing and loading all the gems.
|
|
29
|
+
#
|
|
30
|
+
# @author Michael Fellinger (manveru)
|
|
31
|
+
# @since 19-05-2009
|
|
32
|
+
#
|
|
32
33
|
class GemSetup
|
|
34
|
+
##
|
|
35
|
+
# Creates a new instance of the class and saves the parameters that were set.
|
|
36
|
+
#
|
|
37
|
+
# @author Michael Fellinger (manveru)
|
|
38
|
+
# @since 19-05-2009
|
|
39
|
+
# @param [Hash] options Hash containing various options to pass to the
|
|
40
|
+
# GemSetup class.
|
|
41
|
+
# @option options :verbose When set to true Ramaze will log
|
|
42
|
+
# various actions such as messages about the installation process.
|
|
43
|
+
# @yield block
|
|
44
|
+
#
|
|
33
45
|
def initialize(options = {}, &block)
|
|
34
46
|
@gems = []
|
|
35
47
|
@options = options.dup
|
|
@@ -38,12 +50,33 @@ module Ramaze
|
|
|
38
50
|
run(&block)
|
|
39
51
|
end
|
|
40
52
|
|
|
53
|
+
##
|
|
54
|
+
# Executes the data inside the block, loading all the gems and optionally
|
|
55
|
+
# installing them.
|
|
56
|
+
#
|
|
57
|
+
# @author Michael Fellinger (manveru)
|
|
58
|
+
# @since 19-05-2009
|
|
59
|
+
# @param [Proc] block A block containing all the calls to gem().
|
|
60
|
+
#
|
|
41
61
|
def run(&block)
|
|
42
62
|
return unless block_given?
|
|
43
63
|
instance_eval(&block)
|
|
44
64
|
setup
|
|
45
65
|
end
|
|
46
66
|
|
|
67
|
+
##
|
|
68
|
+
# Adds the given gem to the list of required gems.
|
|
69
|
+
#
|
|
70
|
+
# @example
|
|
71
|
+
# gem('json', '>=1.5.1')
|
|
72
|
+
#
|
|
73
|
+
# @author Michael Fellinger (manveru)
|
|
74
|
+
# @since 19-05-2009
|
|
75
|
+
# @param [String] name The name of the gem to load.
|
|
76
|
+
# @param [String] version The version of the gem.
|
|
77
|
+
# @param [Hash] options Additional options to use when loading the gem.
|
|
78
|
+
# @option options :lib The name to load the gem as.
|
|
79
|
+
#
|
|
47
80
|
def gem(name, version = nil, options = {})
|
|
48
81
|
if version.respond_to?(:merge!)
|
|
49
82
|
options = version
|
|
@@ -54,7 +87,12 @@ module Ramaze
|
|
|
54
87
|
@gems << [name, options]
|
|
55
88
|
end
|
|
56
89
|
|
|
57
|
-
|
|
90
|
+
##
|
|
91
|
+
# Tries to install all the gems.
|
|
92
|
+
#
|
|
93
|
+
# @author Michael Fellinger (manveru)
|
|
94
|
+
# @since 19-05-2009
|
|
95
|
+
#
|
|
58
96
|
def setup
|
|
59
97
|
require 'rubygems'
|
|
60
98
|
require 'rubygems/dependency_installer'
|
|
@@ -64,35 +102,55 @@ module Ramaze
|
|
|
64
102
|
end
|
|
65
103
|
end
|
|
66
104
|
|
|
67
|
-
|
|
68
|
-
#
|
|
105
|
+
##
|
|
106
|
+
# First try to activate, install and try to activate again if activation
|
|
107
|
+
# fails the first time.
|
|
108
|
+
#
|
|
109
|
+
# @author Michael Fellinger (manveru)
|
|
110
|
+
# @since 19-05-2009
|
|
111
|
+
# @param [String] name The name of the gem to activate.
|
|
112
|
+
# @param [Hash] options The options from GemSetup#initialize.
|
|
113
|
+
#
|
|
69
114
|
def setup_gem(name, options)
|
|
70
|
-
version
|
|
115
|
+
version = [options[:version]].compact
|
|
71
116
|
lib_name = options[:lib] || name
|
|
72
117
|
|
|
73
|
-
log "
|
|
118
|
+
log "Activating gem #{name}"
|
|
74
119
|
|
|
75
120
|
Gem.activate(name, *version)
|
|
76
121
|
require(lib_name)
|
|
77
122
|
|
|
123
|
+
# Gem not installed yet
|
|
78
124
|
rescue LoadError
|
|
79
|
-
|
|
80
125
|
install_gem(name, options)
|
|
81
126
|
Gem.activate(name, *version)
|
|
82
127
|
require(lib_name)
|
|
83
128
|
end
|
|
84
129
|
|
|
85
|
-
|
|
130
|
+
##
|
|
131
|
+
# Tell Rubygems to install a gem.
|
|
132
|
+
#
|
|
133
|
+
# @author Michael Fellinger (manveru)
|
|
134
|
+
# @since 19-05-2009
|
|
135
|
+
# @param [String] name The name of the gem to activate.
|
|
136
|
+
# @param [Hash] options The options to use for installing the gem.
|
|
137
|
+
#
|
|
86
138
|
def install_gem(name, options)
|
|
87
139
|
installer = Gem::DependencyInstaller.new(options)
|
|
88
140
|
|
|
89
141
|
temp_argv(options[:extconf]) do
|
|
90
|
-
log "Installing #{name}"
|
|
142
|
+
log "Installing gem #{name}"
|
|
91
143
|
installer.install(name, options[:version])
|
|
92
144
|
end
|
|
93
145
|
end
|
|
94
146
|
|
|
95
|
-
|
|
147
|
+
##
|
|
148
|
+
# Prepare ARGV for rubygems installer
|
|
149
|
+
#
|
|
150
|
+
# @author Michael Fellinger (manveru)
|
|
151
|
+
# @since 19-05-2009
|
|
152
|
+
# @param [String] extconf
|
|
153
|
+
#
|
|
96
154
|
def temp_argv(extconf)
|
|
97
155
|
if extconf ||= @options[:extconf]
|
|
98
156
|
old_argv = ARGV.clone
|
|
@@ -107,6 +165,13 @@ module Ramaze
|
|
|
107
165
|
|
|
108
166
|
private
|
|
109
167
|
|
|
168
|
+
##
|
|
169
|
+
# Writes the message to the logger.
|
|
170
|
+
#
|
|
171
|
+
# @author Michael Fellinger (manveru)
|
|
172
|
+
# @since 19-05-2009
|
|
173
|
+
# @param [String] msg The message to write to the logger.
|
|
174
|
+
#
|
|
110
175
|
def log(msg)
|
|
111
176
|
return unless @verbose
|
|
112
177
|
|
|
@@ -117,7 +182,12 @@ module Ramaze
|
|
|
117
182
|
end
|
|
118
183
|
end
|
|
119
184
|
|
|
185
|
+
##
|
|
186
|
+
# Installs a gem from Rubyforge.
|
|
187
|
+
#
|
|
188
|
+
# @author Michael Fellinger (manveru)
|
|
189
|
+
# @since 19-05-2009
|
|
190
|
+
#
|
|
120
191
|
def rubyforge; 'http://gems.rubyforge.org/' end
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
end
|
|
192
|
+
end # GemSetup
|
|
193
|
+
end # Ramaze
|
data/lib/ramaze/spec.rb
CHANGED