merb-core 0.9.13 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -3
- data/lib/merb-core.rb +84 -41
- data/lib/merb-core/bootloader.rb +71 -60
- data/lib/merb-core/config.rb +31 -17
- data/lib/merb-core/controller/abstract_controller.rb +35 -35
- data/lib/merb-core/controller/exceptions.rb +14 -9
- data/lib/merb-core/controller/merb_controller.rb +22 -20
- data/lib/merb-core/controller/mime.rb +5 -5
- data/lib/merb-core/controller/mixins/authentication.rb +11 -8
- data/lib/merb-core/controller/mixins/conditional_get.rb +7 -7
- data/lib/merb-core/controller/mixins/controller.rb +15 -15
- data/lib/merb-core/controller/mixins/render.rb +16 -16
- data/lib/merb-core/controller/mixins/responder.rb +23 -23
- data/lib/merb-core/controller/template.rb +17 -17
- data/lib/merb-core/core_ext/hash.rb +2 -2
- data/lib/merb-core/core_ext/kernel.rb +19 -18
- data/lib/merb-core/dispatch/cookies.rb +13 -0
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +12 -1
- data/lib/merb-core/dispatch/dispatcher.rb +6 -5
- data/lib/merb-core/dispatch/request.rb +56 -52
- data/lib/merb-core/dispatch/request_parsers.rb +7 -7
- data/lib/merb-core/dispatch/router.rb +14 -14
- data/lib/merb-core/dispatch/router/behavior.rb +31 -31
- data/lib/merb-core/dispatch/router/cached_proc.rb +13 -1
- data/lib/merb-core/dispatch/router/resources.rb +9 -9
- data/lib/merb-core/dispatch/router/route.rb +60 -7
- data/lib/merb-core/dispatch/session.rb +21 -15
- data/lib/merb-core/dispatch/session/container.rb +10 -8
- data/lib/merb-core/dispatch/session/cookie.rb +12 -11
- data/lib/merb-core/dispatch/session/memcached.rb +4 -2
- data/lib/merb-core/dispatch/session/memory.rb +8 -6
- data/lib/merb-core/dispatch/session/store_container.rb +6 -5
- data/lib/merb-core/dispatch/worker.rb +28 -10
- data/lib/merb-core/gem_ext/erubis.rb +4 -2
- data/lib/merb-core/logger.rb +3 -22
- data/lib/merb-core/plugins.rb +5 -5
- data/lib/merb-core/rack.rb +1 -1
- data/lib/merb-core/rack/adapter.rb +5 -1
- data/lib/merb-core/rack/adapter/abstract.rb +15 -10
- data/lib/merb-core/rack/adapter/ebb.rb +4 -2
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -1
- data/lib/merb-core/rack/adapter/fcgi.rb +3 -1
- data/lib/merb-core/rack/adapter/irb.rb +10 -1
- data/lib/merb-core/rack/adapter/mongrel.rb +5 -2
- data/lib/merb-core/rack/adapter/runner.rb +3 -1
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +2 -1
- data/lib/merb-core/rack/adapter/thin.rb +4 -1
- data/lib/merb-core/rack/adapter/thin_turbo.rb +1 -0
- data/lib/merb-core/rack/adapter/webrick.rb +8 -34
- data/lib/merb-core/rack/application.rb +2 -2
- data/lib/merb-core/rack/handler/mongrel.rb +7 -0
- data/lib/merb-core/rack/helpers.rb +1 -1
- data/lib/merb-core/rack/middleware.rb +7 -1
- data/lib/merb-core/rack/middleware/conditional_get.rb +3 -0
- data/lib/merb-core/rack/middleware/content_length.rb +2 -0
- data/lib/merb-core/rack/middleware/path_prefix.rb +4 -0
- data/lib/merb-core/rack/middleware/profiler.rb +3 -1
- data/lib/merb-core/rack/middleware/static.rb +7 -1
- data/lib/merb-core/rack/middleware/tracer.rb +1 -0
- data/lib/merb-core/rack/stream_wrapper.rb +35 -30
- data/lib/merb-core/server.rb +17 -16
- data/lib/merb-core/tasks/gem_management.rb +1 -1
- data/lib/merb-core/tasks/merb.rb +3 -1
- data/lib/merb-core/tasks/merb_rake_helper.rb +1 -1
- data/lib/merb-core/test.rb +8 -8
- data/lib/merb-core/test/helpers.rb +1 -1
- data/lib/merb-core/test/helpers/cookie_jar.rb +16 -2
- data/lib/merb-core/test/helpers/mock_request_helper.rb +13 -13
- data/lib/merb-core/test/helpers/request_helper.rb +1 -1
- data/lib/merb-core/test/helpers/route_helper.rb +2 -2
- data/lib/merb-core/test/matchers.rb +3 -3
- data/lib/merb-core/test/matchers/request_matchers.rb +1 -1
- data/lib/merb-core/test/run_spec.rb +1 -1
- data/lib/merb-core/test/tasks/spectasks.rb +1 -1
- data/lib/merb-core/test/test_ext/hpricot.rb +1 -1
- data/lib/merb-core/test/test_ext/rspec.rb +2 -2
- data/lib/merb-core/test/test_ext/string.rb +1 -1
- data/lib/merb-core/version.rb +1 -1
- metadata +8 -22
- data/lib/merb-core/test/matchers/view_matchers.rb +0 -231
- data/lib/merb-core/test/webrat.rb +0 -37
- data/lib/merb-core/vendor/nokogiri/css.rb +0 -6
- data/lib/merb-core/vendor/nokogiri/css/generated_parser.rb +0 -653
- data/lib/merb-core/vendor/nokogiri/css/generated_tokenizer.rb +0 -159
- data/lib/merb-core/vendor/nokogiri/css/node.rb +0 -95
- data/lib/merb-core/vendor/nokogiri/css/parser.rb +0 -24
- data/lib/merb-core/vendor/nokogiri/css/parser.y +0 -198
- data/lib/merb-core/vendor/nokogiri/css/tokenizer.rb +0 -9
- data/lib/merb-core/vendor/nokogiri/css/tokenizer.rex +0 -63
- data/lib/merb-core/vendor/nokogiri/css/xpath_visitor.rb +0 -159
@@ -1,63 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
module CSS
|
3
|
-
class GeneratedTokenizer
|
4
|
-
|
5
|
-
macro
|
6
|
-
nl \n|\r\n|\r|\f
|
7
|
-
w [\s\r\n\f]*
|
8
|
-
nonascii [^\\\\0-\\\\177]
|
9
|
-
num -?([0-9]+|[0-9]*\.[0-9]+)
|
10
|
-
unicode \\\\\\\\\[0-9a-f]{1,6}(\r\n|[\s\n\r\t\f])?
|
11
|
-
|
12
|
-
escape {unicode}|\\\\\\\[^\n\r\f0-9a-f]
|
13
|
-
nmchar [_a-z0-9-]|{nonascii}|{escape}
|
14
|
-
nmstart [_a-z]|{nonascii}|{escape}
|
15
|
-
ident [-]?({nmstart})({nmchar})*
|
16
|
-
name ({nmchar})+
|
17
|
-
string1 "([^\n\r\f"]|\\{nl}|{nonascii}|{escape})*"
|
18
|
-
string2 '([^\n\r\f']|\\{nl}|{nonascii}|{escape})*'
|
19
|
-
string {string1}|{string2}
|
20
|
-
invalid1 \"([^\n\r\f\\"]|\\{nl}|{nonascii}|{escape})*
|
21
|
-
invalid2 \'([^\n\r\f\\']|\\{nl}|{nonascii}|{escape})*
|
22
|
-
invalid {invalid1}|{invalid2}
|
23
|
-
Comment \/\*(.|[\r\n])*?\*\/
|
24
|
-
|
25
|
-
rule
|
26
|
-
|
27
|
-
# [:state] pattern [actions]
|
28
|
-
|
29
|
-
~= { [:INCLUDES, text] }
|
30
|
-
\|= { [:DASHMATCH, text] }
|
31
|
-
\^= { [:PREFIXMATCH, text] }
|
32
|
-
\$= { [:SUFFIXMATCH, text] }
|
33
|
-
\*= { [:SUBSTRINGMATCH, text] }
|
34
|
-
!= { [:NOT_EQUAL, text] }
|
35
|
-
{ident}\(\s* { [:FUNCTION, text] }
|
36
|
-
@{ident} { [:IDENT, text] }
|
37
|
-
{ident} { [:IDENT, text] }
|
38
|
-
{num} { [:NUMBER, text] }
|
39
|
-
\#{name} { [:HASH, text] }
|
40
|
-
{w}\+ { [:PLUS, text] }
|
41
|
-
{w}> { [:GREATER, text] }
|
42
|
-
{w}, { [:COMMA, text] }
|
43
|
-
{w}~ { [:TILDE, text] }
|
44
|
-
\:not\( { [:NOT, text] }
|
45
|
-
@{ident} { [:ATKEYWORD, text] }
|
46
|
-
{num}% { [:PERCENTAGE, text] }
|
47
|
-
{num}{ident} { [:DIMENSION, text] }
|
48
|
-
<!-- { [:CDO, text] }
|
49
|
-
--> { [:CDC, text] }
|
50
|
-
{w}\/\/ { [:DOUBLESLASH, text] }
|
51
|
-
{w}\/ { [:SLASH, text] }
|
52
|
-
|
53
|
-
U\+[0-9a-f?]{1,6}(-[0-9a-f]{1,6})? {[:UNICODE_RANGE, text] }
|
54
|
-
|
55
|
-
{Comment} /* ignore comments */
|
56
|
-
[\s\t\r\n\f]+ { [:S, text] }
|
57
|
-
[\.*:\[\]=\)] { [text, text] }
|
58
|
-
{string} { [:STRING, text] }
|
59
|
-
{invalid} { [:INVALID, text] }
|
60
|
-
. { [text, text] }
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,159 +0,0 @@
|
|
1
|
-
module Nokogiri
|
2
|
-
module CSS
|
3
|
-
class XPathVisitor
|
4
|
-
def visit_function node
|
5
|
-
# note that nth-child and nth-last-child are preprocessed in css/node.rb.
|
6
|
-
case node.value.first
|
7
|
-
when /^text\(/
|
8
|
-
'child::text()'
|
9
|
-
when /^self\(/
|
10
|
-
"self::#{node.value[1]}"
|
11
|
-
when /^(eq|nth|nth-of-type|nth-child)\(/
|
12
|
-
if node.value[1].is_a?(Nokogiri::CSS::Node) and node.value[1].type == :AN_PLUS_B
|
13
|
-
an_plus_b(node.value[1])
|
14
|
-
else
|
15
|
-
"position() = " + node.value[1]
|
16
|
-
end
|
17
|
-
when /^(first|first-of-type)\(/
|
18
|
-
"position() = 1"
|
19
|
-
when /^(last|last-of-type)\(/
|
20
|
-
"position() = last()"
|
21
|
-
when /^(nth-last-child|nth-last-of-type)\(/
|
22
|
-
"position() = last() - #{node.value[1]}"
|
23
|
-
when /^contains\(/
|
24
|
-
"contains(., #{node.value[1]})"
|
25
|
-
when /^gt\(/
|
26
|
-
"position() > #{node.value[1]}"
|
27
|
-
when /^only-child\(/
|
28
|
-
"last() = 1"
|
29
|
-
else
|
30
|
-
node.value.first + ')'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def visit_not node
|
35
|
-
'not(' + node.value.first.accept(self) + ')'
|
36
|
-
end
|
37
|
-
|
38
|
-
def visit_preceding_selector node
|
39
|
-
node.value.last.accept(self) +
|
40
|
-
'[preceding-sibling::' +
|
41
|
-
node.value.first.accept(self) +
|
42
|
-
']'
|
43
|
-
end
|
44
|
-
|
45
|
-
def visit_direct_adjacent_selector node
|
46
|
-
node.value.last.accept(self) +
|
47
|
-
'[preceding-sibling::' +
|
48
|
-
node.value.first.accept(self) +
|
49
|
-
'][position()=1]'
|
50
|
-
end
|
51
|
-
|
52
|
-
def visit_id node
|
53
|
-
node.value.first =~ /^#(.*)$/
|
54
|
-
"@id = '#{$1}'"
|
55
|
-
end
|
56
|
-
|
57
|
-
def visit_attribute_condition node
|
58
|
-
attribute = if (node.value.first.type == :FUNCTION) or (node.value.first.value.first =~ /::/)
|
59
|
-
''
|
60
|
-
else
|
61
|
-
'@'
|
62
|
-
end
|
63
|
-
attribute += node.value.first.accept(self)
|
64
|
-
|
65
|
-
# Support non-standard css
|
66
|
-
attribute.gsub!(/^@@/, '@')
|
67
|
-
|
68
|
-
return attribute unless node.value.length == 3
|
69
|
-
|
70
|
-
value = node.value.last
|
71
|
-
value = "'#{value}'" if value !~ /^['"]/
|
72
|
-
|
73
|
-
case node.value[1]
|
74
|
-
when '*='
|
75
|
-
"contains(#{attribute}, #{value})"
|
76
|
-
when '^='
|
77
|
-
"starts-with(#{attribute}, #{value})"
|
78
|
-
when '|='
|
79
|
-
"#{attribute} = #{value} or starts-with(#{attribute}, concat(#{value}, '-'))"
|
80
|
-
when '~='
|
81
|
-
"contains(concat(\" \", #{attribute}, \" \"),concat(\" \", #{value}, \" \"))"
|
82
|
-
when '$='
|
83
|
-
"substring(#{attribute}, string-length(#{attribute}) - " +
|
84
|
-
"string-length(#{value}) + 1, string-length(#{value})) = #{value}"
|
85
|
-
else
|
86
|
-
attribute + " #{node.value[1]} " + "#{value}"
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def visit_pseudo_class node
|
91
|
-
if node.value.first.is_a?(Nokogiri::CSS::Node) and node.value.first.type == :FUNCTION
|
92
|
-
node.value.first.accept(self)
|
93
|
-
else
|
94
|
-
case node.value.first
|
95
|
-
when "first" then "position() = 1"
|
96
|
-
when "last" then "position() = last()"
|
97
|
-
when "first-of-type" then "position() = 1"
|
98
|
-
when "last-of-type" then "position() = last()"
|
99
|
-
when "only-of-type" then "last() = 1"
|
100
|
-
when "empty" then "not(node())"
|
101
|
-
when "parent" then "node()"
|
102
|
-
else
|
103
|
-
'1 = 1'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def visit_class_condition node
|
109
|
-
"contains(concat(' ', @class, ' '),concat(' ', '#{node.value.first}', ' '))"
|
110
|
-
end
|
111
|
-
|
112
|
-
def visit_combinator node
|
113
|
-
node.value.first.accept(self) + ' and ' +
|
114
|
-
node.value.last.accept(self)
|
115
|
-
end
|
116
|
-
|
117
|
-
def visit_conditional_selector node
|
118
|
-
node.value.first.accept(self) + '[' +
|
119
|
-
node.value.last.accept(self) + ']'
|
120
|
-
end
|
121
|
-
|
122
|
-
def visit_descendant_selector node
|
123
|
-
node.value.first.accept(self) +
|
124
|
-
'//' +
|
125
|
-
node.value.last.accept(self)
|
126
|
-
end
|
127
|
-
|
128
|
-
def visit_child_selector node
|
129
|
-
node.value.first.accept(self) +
|
130
|
-
'/' +
|
131
|
-
node.value.last.accept(self)
|
132
|
-
end
|
133
|
-
|
134
|
-
def visit_element_name node
|
135
|
-
node.value.first
|
136
|
-
end
|
137
|
-
|
138
|
-
def accept node
|
139
|
-
node.accept(self)
|
140
|
-
end
|
141
|
-
|
142
|
-
private
|
143
|
-
def an_plus_b node
|
144
|
-
raise ArgumentError, "expected an+b node to contain 4 tokens, but is #{node.value.inspect}" unless node.value.size == 4
|
145
|
-
|
146
|
-
a = node.value[0].to_i
|
147
|
-
b = node.value[3].to_i
|
148
|
-
|
149
|
-
if (b == 0)
|
150
|
-
return "(position() mod #{a}) = 0"
|
151
|
-
else
|
152
|
-
compare = (a < 0) ? "<=" : ">="
|
153
|
-
return "(position() #{compare} #{b}) and (((position()-#{b}) mod #{a.abs}) = 0)"
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
end
|
158
|
-
end
|
159
|
-
end
|