manveru-innate 2009.04 → 2009.04.01
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -258
- data/MANIFEST +22 -23
- data/README.md +9 -1
- data/Rakefile +6 -6
- data/example/app/retro_games.rb +8 -8
- data/example/app/todo/layout/{default.xhtml → default.erb} +1 -1
- data/example/app/todo/view/{index.xhtml → index.erb} +11 -11
- data/example/app/whywiki_erb/start.rb +1 -2
- data/example/app/whywiki_erb/view/{edit.erb → edit.html.erb} +0 -0
- data/example/app/whywiki_erb/view/{index.erb → index.html.erb} +0 -0
- data/example/howto_spec.rb +1 -1
- data/example/provides.rb +6 -9
- data/example/session.rb +3 -3
- data/innate.gemspec +14 -6
- data/lib/innate.rb +18 -12
- data/lib/innate/action.rb +11 -22
- data/lib/innate/cache/file_based.rb +0 -2
- data/lib/innate/core_compatibility/basic_object.rb +10 -0
- data/lib/innate/core_compatibility/string.rb +3 -0
- data/lib/innate/dynamap.rb +0 -5
- data/lib/innate/helper.rb +29 -20
- data/lib/innate/helper/cgi.rb +19 -32
- data/lib/innate/helper/link.rb +2 -2
- data/lib/innate/helper/partial.rb +93 -0
- data/lib/innate/helper/redirect.rb +1 -1
- data/lib/innate/helper/send_file.rb +1 -9
- data/lib/innate/mock.rb +3 -2
- data/lib/innate/node.rb +51 -78
- data/lib/innate/options.rb +1 -1
- data/lib/innate/request.rb +23 -3
- data/lib/innate/response.rb +7 -0
- data/lib/innate/session.rb +2 -1
- data/lib/innate/spec.rb +50 -6
- data/lib/innate/version.rb +1 -1
- data/lib/innate/view/erb.rb +1 -1
- data/lib/innate/view/etanni.rb +2 -2
- data/lib/innate/view/none.rb +1 -1
- data/spec/example/session.rb +14 -8
- data/spec/innate/action/layout.rb +1 -1
- data/spec/innate/action/layout/file_layout.erb +1 -0
- data/spec/innate/helper/aspect.rb +6 -6
- data/spec/innate/helper/flash.rb +47 -28
- data/spec/innate/helper/link.rb +0 -8
- data/spec/innate/helper/partial.rb +101 -0
- data/spec/innate/helper/redirect.rb +43 -58
- data/spec/innate/helper/view/aspect_hello.erb +1 -0
- data/spec/innate/helper/view/locals.erb +1 -0
- data/spec/innate/helper/view/loop.erb +4 -0
- data/spec/innate/helper/view/num.erb +1 -0
- data/spec/innate/helper/view/partial.erb +1 -0
- data/spec/innate/helper/view/recursive.erb +8 -0
- data/spec/innate/node/node.rb +13 -5
- data/spec/innate/node/view/another_layout/{another_layout.xhtml → another_layout.erb} +1 -1
- data/spec/innate/node/view/{bar.xhtml → bar.erb} +0 -0
- data/spec/innate/node/view/foo.html.erb +1 -0
- data/spec/innate/node/view/{only_view.xhtml → only_view.erb} +0 -0
- data/spec/innate/node/view/with_layout.erb +1 -0
- data/spec/innate/provides.rb +2 -2
- data/spec/innate/provides/list.html.erb +1 -0
- data/spec/innate/provides/list.txt.erb +1 -0
- data/spec/innate/session.rb +15 -14
- data/spec/innate/state/fiber.rb +7 -8
- data/tasks/bacon.rake +21 -38
- data/tasks/install_dependencies.rake +4 -2
- data/tasks/release.rake +9 -48
- metadata +57 -29
- data/lib/innate/helper/render.rb +0 -87
- data/spec/example/app/retro_games.rb +0 -30
- data/spec/example/provides.rb +0 -16
- data/spec/innate/action/layout/file_layout.xhtml +0 -1
- data/spec/innate/helper/render.rb +0 -133
- data/spec/innate/helper/view/aspect_hello.xhtml +0 -1
- data/spec/innate/helper/view/locals.xhtml +0 -1
- data/spec/innate/helper/view/loop.xhtml +0 -4
- data/spec/innate/helper/view/num.xhtml +0 -1
- data/spec/innate/helper/view/partial.xhtml +0 -1
- data/spec/innate/helper/view/recursive.xhtml +0 -7
- data/spec/innate/node/view/foo.html.xhtml +0 -1
- data/spec/innate/node/view/with_layout.xhtml +0 -1
- data/spec/innate/provides/list.html.xhtml +0 -1
- data/spec/innate/provides/list.txt.xhtml +0 -1
- data/tasks/setup.rake +0 -28
@@ -20,7 +20,7 @@ class SpecRedirectHelper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def redirect_referer_action
|
23
|
-
redirect_referer
|
23
|
+
redirect_referer
|
24
24
|
end
|
25
25
|
|
26
26
|
def no_actual_redirect
|
@@ -69,92 +69,77 @@ describe Innate::Helper::Redirect do
|
|
69
69
|
end
|
70
70
|
|
71
71
|
should 'redirect' do
|
72
|
-
get("#@uri/redirection")
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
last_response.headers['Content-Type'].should == "text/html"
|
72
|
+
got = get("#@uri/redirection")
|
73
|
+
got.status.should == 302
|
74
|
+
got.headers['Location'].should == "#@uri/index"
|
75
|
+
got.headers['Content-Type'].should == "text/html"
|
77
76
|
end
|
78
77
|
|
79
78
|
should 'redirect twice' do
|
80
|
-
get("#@uri/double_redirection")
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
last_response.headers['Content-Type'].should == "text/html"
|
79
|
+
got = get("#@uri/double_redirection")
|
80
|
+
got.status.should == 302
|
81
|
+
got.headers['Location'].should == "#@uri/redirection"
|
82
|
+
got.headers['Content-Type'].should == "text/html"
|
85
83
|
end
|
86
84
|
|
87
85
|
should 'redirect to referer' do
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
should 'redirect to fallback if referrer is identical' do
|
97
|
-
header 'HTTP_REFERER', "#@uri/redirect_referer_action"
|
98
|
-
get("#@uri/redirect_referer_action")
|
99
|
-
|
100
|
-
last_response.status.should == 302
|
101
|
-
last_response.headers['Location'].should == "#@uri/noop"
|
102
|
-
last_response.headers['Content-Type'].should == "text/html"
|
86
|
+
got = get("#@uri/redirect_referer_action", 'HTTP_REFERER' => '/noop')
|
87
|
+
got.status.should == 302
|
88
|
+
got.headers['Location'].should == "#@uri/noop"
|
89
|
+
got.headers['Content-Type'].should == "text/html"
|
90
|
+
got = get("#@uri/redirect_referer_action", 'HTTP_REFERER' => "#@uri/redirect_referer_action")
|
91
|
+
got.status.should == 302
|
92
|
+
got.headers['Location'].should == "#@uri/"
|
93
|
+
got.headers['Content-Type'].should == "text/html"
|
103
94
|
end
|
104
95
|
|
105
96
|
should 'use #r' do
|
106
|
-
get("#@uri/redirect_method")
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
last_response.headers['Content-Type'].should == "text/html"
|
97
|
+
got = get("#@uri/redirect_method")
|
98
|
+
got.status.should == 302
|
99
|
+
got.headers['Location'].should == "#@uri/noop"
|
100
|
+
got.headers['Content-Type'].should == "text/html"
|
111
101
|
end
|
112
102
|
|
113
103
|
should 'work with absolute uris' do
|
114
|
-
get("#@uri/absolute_redirect")
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
last_response.headers['Content-Type'].should == "text/html"
|
104
|
+
got = get("#@uri/absolute_redirect")
|
105
|
+
got.status.should == 302
|
106
|
+
got.headers['Location'].should == "#@uri/noop"
|
107
|
+
got.headers['Content-Type'].should == "text/html"
|
119
108
|
end
|
120
109
|
|
121
110
|
should 'support #respond' do
|
122
|
-
get("#@uri/loop")
|
123
|
-
|
124
|
-
|
125
|
-
last_response.body.should == 'no loop'
|
111
|
+
got = get("#@uri/loop")
|
112
|
+
got.status.should == 200
|
113
|
+
got.body.should == 'no loop'
|
126
114
|
end
|
127
115
|
|
128
116
|
should 'support #respond with status' do
|
129
|
-
get("#@uri/respond_with_status")
|
130
|
-
|
131
|
-
|
132
|
-
last_response.body.should == 'not found'
|
117
|
+
got = get("#@uri/respond_with_status")
|
118
|
+
got.status.should == 404
|
119
|
+
got.body.should == 'not found'
|
133
120
|
end
|
134
121
|
|
135
122
|
should 'support #respond!' do
|
136
|
-
get("#@uri/destructive_respond")
|
137
|
-
|
138
|
-
|
139
|
-
last_response.body.should == 'destructive'
|
123
|
+
got = get("#@uri/destructive_respond")
|
124
|
+
got.status.should == 200
|
125
|
+
got.body.should == 'destructive'
|
140
126
|
end
|
141
127
|
|
142
128
|
should 'redirect without modifying the target' do
|
143
|
-
get("#@uri/redirect_unmodified")
|
144
|
-
|
145
|
-
|
146
|
-
last_response.headers['Location'].should == '/noop'
|
129
|
+
got = get("#@uri/redirect_unmodified")
|
130
|
+
got.status.should == 302
|
131
|
+
got.headers['Location'].should == '/noop'
|
147
132
|
end
|
148
133
|
|
149
134
|
should 'catch redirection' do
|
150
|
-
get("#@uri/no_actual_redirect")
|
151
|
-
|
152
|
-
|
135
|
+
got = get("#@uri/no_actual_redirect")
|
136
|
+
got.status.should == 200
|
137
|
+
got.body.should == 'no actual redirect'
|
153
138
|
end
|
154
139
|
|
155
140
|
should 'catch double redirect' do
|
156
|
-
get("#@uri/no_actual_double_redirect")
|
157
|
-
|
158
|
-
|
141
|
+
got = get("#@uri/no_actual_double_redirect")
|
142
|
+
got.status.should == 200
|
143
|
+
got.body.should == 'no actual double redirect'
|
159
144
|
end
|
160
145
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @foo %> <%= @bar %>!
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= say %>, <%= to %>!
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @n %>
|
@@ -0,0 +1 @@
|
|
1
|
+
From Partial <%= @here %>
|
data/spec/innate/node/node.rb
CHANGED
@@ -4,6 +4,8 @@ Innate.options.merge!(:views => 'view', :layouts => 'view')
|
|
4
4
|
|
5
5
|
class SpecNode
|
6
6
|
Innate.node('/')
|
7
|
+
provide(:html, :ERB)
|
8
|
+
provide(:erb, :None)
|
7
9
|
|
8
10
|
def foo; end
|
9
11
|
def bar; end
|
@@ -16,18 +18,24 @@ end
|
|
16
18
|
class SpecNodeProvide
|
17
19
|
Innate.node('/provide')
|
18
20
|
|
21
|
+
provide(:html, :ERB)
|
22
|
+
provide(:erb, :None)
|
23
|
+
|
19
24
|
def foo
|
20
|
-
'
|
25
|
+
'<%= 21 * 2 %>'
|
21
26
|
end
|
22
27
|
|
23
28
|
def bar
|
24
|
-
'
|
29
|
+
'<%= 84 / 2 %>'
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
28
33
|
class SpecNodeProvideTemplate
|
29
34
|
Innate.node('/provide_template')
|
30
35
|
|
36
|
+
provide :html, :ERB
|
37
|
+
provide :erb, :None
|
38
|
+
|
31
39
|
map_views '/'
|
32
40
|
end
|
33
41
|
|
@@ -56,7 +64,7 @@ class SpecNodeWithLayoutMethod < SpecNodeProvide
|
|
56
64
|
layout 'layout_method'
|
57
65
|
|
58
66
|
def layout_method
|
59
|
-
'<div class="content"
|
67
|
+
'<div class="content"><%= @content %></div>'
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
@@ -88,14 +96,14 @@ describe 'Innate::Node' do
|
|
88
96
|
should 'wrap with layout' do
|
89
97
|
got = Innate::Mock.get('/layout/bar')
|
90
98
|
got.status.should == 200
|
91
|
-
got.body.should == %(<div class="content">42</div
|
99
|
+
got.body.should == %(<div class="content">42</div>\n)
|
92
100
|
got['Content-Type'].should == 'text/html'
|
93
101
|
end
|
94
102
|
|
95
103
|
should 'find layout with view_root' do
|
96
104
|
got = Innate::Mock.get('/another_layout/bar')
|
97
105
|
got.status.should == 200
|
98
|
-
got.body.should == %(<div class="content">\n 42\n</div
|
106
|
+
got.body.should == %(<div class="content">\n 42\n</div>\n)
|
99
107
|
got['Content-Type'].should == 'text/html'
|
100
108
|
end
|
101
109
|
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<% 10.times do |n| %><%= n %><% end %>
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<div class="content"><%= @content %></div>
|
data/spec/innate/provides.rb
CHANGED
@@ -12,7 +12,7 @@ Innate.options.merge!(:views => 'provides', :layouts => 'provides')
|
|
12
12
|
class SpecNodeProvides
|
13
13
|
Innate.node '/'
|
14
14
|
|
15
|
-
provide(:html, :
|
15
|
+
provide(:html, :None)
|
16
16
|
provide(:yaml, :type => 'text/yaml'){|a,s| s.to_yaml }
|
17
17
|
provide(:json, :type => 'application/json'){|a,s| s.to_json }
|
18
18
|
|
@@ -31,7 +31,7 @@ class SpecNodeProvidesTemplates
|
|
31
31
|
|
32
32
|
provide(:yaml, :type => 'text/yaml'){|a,s| s.to_yaml }
|
33
33
|
provide(:json, :type => 'application/json'){|a,s| s.to_json }
|
34
|
-
provide(:txt, :engine => :
|
34
|
+
provide(:txt, :engine => :ERB, :type => 'text/plain')
|
35
35
|
|
36
36
|
def list
|
37
37
|
@users = %w[starbucks apollo athena]
|
@@ -0,0 +1 @@
|
|
1
|
+
<ul><% @users.each do |user| %><li><%= user %></li><% end %></ul>
|
@@ -0,0 +1 @@
|
|
1
|
+
<% @users.each do |user| %><%= "#{user}\n" %><% end %>
|
data/spec/innate/session.rb
CHANGED
@@ -29,26 +29,27 @@ class SpecSession
|
|
29
29
|
end
|
30
30
|
|
31
31
|
describe Innate::Session do
|
32
|
-
behaves_like :
|
32
|
+
behaves_like :session
|
33
33
|
|
34
34
|
should 'initiate session as needed' do
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
session do |mock|
|
36
|
+
response = mock.get('/')
|
37
|
+
response.body.should == 'No session here'
|
38
|
+
response['Set-Cookie'].should == nil
|
38
39
|
|
39
|
-
|
40
|
-
last_response.body.should == '0'
|
40
|
+
mock.get('/init').body.should == '0'
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
1.upto(10) do |n|
|
43
|
+
mock.get('/increment').body.should == n.to_s
|
44
|
+
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
mock.get('/reset')
|
47
|
+
mock.get('/view').body.should == ''
|
48
|
+
mock.get('/init').body.should == '0'
|
49
49
|
|
50
|
-
|
51
|
-
|
50
|
+
-1.downto(-10) do |n|
|
51
|
+
mock.get('/decrement').body.should == n.to_s
|
52
|
+
end
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
data/spec/innate/state/fiber.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
|
1
|
+
begin
|
2
|
+
require 'fiber'
|
3
|
+
rescue LoadError
|
4
|
+
exit
|
5
|
+
end
|
2
6
|
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'fiber'
|
6
|
-
rescue LoadError
|
7
|
-
it('needs fiber'){ should.flunk('needed fiber') }
|
8
|
-
exit
|
9
|
-
end
|
7
|
+
require 'spec/helper'
|
10
8
|
|
9
|
+
describe Innate::State::Fiber do
|
11
10
|
F = Innate::State::Fiber
|
12
11
|
|
13
12
|
it 'sets value in current thread with #[]=' do
|
data/tasks/bacon.rake
CHANGED
@@ -2,65 +2,48 @@ desc 'Run all bacon specs with pretty output'
|
|
2
2
|
task :bacon => :install_dependencies do
|
3
3
|
require 'open3'
|
4
4
|
require 'scanf'
|
5
|
-
require 'matrix'
|
6
5
|
|
7
6
|
specs = PROJECT_SPECS
|
8
7
|
|
9
8
|
some_failed = false
|
10
|
-
|
9
|
+
total = specs.size
|
11
10
|
len = specs.map{|s| s.size }.sort.last
|
12
|
-
|
13
|
-
totals = Vector[0, 0, 0, 0]
|
11
|
+
tt = ta = tf = te = 0
|
14
12
|
|
15
13
|
red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
|
16
14
|
left_format = "%4d/%d: %-#{len + 11}s"
|
17
15
|
spec_format = "%d specifications (%d requirements), %d failures, %d errors"
|
18
16
|
|
19
17
|
specs.each_with_index do |spec, idx|
|
20
|
-
print(left_format % [idx + 1,
|
18
|
+
print(left_format % [idx + 1, total, spec])
|
21
19
|
|
22
20
|
Open3.popen3(RUBY, spec) do |sin, sout, serr|
|
23
|
-
out = sout.read
|
24
|
-
err = serr.read
|
21
|
+
out = sout.read
|
22
|
+
err = serr.read
|
25
23
|
|
26
|
-
|
27
|
-
if out =~ /^Bacon::Error: (needed .*)/
|
28
|
-
puts(yellow % ("%6s %s" % ['', $1]))
|
29
|
-
else
|
30
|
-
total = nil
|
24
|
+
ran = false
|
31
25
|
|
32
|
-
|
33
|
-
|
26
|
+
out.each_line do |line|
|
27
|
+
tests, assertions, failures, errors = all = line.scanf(spec_format)
|
28
|
+
next unless all.any?
|
29
|
+
ran = true
|
30
|
+
tt += tests; ta += assertions; tf += failures; te += errors
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
if total
|
42
|
-
totals += total
|
43
|
-
tests, assertions, failures, errors = total_array = total.to_a
|
44
|
-
|
45
|
-
if tests > 0 && failures + errors == 0
|
46
|
-
puts((green % "%6d passed") % tests)
|
47
|
-
else
|
48
|
-
some_failed = true
|
49
|
-
puts(red % " failed")
|
50
|
-
puts out unless out.empty?
|
51
|
-
puts err unless err.empty?
|
52
|
-
end
|
32
|
+
if tests == 0 || failures + errors > 0
|
33
|
+
puts((red % spec_format) % all)
|
34
|
+
puts out
|
35
|
+
puts err
|
53
36
|
else
|
54
|
-
|
55
|
-
puts(red % " failed")
|
56
|
-
puts out unless out.empty?
|
57
|
-
puts err unless err.empty?
|
37
|
+
puts((green % "%6d passed") % tests)
|
58
38
|
end
|
39
|
+
|
40
|
+
break
|
59
41
|
end
|
42
|
+
|
43
|
+
puts(yellow % " skipped") unless ran
|
60
44
|
end
|
61
45
|
end
|
62
46
|
|
63
|
-
|
64
|
-
puts(total_color % (spec_format % totals.to_a))
|
47
|
+
puts(spec_format % [tt, ta, tf, te])
|
65
48
|
exit 1 if some_failed
|
66
49
|
end
|
data/tasks/release.rake
CHANGED
@@ -1,51 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
desc 'publish to github'
|
2
|
+
task :release => [:reversion, :gemspec] do
|
3
|
+
name, version = GEMSPEC.name, GEMSPEC.version
|
3
4
|
|
4
|
-
|
5
|
-
task :github => [:reversion, :gemspec] do
|
6
|
-
name, version = GEMSPEC.name, GEMSPEC.version
|
5
|
+
sh("git add MANIFEST CHANGELOG #{name}.gemspec lib/#{name}/version.rb")
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
git
|
12
|
-
|
13
|
-
Then commit them, tag the commit, and push:
|
14
|
-
|
15
|
-
git commit -m 'Version #{version}'
|
16
|
-
git tag -a -m '#{version}' '#{version}'
|
17
|
-
git push
|
18
|
-
|
19
|
-
INSTRUCTIONS
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
# TODO: Not tested
|
24
|
-
desc 'Display instructions to release on rubyforge'
|
25
|
-
task :rubyforge => [:reversion, :gemspec, :package] do
|
26
|
-
name, version = GEMSPEC.name, GEMSPEC.version
|
27
|
-
|
28
|
-
puts <<INSTRUCTIONS
|
29
|
-
To publish to rubyforge do following:
|
30
|
-
|
31
|
-
rubyforge login
|
32
|
-
rubyforge add_release #{name} '#{version}' pkg/#{name}-#{version}.gem
|
33
|
-
|
34
|
-
After you have done these steps, see:
|
35
|
-
|
36
|
-
rake release:rubyforge_archives
|
37
|
-
|
38
|
-
INSTRUCTIONS
|
39
|
-
end
|
40
|
-
|
41
|
-
desc 'Display instructions to add archives after release:rubyforge'
|
42
|
-
task :rubyforge_archives do
|
43
|
-
puts "Adding archives for distro packagers is:", ""
|
44
|
-
|
45
|
-
Dir["pkg/#{name}-#{version}.{gz,zip}"].each do |file|
|
46
|
-
puts "rubyforge add_file #{name} #{name} '#{version}' '#{file}'"
|
47
|
-
end
|
48
|
-
|
49
|
-
puts
|
50
|
-
end
|
7
|
+
puts "I added the relevant files, you can now run:", ''
|
8
|
+
puts "git commit -m 'Version #{version}'"
|
9
|
+
puts "git tag -a -m '#{version}' '#{version}'"
|
10
|
+
puts "git push"
|
11
|
+
puts
|
51
12
|
end
|