manveru-ramaze 2008.09 → 2008.10
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/examples/app/rapaste/model/paste.rb +3 -0
- data/examples/app/rapaste/start.rb +1 -1
- data/examples/app/rapaste/view/view.xhtml +3 -0
- data/examples/helpers/httpdigest.rb +68 -10
- data/lib/proto/controller/init.rb +2 -1
- data/lib/proto/model/init.rb +3 -3
- data/lib/proto/start.rb +4 -0
- data/lib/ramaze/adapter/base.rb +2 -2
- data/lib/ramaze/contrib.rb +1 -1
- data/lib/ramaze/controller/resolve.rb +8 -3
- data/lib/ramaze/controller.rb +3 -0
- data/lib/ramaze/current/request.rb +2 -4
- data/lib/ramaze/dispatcher/action.rb +2 -2
- data/lib/ramaze/dispatcher/file.rb +2 -1
- data/lib/ramaze/dispatcher.rb +1 -1
- data/lib/ramaze/helper/formatting.rb +1 -1
- data/lib/ramaze/helper/httpdigest.rb +64 -24
- data/lib/ramaze/helper/paginate.rb +2 -3
- data/lib/ramaze/helper/partial.rb +1 -1
- data/lib/ramaze/helper/user.rb +4 -4
- data/lib/ramaze/helper.rb +3 -2
- data/lib/ramaze/log/rotatinginformer.rb +168 -0
- data/lib/ramaze/option/holder.rb +3 -3
- data/lib/ramaze/snippets/divide.rb +2 -0
- data/lib/ramaze/snippets/numeric/time.rb +1 -1
- data/lib/ramaze/snippets/object/acquire.rb +3 -6
- data/lib/ramaze/snippets/ordered_set.rb +21 -14
- data/lib/ramaze/snippets/ramaze/deprecated.rb +2 -1
- data/lib/ramaze/tool/localize.rb +8 -4
- data/lib/ramaze/tool/mime.rb +1 -1
- data/lib/ramaze/tool/project_creator.rb +2 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze.rb +2 -0
- data/rake_tasks/coverage.rake +4 -5
- data/rake_tasks/spec.rake +6 -6
- data/ramaze.gemspec +2 -1
- data/spec/contrib/profiling.rb +2 -2
- metadata +3 -2
- data/lib/ramaze/contrib/auto_params/get_args.rb +0 -58
- data/lib/ramaze/contrib/auto_params.rb +0 -135
- data/spec/contrib/auto_params.rb +0 -121
- data/spec/snippets/divide.rb +0 -19
- data/spec/snippets/object/acquire.rb +0 -71
@@ -6,6 +6,7 @@ class String
|
|
6
6
|
# Usage:
|
7
7
|
# 'a' / 'b' # => 'a/b'
|
8
8
|
def / obj
|
9
|
+
Ramaze.deprecated('String#/', 'File::join')
|
9
10
|
File.join(self, obj.to_s)
|
10
11
|
end
|
11
12
|
end
|
@@ -15,6 +16,7 @@ class Symbol
|
|
15
16
|
# Usage:
|
16
17
|
# :dir/:file # => 'dir/file'
|
17
18
|
def / obj
|
19
|
+
Ramaze.deprecated('Symbol#/', 'File::join(sym.to_s)')
|
18
20
|
self.to_s / obj
|
19
21
|
end
|
20
22
|
end
|
@@ -27,12 +27,9 @@ module Ramaze
|
|
27
27
|
# # require 'src/foo.rb' and 'src/bar.so' and 'src/foobar/baz.rb'
|
28
28
|
# acquire 'src/*', 'src/foobar/*'
|
29
29
|
|
30
|
-
def acquire
|
31
|
-
|
32
|
-
|
33
|
-
require file if file =~ /\.(rb|so)$/
|
34
|
-
end
|
35
|
-
end
|
30
|
+
def acquire(*globs)
|
31
|
+
Ramaze.deprecated('Object#acquire', 'Ramaze::acquire')
|
32
|
+
Ramaze.acquire(*globs)
|
36
33
|
end
|
37
34
|
end
|
38
35
|
|
@@ -22,23 +22,30 @@ class OrderedSet < BlankSlate
|
|
22
22
|
@set.uniq!
|
23
23
|
end
|
24
24
|
|
25
|
+
%w[ push unshift << ].each do |meth|
|
26
|
+
class_eval %[
|
27
|
+
def #{meth} *args
|
28
|
+
@set.delete(*args)
|
29
|
+
@set.#{meth}(*args)
|
30
|
+
end
|
31
|
+
]
|
32
|
+
end
|
33
|
+
|
34
|
+
def []= *args
|
35
|
+
@set.map! do |e|
|
36
|
+
if ::Array === args.last
|
37
|
+
args.last.include?(e) ? nil : e
|
38
|
+
else
|
39
|
+
args.last == e ? nil : e
|
40
|
+
end
|
41
|
+
end
|
42
|
+
@set.__send__(:[]=, *args)
|
43
|
+
@set.compact!
|
44
|
+
end
|
45
|
+
|
25
46
|
# Delegate everything, but controlled, keep elements unique.
|
26
47
|
# Warning, this is not really atomic.
|
27
48
|
def method_missing(meth, *args, &block)
|
28
|
-
case meth.to_s
|
29
|
-
when /push|unshift|\<\</
|
30
|
-
@set.delete(*args)
|
31
|
-
when '[]='
|
32
|
-
@set.map! do |e|
|
33
|
-
if ::Array === args.last
|
34
|
-
args.last.include?(e) ? nil : e
|
35
|
-
else
|
36
|
-
args.last == e ? nil : e
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
49
|
@set.__send__(meth, *args, &block)
|
41
|
-
ensure
|
42
|
-
@set.compact! if meth == :[]=
|
43
50
|
end
|
44
51
|
end
|
@@ -6,7 +6,8 @@ module Ramaze
|
|
6
6
|
def self.deprecated(from, to = nil)
|
7
7
|
message = "%s is deprecated"
|
8
8
|
message << ", use %s instead" unless to.nil?
|
9
|
-
|
9
|
+
message << " - from: %p"
|
10
|
+
Log.warn(message % [from, to, caller[1]])
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.const_missing(name)
|
data/lib/ramaze/tool/localize.rb
CHANGED
@@ -63,10 +63,14 @@ module Ramaze
|
|
63
63
|
|
64
64
|
def call(response, options = {})
|
65
65
|
return response unless trait[:enable]
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
response
|
66
|
+
|
67
|
+
body = []
|
68
|
+
|
69
|
+
response.body.each do |chunk|
|
70
|
+
body << localize_body(chunk, options)
|
71
|
+
end
|
72
|
+
|
73
|
+
response.body = body
|
70
74
|
end
|
71
75
|
|
72
76
|
# Localizes a response body. It reacts to a regular expression as given
|
data/lib/ramaze/tool/mime.rb
CHANGED
@@ -9,7 +9,7 @@ module Ramaze
|
|
9
9
|
module MIME
|
10
10
|
|
11
11
|
# the mime_types.yaml as full path, we use a copy of mongrels.
|
12
|
-
trait :types => YAML.load_file(BASEDIR
|
12
|
+
trait :types => YAML.load_file(File.join(BASEDIR, 'ramaze/tool/mime_types.yaml'))
|
13
13
|
|
14
14
|
class << self
|
15
15
|
|
data/lib/ramaze/version.rb
CHANGED
data/lib/ramaze.rb
CHANGED
data/rake_tasks/coverage.rake
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
4
|
require 'rake'
|
5
|
-
require 'lib/ramaze/snippets/divide'
|
6
5
|
|
7
6
|
spec_base = File.expand_path('spec/ramaze/')
|
8
7
|
example_base = File.expand_path('examples')
|
@@ -10,10 +9,10 @@ snippets_base = File.expand_path('spec/snippets')
|
|
10
9
|
# ignore files with these paths
|
11
10
|
ignores = [ './*', './helper/*', './ramaze/adapter.rb', './ramaze/request.rb', ]
|
12
11
|
|
13
|
-
files = Dir[spec_base
|
14
|
-
Dir[example_base
|
12
|
+
files = Dir["#{spec_base}/**/*.rb"] +
|
13
|
+
Dir["#{example_base}/**/spec/*.rb"]
|
15
14
|
ignores.each do |ignore|
|
16
|
-
ignore_files = Dir[spec_base
|
15
|
+
ignore_files = Dir["#{spec_base}/#{ignore}"]
|
17
16
|
ignore_files.each do |ignore_file|
|
18
17
|
files.delete File.expand_path(ignore_file)
|
19
18
|
end
|
@@ -35,7 +34,7 @@ task :coverage => :clean do
|
|
35
34
|
# IMHO, ideally we should have
|
36
35
|
# * 100% coverage of ramaze with pure tests
|
37
36
|
# * 100% coverage with non-pure functional tests
|
38
|
-
pure_specs = Dir[snippets_base
|
37
|
+
pure_specs = Dir["#{snippets_base}/**/*.rb"].entries
|
39
38
|
sys(COV_CMD % ["no-","t", pure_specs.join(' ')])
|
40
39
|
|
41
40
|
files.each do |file|
|
data/rake_tasks/spec.rake
CHANGED
@@ -11,18 +11,18 @@ task 'spec' do
|
|
11
11
|
non_verbose, non_fatal = ENV['non_verbose'], ENV['non_fatal']
|
12
12
|
require 'scanf'
|
13
13
|
|
14
|
-
root = File.expand_path(File.dirname(__FILE__)
|
15
|
-
libpath = root/
|
14
|
+
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
15
|
+
libpath = "#{root}/lib"
|
16
16
|
|
17
|
-
specs = Dir[root/
|
18
|
-
Dir[root/
|
17
|
+
specs = Dir["#{root}/spec/{ramaze,examples,snippets,contrib}/**/*.rb"] +
|
18
|
+
Dir["#{root}/examples/**/spec/**/*.rb"]
|
19
19
|
|
20
20
|
ignore = [
|
21
|
-
root/
|
21
|
+
"#{root}/spec/ramaze/request.rb",
|
22
22
|
].map{|i| Dir[i].map{|f| File.expand_path(f) }}.flatten
|
23
23
|
|
24
24
|
config = RbConfig::CONFIG
|
25
|
-
bin = config['bindir']
|
25
|
+
bin = File.join(config['bindir'], config['ruby_install_name'])
|
26
26
|
|
27
27
|
result_format = '%d tests, %d assertions, %d failures, %d errors'
|
28
28
|
|
data/ramaze.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "ramaze"
|
3
|
-
s.version = "2008.
|
3
|
+
s.version = "2008.10"
|
4
4
|
|
5
5
|
s.summary = "Ramaze is a simple and modular web framework"
|
6
6
|
s.description = "Ramaze is a simple and modular web framework"
|
@@ -429,6 +429,7 @@ Gem::Specification.new do |s|
|
|
429
429
|
"lib/ramaze/log/knotify.rb",
|
430
430
|
"lib/ramaze/log/logger.rb",
|
431
431
|
"lib/ramaze/log/logging.rb",
|
432
|
+
"lib/ramaze/log/rotatinginformer.rb",
|
432
433
|
"lib/ramaze/log/syslog.rb",
|
433
434
|
"lib/ramaze/log/xosd.rb",
|
434
435
|
"lib/ramaze/option",
|
data/spec/contrib/profiling.rb
CHANGED
@@ -15,14 +15,14 @@ Ramaze::Log.loggers << Ramaze::Logger::Informer.new(output)
|
|
15
15
|
|
16
16
|
describe 'Profiling' do
|
17
17
|
behaves_like "http"
|
18
|
-
ramaze :public_root => __DIR__
|
18
|
+
ramaze :public_root => File.join(__DIR__, 'public')
|
19
19
|
|
20
20
|
it "should profile" do
|
21
21
|
output = StringIO.new
|
22
22
|
Ramaze::Log.loggers << Ramaze::Logger::Informer.new(output)
|
23
23
|
|
24
24
|
get('/')
|
25
|
-
output.string.should =~ /Thread ID:\s
|
25
|
+
output.string.should =~ /Thread ID:\s-?\d+/
|
26
26
|
output.string.should =~ /Total:/
|
27
27
|
output.string.should =~ /self\s+total\s+self\s+wait\s+child\s+call/
|
28
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manveru-ramaze
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "2008.
|
4
|
+
version: "2008.10"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael 'manveru' Fellinger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-12-15 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -443,6 +443,7 @@ files:
|
|
443
443
|
- lib/ramaze/log/knotify.rb
|
444
444
|
- lib/ramaze/log/logger.rb
|
445
445
|
- lib/ramaze/log/logging.rb
|
446
|
+
- lib/ramaze/log/rotatinginformer.rb
|
446
447
|
- lib/ramaze/log/syslog.rb
|
447
448
|
- lib/ramaze/log/xosd.rb
|
448
449
|
- lib/ramaze/option
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# from merb/core_ext/get_args.rb
|
2
|
-
begin
|
3
|
-
require 'parse_tree'
|
4
|
-
require 'ruby2ruby'
|
5
|
-
|
6
|
-
class ParseTreeArray < Array
|
7
|
-
def self.translate(*args)
|
8
|
-
self.new(ParseTree.translate(*args))
|
9
|
-
end
|
10
|
-
|
11
|
-
def deep_array_node(type = nil)
|
12
|
-
each do |node|
|
13
|
-
return ParseTreeArray.new(node) if node.is_a?(Array) && (!type || node[0] == type)
|
14
|
-
next unless node.is_a?(Array)
|
15
|
-
return ParseTreeArray.new(node).deep_array_node(type)
|
16
|
-
end
|
17
|
-
nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def arg_nodes
|
21
|
-
self[1..-1].inject([]) do |sum,item|
|
22
|
-
sum << [item] unless item.is_a?(Array)
|
23
|
-
sum
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_args
|
28
|
-
arg_node = deep_array_node(:args)
|
29
|
-
return nil unless arg_node
|
30
|
-
args = arg_node.arg_nodes
|
31
|
-
default_node = arg_node.deep_array_node(:block)
|
32
|
-
return args unless default_node
|
33
|
-
lasgns = default_node[1..-1]
|
34
|
-
lasgns.each do |asgn|
|
35
|
-
args.assoc(asgn[1]) << eval(RubyToRuby.new.process(asgn[2]))
|
36
|
-
end
|
37
|
-
args
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
module GetArgs
|
43
|
-
def get_args
|
44
|
-
klass, meth = self.to_s.split(/ /).to_a[1][0..-2].split("#")
|
45
|
-
klass = $` if klass =~ /\(/
|
46
|
-
ParseTreeArray.translate(Object.const_get(klass), meth).get_args
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class UnboundMethod
|
51
|
-
include GetArgs
|
52
|
-
end
|
53
|
-
|
54
|
-
class Method
|
55
|
-
include GetArgs
|
56
|
-
end
|
57
|
-
rescue LoadError
|
58
|
-
end
|
@@ -1,135 +0,0 @@
|
|
1
|
-
# auto_params.rb
|
2
|
-
#
|
3
|
-
# AutoParams implements action parameterization ala merb 0.4 and Nitro
|
4
|
-
# using ruby2ruby and ParseTree
|
5
|
-
#
|
6
|
-
# Usage:
|
7
|
-
#
|
8
|
-
# Ramaze.contrib :auto_params
|
9
|
-
#
|
10
|
-
# Then, for example,
|
11
|
-
#
|
12
|
-
# def search(query) end
|
13
|
-
#
|
14
|
-
# can be accessed via
|
15
|
-
#
|
16
|
-
# - /search?query=findthis, which calls search('findthis')
|
17
|
-
# - /search/findthis search('findthis')
|
18
|
-
# - /search/findthis?query=andthis search(['findthis', 'andthis'])
|
19
|
-
#
|
20
|
-
# For more examples, take a look at spec/contrib/auto_params.rb
|
21
|
-
#
|
22
|
-
# Note: A simpler alternative for similar functionality would be:
|
23
|
-
#
|
24
|
-
# def search(query = request['query']) end
|
25
|
-
#
|
26
|
-
|
27
|
-
require __DIR__/:auto_params/:get_args
|
28
|
-
|
29
|
-
module Ramaze
|
30
|
-
|
31
|
-
module Contrib
|
32
|
-
class AutoParams
|
33
|
-
def self.startup
|
34
|
-
Ramaze::Cache.add :args
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class Action
|
40
|
-
|
41
|
-
# with parameterization, params may include
|
42
|
-
# arrays: /num?n=1&n=2 becomes [['1','2']] for def num(n) end
|
43
|
-
# nil: /calc?w=10&d=2 becomes ['10', nil, '2'] for def calc(w, h, d) end
|
44
|
-
|
45
|
-
def params=(*par)
|
46
|
-
par = *par
|
47
|
-
self[:params] = par.map{ |pa|
|
48
|
-
case pa
|
49
|
-
when Array
|
50
|
-
pa.map{|p| Rack::Utils.unescape(p)}
|
51
|
-
when nil
|
52
|
-
nil
|
53
|
-
else
|
54
|
-
Rack::Utils.unescape(pa)
|
55
|
-
end
|
56
|
-
} unless par.nil?
|
57
|
-
self[:params] ||= []
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
class Controller
|
63
|
-
|
64
|
-
# ignore cache when request.params is interesting
|
65
|
-
|
66
|
-
def self.cached(path)
|
67
|
-
if found = Cache.resolved[path]
|
68
|
-
if found.respond_to?(:relaxed_hash)
|
69
|
-
|
70
|
-
# don't use cache if we need to add request.params entries to the Action
|
71
|
-
if args = Cache.args[found.method]
|
72
|
-
param_keys = request.params.keys
|
73
|
-
return nil if args.find{|k,v| param_keys.include?(k.to_s) }
|
74
|
-
end
|
75
|
-
|
76
|
-
return found.dup
|
77
|
-
else
|
78
|
-
Log.warn("Found faulty `#{path}' in Cache.resolved, deleting it for sanity.")
|
79
|
-
Cache.resolved.delete path
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
nil
|
84
|
-
end
|
85
|
-
|
86
|
-
# use Method#get_args to insert values from request.params into Action#params
|
87
|
-
|
88
|
-
def self.resolve_method(name, *params)
|
89
|
-
if method = [ name, name.gsub('__','/') ].find{|n|
|
90
|
-
cached_action_methods.include?(n) }
|
91
|
-
meth = instance_method(method)
|
92
|
-
arity = meth.arity
|
93
|
-
|
94
|
-
if meth.respond_to? :get_args
|
95
|
-
unless args = Cache.args[name]
|
96
|
-
if args = meth.get_args
|
97
|
-
args = args.select{|e| e.to_s !~ /^\*/}
|
98
|
-
else
|
99
|
-
args = []
|
100
|
-
end
|
101
|
-
Cache.args[name] = args
|
102
|
-
end
|
103
|
-
|
104
|
-
param_keys = request.params.keys
|
105
|
-
|
106
|
-
# if there are missing args, or keys in request.params that match expected args
|
107
|
-
if args.size > params.size or args.find{|k,v| param_keys.include?(k.to_s) }
|
108
|
-
args.each_with_index do |(name, val), i|
|
109
|
-
r_params = request.params[name.to_s]
|
110
|
-
if params[i] and r_params and r_params.size > 0
|
111
|
-
params[i] = [params[i], r_params].flatten
|
112
|
-
else
|
113
|
-
params[i] ||= r_params
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
# strip trailing nils so default argument values are used
|
118
|
-
params.reverse.each{|e| if e.nil? then params.pop else break end }
|
119
|
-
end
|
120
|
-
|
121
|
-
argity = args.select{|e| e.size==1}.size..args.size
|
122
|
-
else
|
123
|
-
argity = arity..arity
|
124
|
-
end
|
125
|
-
|
126
|
-
if arity < 0 or argity.include? params.size
|
127
|
-
return method, params
|
128
|
-
end
|
129
|
-
end
|
130
|
-
return nil, []
|
131
|
-
end
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
data/spec/contrib/auto_params.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
require 'spec/helper'
|
2
|
-
spec_require 'parse_tree', 'ruby2ruby'
|
3
|
-
|
4
|
-
Ramaze.contrib :auto_params
|
5
|
-
|
6
|
-
module AnotherController
|
7
|
-
Ramaze::Helper::LOOKUP << self
|
8
|
-
|
9
|
-
def another_page
|
10
|
-
'another page'
|
11
|
-
end
|
12
|
-
|
13
|
-
define_method('css/style.css') { 'style.css' }
|
14
|
-
end
|
15
|
-
|
16
|
-
class MainController < Ramaze::Controller
|
17
|
-
include AnotherController
|
18
|
-
engine :None
|
19
|
-
|
20
|
-
def search query
|
21
|
-
query.inspect
|
22
|
-
end
|
23
|
-
|
24
|
-
def create name, age = '?', occupation = nil
|
25
|
-
[name, age, occupation].compact.join(', ')
|
26
|
-
end
|
27
|
-
|
28
|
-
def show *args
|
29
|
-
args.join(', ')
|
30
|
-
end
|
31
|
-
|
32
|
-
def add item, price = 1.0, *args
|
33
|
-
[item, price, *args].join(', ')
|
34
|
-
end
|
35
|
-
|
36
|
-
def find width, height, depth
|
37
|
-
[width, height, depth].join(', ')
|
38
|
-
end
|
39
|
-
|
40
|
-
define_method('page') do
|
41
|
-
'page'
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class GetArgsTest
|
46
|
-
def one(a, b, c) end
|
47
|
-
def two(a, b = 1, c = nil) end
|
48
|
-
def three(a, *args) end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'Method#get_args' do
|
52
|
-
it 'should return a list of arguments' do
|
53
|
-
gat = GetArgsTest.new
|
54
|
-
gat.method(:one).get_args.should == [[:a], [:b], [:c]]
|
55
|
-
gat.method(:two).get_args.should == [[:a], [:b, 1], [:c, nil]]
|
56
|
-
gat.method(:three).get_args.should == [[:a], [:"*args"]]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'Parameterized actions' do
|
61
|
-
behaves_like 'http'
|
62
|
-
ramaze
|
63
|
-
|
64
|
-
it 'should pass in values from request.params' do
|
65
|
-
get('/create/Aman/20').body.should == 'Aman, 20'
|
66
|
-
get('/create', :name => 'Aman', :age => 20).body.should == 'Aman, 20'
|
67
|
-
|
68
|
-
get('/create/Aman/20/Unemployed').body.should == 'Aman, 20, Unemployed'
|
69
|
-
get('/create', :name => 'Aman', :age => 20, :occupation => 'Unemployed').body.should == 'Aman, 20, Unemployed'
|
70
|
-
|
71
|
-
get('/create/Aman').body.should == 'Aman, ?'
|
72
|
-
get('/create', :name => 'Aman').body.should == 'Aman, ?'
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'should insert nil for arguments not found' do
|
76
|
-
get('/find', :width => 10, :depth => 20).body.should == '10, , 20'
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'should work with variable arguments' do
|
80
|
-
get('/show/1/2/3').body.should == '1, 2, 3'
|
81
|
-
|
82
|
-
get('/add/Shoe').body.should == 'Shoe, 1.0'
|
83
|
-
get('/add', :item => 'Shoe').body.should == 'Shoe, 1.0'
|
84
|
-
|
85
|
-
get('/add/Shoe/10.50/1/2/3').body.should == 'Shoe, 10.50, 1, 2, 3'
|
86
|
-
get('/add/Shoe/11.00').body.should == 'Shoe, 11.00'
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'should not break existing methods' do
|
90
|
-
get('/search/Aman').body.should == '"Aman"'
|
91
|
-
get('/search', 'query=Aman').body.should == '"Aman"'
|
92
|
-
get('/search/tmm1', 'query=Aman').body.should == ['tmm1','Aman'].inspect
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'should consolidate all values for the same key into an array' do
|
96
|
-
get('/add', 'item=Shoe&item=Shirt').body.should == 'Shoe, Shirt, 1.0'
|
97
|
-
get('/add/Pants', 'item=Shoe&item=Shirt').body.should == 'Pants, Shoe, Shirt, 1.0'
|
98
|
-
get('/add/Shoe', :item => 'Shirt').body.should == 'Shoe, Shirt, 1.0'
|
99
|
-
end
|
100
|
-
end if method(:puts).respond_to? :get_args
|
101
|
-
|
102
|
-
describe 'Normal behavior' do
|
103
|
-
behaves_like 'http'
|
104
|
-
ramaze
|
105
|
-
|
106
|
-
it 'should work with no arguments' do
|
107
|
-
get('/page').body.should == 'page'
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should raise no action' do
|
111
|
-
get('/none').body.should =~ /^No Action found/
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should work with included actions' do
|
115
|
-
get('/another_page').body.should == 'another page'
|
116
|
-
end
|
117
|
-
|
118
|
-
it 'should work with /' do
|
119
|
-
get('/css/style.css').body.should == 'style.css'
|
120
|
-
end
|
121
|
-
end
|
data/spec/snippets/divide.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'lib/ramaze/spec/helper/snippets'
|
2
|
-
|
3
|
-
describe 'String#/ and Symbol#/' do
|
4
|
-
it 'should join two strings' do
|
5
|
-
('a' / 'b').should == 'a/b'
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should join a string and a symbol' do
|
9
|
-
('a' / :b).should == 'a/b'
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should join two symbols' do
|
13
|
-
(:a / :b).should == 'a/b'
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should be usable in concatenation' do
|
17
|
-
('a' / :b / :c).should == 'a/b/c'
|
18
|
-
end
|
19
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'lib/ramaze/spec/helper/snippets'
|
2
|
-
require 'fileutils'
|
3
|
-
|
4
|
-
describe 'acquire' do
|
5
|
-
def require(name)
|
6
|
-
@required << name
|
7
|
-
end
|
8
|
-
|
9
|
-
before do
|
10
|
-
dir = 'tmp_dir_for_acquire'
|
11
|
-
FileUtils.mkdir_p(dir + '/sub')
|
12
|
-
|
13
|
-
%w[ foo.rb bar.rb baz.so baz.yml sub/baz.rb ].
|
14
|
-
each do |path|
|
15
|
-
FileUtils.touch("#{dir}/#{path}")
|
16
|
-
end
|
17
|
-
|
18
|
-
@required = []
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should not load a single file' do
|
22
|
-
acquire 'tmp_dir_for_acquire/foo'
|
23
|
-
@required.should == []
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should load dir' do
|
27
|
-
acquire 'tmp_dir_for_acquire/sub/*'
|
28
|
-
@required.should == %w[
|
29
|
-
tmp_dir_for_acquire/sub/baz.rb]
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should be aliased to acquire' do
|
33
|
-
acquire 'tmp_dir_for_acquire/sub/*'
|
34
|
-
@required.should.not.be.empty
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should load {so,rb}, not others' do
|
38
|
-
acquire 'tmp_dir_for_acquire/*'
|
39
|
-
@required.sort.should == %w[
|
40
|
-
tmp_dir_for_acquire/bar.rb
|
41
|
-
tmp_dir_for_acquire/baz.so
|
42
|
-
tmp_dir_for_acquire/foo.rb]
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should use globbing' do
|
46
|
-
acquire 'tmp_dir_for_acquire/ba*'
|
47
|
-
@required.sort.should == %w[
|
48
|
-
tmp_dir_for_acquire/bar.rb
|
49
|
-
tmp_dir_for_acquire/baz.so]
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should use recursive globbing' do
|
53
|
-
acquire 'tmp_dir_for_acquire/**/*'
|
54
|
-
@required.sort.should == %w[
|
55
|
-
tmp_dir_for_acquire/bar.rb
|
56
|
-
tmp_dir_for_acquire/baz.so
|
57
|
-
tmp_dir_for_acquire/foo.rb
|
58
|
-
tmp_dir_for_acquire/sub/baz.rb]
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should accept multiple arguments' do
|
62
|
-
acquire 'tmp_dir_for_acquire/*', 'tmp_dir_for_acquire/sub/*'
|
63
|
-
@required.sort.should == %w[
|
64
|
-
tmp_dir_for_acquire/bar.rb
|
65
|
-
tmp_dir_for_acquire/baz.so
|
66
|
-
tmp_dir_for_acquire/foo.rb
|
67
|
-
tmp_dir_for_acquire/sub/baz.rb]
|
68
|
-
end
|
69
|
-
|
70
|
-
FileUtils.rm_rf('tmp_dir_for_acquire')
|
71
|
-
end
|