manveru-innate 2009.02.06 → 2009.02.21
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +715 -0
- data/MANIFEST +3 -0
- data/Rakefile +120 -10
- data/example/app/retro_games.rb +29 -26
- data/innate.gemspec +4 -1
- data/lib/innate.rb +183 -131
- data/lib/innate/action.rb +21 -13
- data/lib/innate/cache.rb +2 -2
- data/lib/innate/cache/api.rb +28 -6
- data/lib/innate/dynamap.rb +47 -47
- data/lib/innate/helper/aspect.rb +4 -2
- data/lib/innate/helper/link.rb +8 -1
- data/lib/innate/helper/partial.rb +17 -15
- data/lib/innate/node.rb +203 -74
- data/lib/innate/options.rb +27 -2
- data/lib/innate/options/dsl.rb +16 -9
- data/lib/innate/request.rb +40 -5
- data/lib/innate/route.rb +7 -5
- data/lib/innate/session.rb +2 -1
- data/lib/innate/spec.rb +1 -1
- data/lib/innate/state/fiber.rb +3 -4
- data/lib/innate/traited.rb +7 -2
- data/lib/innate/version.rb +1 -1
- data/lib/innate/view.rb +1 -1
- data/lib/rack/middleware_compiler.rb +13 -3
- data/spec/innate/action/layout.rb +104 -0
- data/spec/innate/action/layout/file_layout.erb +1 -0
- data/spec/innate/cache/common.rb +4 -2
- data/spec/innate/helper.rb +20 -0
- data/spec/innate/helper/aspect.rb +4 -7
- data/spec/innate/helper/flash.rb +0 -11
- data/spec/innate/helper/link.rb +6 -0
- data/spec/innate/helper/partial.rb +18 -7
- data/spec/innate/node.rb +54 -22
- data/spec/innate/node/another_layout/another_layout.erb +3 -0
- data/spec/innate/options.rb +11 -8
- data/spec/innate/route.rb +8 -0
- data/spec/innate/session.rb +12 -16
- metadata +6 -2
data/spec/innate/helper.rb
CHANGED
@@ -63,4 +63,24 @@ describe Innate::Helper::Link do
|
|
63
63
|
FNL.a('duh/bar', 'duh/bar', :x => :y).should == '<a href="/foo/duh/bar?x=y">duh/bar</a>'
|
64
64
|
FNL.a('foo', :/, :x => :y).should == '<a href="/foo/?x=y">foo</a>'
|
65
65
|
end
|
66
|
+
|
67
|
+
should 'return module when Module is given to #each' do
|
68
|
+
Innate::HelpersHelper.each_extend(self, Innate::Helper::Link) do |p|
|
69
|
+
p.should == Innate::Helper::Link
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
should 'raise if helpers are not found' do
|
74
|
+
lambda{
|
75
|
+
Innate::HelpersHelper.each(:foo, :bar)
|
76
|
+
}.should.raise(LoadError).
|
77
|
+
message.should == "Helper foo not found"
|
78
|
+
end
|
79
|
+
|
80
|
+
should 'raise if helper is not found' do
|
81
|
+
lambda{
|
82
|
+
Innate::HelpersHelper.try_require(:foo)
|
83
|
+
}.should.raise(LoadError).
|
84
|
+
message.should == "Helper foo not found"
|
85
|
+
end
|
66
86
|
end
|
@@ -3,9 +3,7 @@ Innate.options.app.root = File.dirname(__FILE__)
|
|
3
3
|
Innate.options.app.view = ''
|
4
4
|
|
5
5
|
class AspectSpec
|
6
|
-
|
7
|
-
map '/'
|
8
|
-
provide :html => :none
|
6
|
+
Innate.node('/', self).provide(:html => :none)
|
9
7
|
|
10
8
|
before(:with_before){ $aspect_spec_before += 40 }
|
11
9
|
def with_before; $aspect_spec_before += 2; end
|
@@ -15,15 +13,13 @@ class AspectSpec
|
|
15
13
|
|
16
14
|
wrap(:with_wrap){ $aspect_spec_wrap += 20 }
|
17
15
|
def with_wrap; $aspect_spec_wrap += 2; end
|
18
|
-
|
16
|
+
|
19
17
|
before(:with_instance_var){ @foo = 'Hello'; @bar = 'World' }
|
20
18
|
def with_instance_var; "#{@foo} #{@bar}"; end
|
21
19
|
end
|
22
20
|
|
23
21
|
class AspectAllSpec
|
24
|
-
|
25
|
-
map '/all'
|
26
|
-
provide :html => :none
|
22
|
+
Innate.node('/all', self).provide(:html => :none)
|
27
23
|
|
28
24
|
before_all{ $aspect_spec_before_all += 40; @foo = 'Hello'; @bar = 'World' }
|
29
25
|
after_all{ $aspect_spec_after_all += 40 }
|
@@ -34,6 +30,7 @@ class AspectAllSpec
|
|
34
30
|
end
|
35
31
|
|
36
32
|
class AspecNoMethodSpec
|
33
|
+
Innate.node('/without_method', self)
|
37
34
|
include Innate::Node
|
38
35
|
map '/without_method'
|
39
36
|
view_root 'view'
|
data/spec/innate/helper/flash.rb
CHANGED
@@ -16,10 +16,6 @@ class SpecFlash
|
|
16
16
|
"Bye #{flash[:name]}"
|
17
17
|
end
|
18
18
|
|
19
|
-
def box
|
20
|
-
flashbox
|
21
|
-
end
|
22
|
-
|
23
19
|
def check_empty
|
24
20
|
flash.empty?.to_s
|
25
21
|
end
|
@@ -35,13 +31,6 @@ class SpecFlash
|
|
35
31
|
"Bye #{flash[:name]}"
|
36
32
|
end
|
37
33
|
|
38
|
-
def set(*hash)
|
39
|
-
Hash[*hash].each do |key, value|
|
40
|
-
flash[key] = value
|
41
|
-
end
|
42
|
-
hash.inspect
|
43
|
-
end
|
44
|
-
|
45
34
|
def merge!
|
46
35
|
flash.merge!(:name => 'feagliir').inspect
|
47
36
|
end
|
data/spec/innate/helper/link.rb
CHANGED
@@ -54,6 +54,12 @@ describe Innate::Helper::Link do
|
|
54
54
|
Two.route('/foo/bar', :a => :b).should == URI('/two/foo/bar?a=b')
|
55
55
|
Two.route(:foo, :bar, :a => :b).should == URI('/two/foo/bar?a=b')
|
56
56
|
end
|
57
|
+
|
58
|
+
should 'prefix the links as defined in the options' do
|
59
|
+
Innate.options.app.prefix = '/bar'
|
60
|
+
One.route('/foo').should == URI('/bar/foo')
|
61
|
+
Innate.options.app.prefix = '/'
|
62
|
+
end
|
57
63
|
end
|
58
64
|
|
59
65
|
describe '#anchor' do
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec/helper'
|
2
2
|
|
3
|
+
Innate.options.app.root = File.dirname(__FILE__)
|
3
4
|
class SpecHelperPartial
|
4
|
-
|
5
|
-
map '/'
|
5
|
+
Innate.node '/'
|
6
6
|
|
7
7
|
def index
|
8
8
|
'<html><head><title><%= render_partial("/title") %></title></head></html>'
|
@@ -25,17 +25,24 @@ class SpecHelperPartial
|
|
25
25
|
'From Action | ' << render_template("partial.erb")
|
26
26
|
end
|
27
27
|
|
28
|
-
def recursive
|
29
|
-
respond render_template('recursive_locals.erb', :n => 1) if locals
|
28
|
+
def recursive
|
30
29
|
@n = 1
|
31
30
|
end
|
32
31
|
|
33
32
|
def without_ext
|
34
|
-
render_template('
|
33
|
+
render_template('partial')
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
|
37
|
+
class SpecHelperPartialWithLayout < SpecHelperPartial
|
38
|
+
Innate.node '/with_layout'
|
39
|
+
layout('layout')
|
40
|
+
view_root '/'
|
41
|
+
|
42
|
+
def layout
|
43
|
+
'<h1>with layout</h1><%= @content %>'
|
44
|
+
end
|
45
|
+
end
|
39
46
|
|
40
47
|
describe Innate::Helper::Partial do
|
41
48
|
behaves_like :mock
|
@@ -61,6 +68,10 @@ describe Innate::Helper::Partial do
|
|
61
68
|
end
|
62
69
|
|
63
70
|
should 'not require file extension' do
|
64
|
-
get('/without_ext').body.should ==
|
71
|
+
get('/without_ext').body.should == "From Partial \n"
|
72
|
+
end
|
73
|
+
|
74
|
+
should 'render template with layout' do
|
75
|
+
get('/with_layout/without_ext').body.should == "<h1>with layout</h1>From Partial \n"
|
65
76
|
end
|
66
77
|
end
|
data/spec/innate/node.rb
CHANGED
@@ -5,9 +5,7 @@ Innate.options.app.view = ''
|
|
5
5
|
Innate.options.app.layout = 'node'
|
6
6
|
|
7
7
|
class SpecNode
|
8
|
-
|
9
|
-
map '/'
|
10
|
-
provide :html => :erb, :erb => :none
|
8
|
+
Innate.node('/').provide(:html => :erb, :erb => :none)
|
11
9
|
|
12
10
|
def foo; end
|
13
11
|
def bar; end
|
@@ -18,10 +16,7 @@ class SpecNode
|
|
18
16
|
end
|
19
17
|
|
20
18
|
class SpecNodeProvide
|
21
|
-
|
22
|
-
map '/provide'
|
23
|
-
|
24
|
-
provide :html => :erb, :erb => :none
|
19
|
+
Innate.node('/provide').provide(:html => :erb, :erb => :none)
|
25
20
|
|
26
21
|
def foo
|
27
22
|
'<%= 21 * 2 %>'
|
@@ -33,10 +28,8 @@ class SpecNodeProvide
|
|
33
28
|
end
|
34
29
|
|
35
30
|
class SpecNodeProvideTemplate
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
provide :html => :erb, :erb => :none
|
31
|
+
Innate.node('/provide_template')
|
32
|
+
provide(:html => :erb, :erb => :none, :yaml => :yaml, :json => :json)
|
40
33
|
|
41
34
|
view_root 'node'
|
42
35
|
end
|
@@ -52,15 +45,36 @@ class SpecNodeWithLayout < SpecNodeProvide
|
|
52
45
|
map '/layout'
|
53
46
|
end
|
54
47
|
|
48
|
+
class SpecNodeWithLayoutView < SpecNodeProvide
|
49
|
+
view_root 'node/another_layout'
|
50
|
+
layout 'another_layout'
|
51
|
+
map '/another_layout'
|
52
|
+
end
|
53
|
+
|
54
|
+
class SpecNodeWithLayoutMethod < SpecNodeProvide
|
55
|
+
map '/layout_method'
|
56
|
+
layout 'layout_method'
|
57
|
+
|
58
|
+
def layout_method
|
59
|
+
'<div class="content"><%= @content %></div>'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
55
63
|
class SpecNodeIndex
|
56
|
-
|
57
|
-
map '/spec_index'
|
64
|
+
Innate.node('/spec_index')
|
58
65
|
|
59
66
|
def index
|
60
67
|
"I have no parameters"
|
61
68
|
end
|
62
69
|
end
|
63
70
|
|
71
|
+
class SpecNodeAliasView < SpecNodeProvideTemplate
|
72
|
+
map '/alias_view'
|
73
|
+
view_root 'node'
|
74
|
+
|
75
|
+
alias_view :aliased, :bar
|
76
|
+
end
|
77
|
+
|
64
78
|
describe 'Innate::Node' do
|
65
79
|
behaves_like :mock
|
66
80
|
|
@@ -72,6 +86,12 @@ describe 'Innate::Node' do
|
|
72
86
|
end
|
73
87
|
end
|
74
88
|
|
89
|
+
def assert_wish(url, body, content_type)
|
90
|
+
got = get(url)
|
91
|
+
got.body.strip.should == body
|
92
|
+
got.headers['Content-Type'].should == content_type
|
93
|
+
end
|
94
|
+
|
75
95
|
should 'resolve actions with methods' do
|
76
96
|
SpecNode.resolve('/').should.be.nil
|
77
97
|
SpecNode.resolve('/index').should.be.nil
|
@@ -116,12 +136,6 @@ describe 'Innate::Node' do
|
|
116
136
|
SpecNodeSub.resolve('/bar').should.be.nil
|
117
137
|
end
|
118
138
|
|
119
|
-
def assert_wish(url, body, content_type)
|
120
|
-
got = get(url)
|
121
|
-
got.body.strip.should == body
|
122
|
-
got.headers['Content-Type'].should == content_type
|
123
|
-
end
|
124
|
-
|
125
139
|
should 'provide html if no wish given' do
|
126
140
|
assert_wish('/provide/foo', '42', 'text/html')
|
127
141
|
assert_wish('/provide/bar', '42', 'text/html')
|
@@ -143,7 +157,7 @@ describe 'Innate::Node' do
|
|
143
157
|
assert_wish('/provide_template/bar.erb', "<h1>Hello, World!</h1>",
|
144
158
|
'text/html')
|
145
159
|
|
146
|
-
expected =
|
160
|
+
expected = '0123456789'
|
147
161
|
assert_wish('/provide_template/foo.html', expected, 'text/html')
|
148
162
|
# assert_wish('/provide_template/foo.erb', expected, 'text/plain')
|
149
163
|
end
|
@@ -151,7 +165,7 @@ describe 'Innate::Node' do
|
|
151
165
|
should 'respond with 404 if no action was found' do
|
152
166
|
got = Innate::Mock.get('/does_not_exist')
|
153
167
|
got.status.should == 404
|
154
|
-
got.body.should == '
|
168
|
+
got.body.should == 'No action found at: "/does_not_exist"'
|
155
169
|
got['Content-Type'].should == 'text/plain'
|
156
170
|
end
|
157
171
|
|
@@ -172,9 +186,27 @@ describe 'Innate::Node' do
|
|
172
186
|
got['Content-Type'].should == 'text/html'
|
173
187
|
end
|
174
188
|
|
189
|
+
should 'find layout with view_root' do
|
190
|
+
got = Innate::Mock.get('/another_layout/bar')
|
191
|
+
got.status.should == 200
|
192
|
+
got.body.should == %(<div class="content">\n 42\n</div>\n)
|
193
|
+
got['Content-Type'].should == 'text/html'
|
194
|
+
end
|
195
|
+
|
196
|
+
should 'find layout from method' do
|
197
|
+
got = Innate::Mock.get('/layout_method/bar')
|
198
|
+
got.status.should == 200
|
199
|
+
got.body.should == %(<div class="content">42</div>)
|
200
|
+
got['Content-Type'].should == 'text/html'
|
201
|
+
end
|
202
|
+
|
175
203
|
should 'not get an action with wrong parameters' do
|
176
204
|
got = Innate::Mock.get('/spec_index/bar')
|
177
205
|
got.status.should == 404
|
178
|
-
got.body.should == '
|
206
|
+
got.body.should == 'No action found at: "/bar"'
|
207
|
+
end
|
208
|
+
|
209
|
+
should 'use alias_view' do
|
210
|
+
assert_wish('/alias_view/aliased', "<h1>Hello, World!</h1>", 'text/html')
|
179
211
|
end
|
180
212
|
end
|
data/spec/innate/options.rb
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'lib/innate/options/dsl'
|
3
|
-
|
4
|
-
require 'bacon'
|
5
|
-
|
6
|
-
Bacon.extend(Bacon::TestUnitOutput)
|
7
|
-
Bacon.summary_on_exit
|
1
|
+
require 'spec/helper'
|
8
2
|
|
9
3
|
Options = Innate::Options
|
10
4
|
|
@@ -51,7 +45,8 @@ describe Options do
|
|
51
45
|
end
|
52
46
|
|
53
47
|
should 'get sub-sub option' do
|
54
|
-
@options.get(:deep, :down, :me).
|
48
|
+
@options.get(:deep, :down, :me).
|
49
|
+
should == {:value => :too, :doc => 'deep down', :trigger=> nil}
|
55
50
|
end
|
56
51
|
|
57
52
|
should 'respond with nil on getting missing option' do
|
@@ -87,4 +82,12 @@ describe Options do
|
|
87
82
|
@options.pretty_print(p)
|
88
83
|
p.output.should =~ /:value=>4000/
|
89
84
|
end
|
85
|
+
|
86
|
+
should 'trigger block when option is changed' do
|
87
|
+
set = nil
|
88
|
+
@options.trigger(:port){|value| set = value }
|
89
|
+
set.should.be.nil
|
90
|
+
@options.port = 300
|
91
|
+
set.should == 300
|
92
|
+
end
|
90
93
|
end
|
data/spec/innate/route.rb
CHANGED
@@ -126,4 +126,12 @@ describe Innate::Rewrite do
|
|
126
126
|
got.status.should == 200
|
127
127
|
got.body.should == 'this is bar'
|
128
128
|
end
|
129
|
+
|
130
|
+
it 'should rewite with (key, val)' do
|
131
|
+
Innate::Rewrite[ %r!^/(.+)$! ] = nil
|
132
|
+
Innate::Rewrite(%r!^/(.+)$!, "/string/%s")
|
133
|
+
got = Innate::Mock.get('/hello')
|
134
|
+
got.status.should == 200
|
135
|
+
got.body.should == 'String: hello'
|
136
|
+
end
|
129
137
|
end
|
data/spec/innate/session.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'spec/helper'
|
2
2
|
|
3
|
-
class
|
4
|
-
|
5
|
-
map '/'
|
6
|
-
provide :html => :none
|
3
|
+
class SpecSession
|
4
|
+
Innate.node('/').provide(:html => :none)
|
7
5
|
|
8
6
|
def index
|
9
7
|
'No session here'
|
@@ -30,29 +28,27 @@ class SessionSpec
|
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
|
-
|
31
|
+
describe Innate::Session do
|
32
|
+
behaves_like :session
|
34
33
|
|
35
|
-
Innate.setup_dependencies
|
36
|
-
|
37
|
-
describe 'Innate::Session' do
|
38
34
|
should 'initiate session as needed' do
|
39
|
-
|
40
|
-
response =
|
35
|
+
session do |mock|
|
36
|
+
response = mock.get('/')
|
41
37
|
response.body.should == 'No session here'
|
42
38
|
response['Set-Cookie'].should == nil
|
43
39
|
|
44
|
-
|
40
|
+
mock.get('/init').body.should == '0'
|
45
41
|
|
46
42
|
1.upto(10) do |n|
|
47
|
-
|
43
|
+
mock.get('/increment').body.should == n.to_s
|
48
44
|
end
|
49
45
|
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
mock.get('/reset')
|
47
|
+
mock.get('/view').body.should == ''
|
48
|
+
mock.get('/init').body.should == '0'
|
53
49
|
|
54
50
|
-1.downto(-10) do |n|
|
55
|
-
|
51
|
+
mock.get('/decrement').body.should == n.to_s
|
56
52
|
end
|
57
53
|
end
|
58
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manveru-innate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2009.02.
|
4
|
+
version: 2009.02.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael 'manveru' Fellinger
|
@@ -9,11 +9,12 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-02-
|
12
|
+
date: 2009-02-13 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|
17
|
+
type: :runtime
|
17
18
|
version_requirement:
|
18
19
|
version_requirements: !ruby/object:Gem::Requirement
|
19
20
|
requirements:
|
@@ -100,6 +101,8 @@ files:
|
|
100
101
|
- spec/example/hello.rb
|
101
102
|
- spec/example/link.rb
|
102
103
|
- spec/helper.rb
|
104
|
+
- spec/innate/action/layout.rb
|
105
|
+
- spec/innate/action/layout/file_layout.erb
|
103
106
|
- spec/innate/cache/common.rb
|
104
107
|
- spec/innate/cache/marshal.rb
|
105
108
|
- spec/innate/cache/memory.rb
|
@@ -121,6 +124,7 @@ files:
|
|
121
124
|
- spec/innate/helper/view/recursive.erb
|
122
125
|
- spec/innate/mock.rb
|
123
126
|
- spec/innate/node.rb
|
127
|
+
- spec/innate/node/another_layout/another_layout.erb
|
124
128
|
- spec/innate/node/bar.html
|
125
129
|
- spec/innate/node/foo.html.erb
|
126
130
|
- spec/innate/node/with_layout.erb
|