manveru-innate 2009.02.21 → 2009.02.25
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +112 -0
- data/MANIFEST +6 -3
- data/Rakefile +2 -5
- data/example/app/retro_games.rb +2 -2
- data/example/app/todo/layout/default.erb +11 -0
- data/example/app/todo/spec/todo.rb +63 -0
- data/example/app/todo/start.rb +51 -0
- data/example/app/todo/view/index.erb +39 -0
- data/example/app/whywiki_erb/layout/wiki.html.erb +1 -1
- data/example/app/whywiki_erb/start.rb +3 -7
- data/example/app/whywiki_erb/view/edit.html.erb +1 -1
- data/example/app/whywiki_erb/view/index.html.erb +6 -4
- data/example/custom_middleware.rb +5 -13
- data/example/hello.rb +1 -2
- data/example/howto_spec.rb +14 -39
- data/example/link.rb +5 -13
- data/example/session.rb +16 -20
- data/innate.gemspec +7 -4
- data/lib/innate/action.rb +8 -7
- data/lib/innate/adapter.rb +1 -1
- data/lib/innate/cache.rb +9 -0
- data/lib/innate/core_compatibility/basic_object.rb +1 -0
- data/lib/innate/helper.rb +5 -5
- data/lib/innate/node.rb +18 -17
- data/lib/innate/options.rb +2 -2
- data/lib/innate/spec.rb +25 -4
- data/lib/innate/state.rb +12 -4
- data/lib/innate/traited.rb +55 -3
- data/lib/innate/version.rb +1 -1
- data/lib/innate/view/erb.rb +1 -1
- data/lib/innate/view/none.rb +2 -2
- data/lib/innate/view.rb +4 -2
- data/lib/innate.rb +137 -104
- data/spec/example/hello.rb +0 -1
- data/spec/example/link.rb +3 -7
- data/spec/example/session.rb +28 -0
- data/spec/innate/helper/redirect.rb +1 -4
- data/spec/innate/node/only_view.html +1 -0
- data/spec/innate/node.rb +12 -0
- metadata +8 -5
- data/example/error_handling.rb +0 -31
- data/example/providing_hash.rb +0 -46
- data/lib/innate/setup.rb +0 -23
data/CHANGELOG
CHANGED
@@ -1,3 +1,115 @@
|
|
1
|
+
[04201ef | Wed Feb 25 06:27:15 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
2
|
+
|
3
|
+
* cleanup
|
4
|
+
|
5
|
+
[295a241 | Wed Feb 25 06:27:10 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
6
|
+
|
7
|
+
* Add Traited#class_trait and docs
|
8
|
+
|
9
|
+
[6ed8499 | Wed Feb 25 06:04:24 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
10
|
+
|
11
|
+
* rebuild middleware if block is passed to Innate.start
|
12
|
+
|
13
|
+
[8ce86a7 | Wed Feb 25 06:04:01 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
14
|
+
|
15
|
+
* Make the real failures on helper requires visible
|
16
|
+
|
17
|
+
[232214e | Wed Feb 25 06:03:29 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
18
|
+
|
19
|
+
* Remove optimization for wrap_action_call, leads to really weird recursion
|
20
|
+
|
21
|
+
[38d0a7b | Wed Feb 25 05:09:53 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
22
|
+
|
23
|
+
* Simplify setting of mode and compilation of middleware
|
24
|
+
|
25
|
+
[8c02417 | Wed Feb 25 04:40:11 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
26
|
+
|
27
|
+
* Speed up wrap_action_call
|
28
|
+
|
29
|
+
[cea8af5 | Wed Feb 25 04:37:29 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
30
|
+
|
31
|
+
* Speed up ancestral_trait
|
32
|
+
|
33
|
+
[608a7eb | Tue Feb 24 13:45:15 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
34
|
+
|
35
|
+
* Remove Innate::Setup, that goes into Ramaze
|
36
|
+
|
37
|
+
[785b1e5 | Tue Feb 24 13:45:04 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
38
|
+
|
39
|
+
* Remove reference to Innate in log to avoid confusion
|
40
|
+
|
41
|
+
[3df0612 | Tue Feb 24 13:28:02 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
42
|
+
|
43
|
+
* Remove the providing_hash example until we come up with a better way to show it
|
44
|
+
|
45
|
+
[8309299 | Tue Feb 24 13:25:36 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
46
|
+
|
47
|
+
* small cleanup
|
48
|
+
|
49
|
+
[93be7ad | Tue Feb 24 13:25:25 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
50
|
+
|
51
|
+
* Spec the session example
|
52
|
+
|
53
|
+
[7b39146 | Tue Feb 24 13:24:45 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
54
|
+
|
55
|
+
* Add missing template for node spec
|
56
|
+
|
57
|
+
[d8ccfce | Tue Feb 24 13:22:56 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
58
|
+
|
59
|
+
* Add todolist example
|
60
|
+
|
61
|
+
[fd73cef | Tue Feb 24 13:06:01 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
62
|
+
|
63
|
+
* Don't serve a view without method if params are given
|
64
|
+
|
65
|
+
[58f9ecd | Tue Feb 24 12:05:27 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
66
|
+
|
67
|
+
* Fix spec for example/link
|
68
|
+
|
69
|
+
[607fc72 | Tue Feb 24 12:05:16 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
70
|
+
|
71
|
+
* Provide shared multipart to enable easy POST specs
|
72
|
+
|
73
|
+
[9b833f8 | Tue Feb 24 12:04:48 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
74
|
+
|
75
|
+
* Innate::Node, rename LIST to NODE_LIST and HELPERS to DEFAULT_HELPERS
|
76
|
+
|
77
|
+
[397cff4 | Tue Feb 24 12:03:38 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
78
|
+
|
79
|
+
* A little bit nicer each in retro games
|
80
|
+
|
81
|
+
[0ab5dfe | Tue Feb 24 11:09:07 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
82
|
+
|
83
|
+
* We don't provide error handling out of the box, remove example
|
84
|
+
|
85
|
+
[9466549 | Tue Feb 24 11:06:39 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
86
|
+
|
87
|
+
* Clean up code of the whywiki
|
88
|
+
|
89
|
+
[715371b | Tue Feb 24 10:58:44 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
90
|
+
|
91
|
+
* Bring examples up to date
|
92
|
+
|
93
|
+
[378977c | Sun Feb 22 13:14:09 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
94
|
+
|
95
|
+
* Add some docs
|
96
|
+
|
97
|
+
[566303c | Sun Feb 22 12:34:48 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
98
|
+
|
99
|
+
* Make Innate::setup and Innate::sync available to Ramaze
|
100
|
+
|
101
|
+
[6fa8645 | Sun Feb 22 12:16:33 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
102
|
+
|
103
|
+
* Make it easier for Ramaze to set a default engine
|
104
|
+
|
105
|
+
[dfe34cd | Sat Feb 21 12:54:34 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
106
|
+
|
107
|
+
* Correct usage of git tag
|
108
|
+
|
109
|
+
[42d3883 | Sat Feb 21 03:28:29 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
110
|
+
|
111
|
+
* Version 2009.02.21
|
112
|
+
|
1
113
|
[374f218 | Sat Feb 21 03:26:55 UTC 2009] Michael Fellinger <m.fellinger@gmail.com>
|
2
114
|
|
3
115
|
* Bring retro games example back to life
|
data/MANIFEST
CHANGED
@@ -4,17 +4,19 @@ MANIFEST
|
|
4
4
|
README.md
|
5
5
|
Rakefile
|
6
6
|
example/app/retro_games.rb
|
7
|
+
example/app/todo/layout/default.erb
|
8
|
+
example/app/todo/spec/todo.rb
|
9
|
+
example/app/todo/start.rb
|
10
|
+
example/app/todo/view/index.erb
|
7
11
|
example/app/whywiki_erb/layout/wiki.html.erb
|
8
12
|
example/app/whywiki_erb/spec/wiki.rb
|
9
13
|
example/app/whywiki_erb/start.rb
|
10
14
|
example/app/whywiki_erb/view/edit.html.erb
|
11
15
|
example/app/whywiki_erb/view/index.html.erb
|
12
16
|
example/custom_middleware.rb
|
13
|
-
example/error_handling.rb
|
14
17
|
example/hello.rb
|
15
18
|
example/howto_spec.rb
|
16
19
|
example/link.rb
|
17
|
-
example/providing_hash.rb
|
18
20
|
example/session.rb
|
19
21
|
innate.gemspec
|
20
22
|
lib/innate.rb
|
@@ -51,7 +53,6 @@ lib/innate/response.rb
|
|
51
53
|
lib/innate/route.rb
|
52
54
|
lib/innate/session.rb
|
53
55
|
lib/innate/session/flash.rb
|
54
|
-
lib/innate/setup.rb
|
55
56
|
lib/innate/spec.rb
|
56
57
|
lib/innate/state.rb
|
57
58
|
lib/innate/state/accessor.rb
|
@@ -67,6 +68,7 @@ lib/rack/middleware_compiler.rb
|
|
67
68
|
lib/rack/reloader.rb
|
68
69
|
spec/example/hello.rb
|
69
70
|
spec/example/link.rb
|
71
|
+
spec/example/session.rb
|
70
72
|
spec/helper.rb
|
71
73
|
spec/innate/action/layout.rb
|
72
74
|
spec/innate/action/layout/file_layout.erb
|
@@ -94,6 +96,7 @@ spec/innate/node.rb
|
|
94
96
|
spec/innate/node/another_layout/another_layout.erb
|
95
97
|
spec/innate/node/bar.html
|
96
98
|
spec/innate/node/foo.html.erb
|
99
|
+
spec/innate/node/only_view.html
|
97
100
|
spec/innate/node/with_layout.erb
|
98
101
|
spec/innate/options.rb
|
99
102
|
spec/innate/parameter.rb
|
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ task :release => [:reversion, :gemspec] do
|
|
25
25
|
sh('git add MANIFEST CHANGELOG innate.gemspec lib/innate/version.rb')
|
26
26
|
puts "I added the relevant files, you can now run:", ''
|
27
27
|
puts "git commit -m 'Version #{INNATE_VERSION}'"
|
28
|
-
puts "git tag -m '#{INNATE_VERSION}'"
|
28
|
+
puts "git tag -a -m '#{INNATE_VERSION}' '#{INNATE_VERSION}'"
|
29
29
|
puts "git push"
|
30
30
|
puts
|
31
31
|
end
|
@@ -75,7 +75,7 @@ Gem::Specification.new do |s|
|
|
75
75
|
s.homepage = "http://github.com/manveru/innate"
|
76
76
|
s.require_path = "lib"
|
77
77
|
|
78
|
-
s.add_dependency('rack', '>= 0.
|
78
|
+
s.add_dependency('rack', '>= 0.9.1')
|
79
79
|
|
80
80
|
s.files = [
|
81
81
|
#{files}
|
@@ -173,9 +173,6 @@ end
|
|
173
173
|
desc 'install dependencies'
|
174
174
|
task :setup do
|
175
175
|
GemSetup.new do
|
176
|
-
github = 'http://gems.github.com'
|
177
|
-
Gem.sources << github
|
178
|
-
|
179
176
|
gem('rack', '>=0.9.1')
|
180
177
|
gem('bacon', '>=1.1.0')
|
181
178
|
|
data/example/app/retro_games.rb
CHANGED
@@ -5,8 +5,8 @@ STORE = YAML::Store.new('games.yaml')
|
|
5
5
|
|
6
6
|
def STORE.[](key) transaction{|s| super } end
|
7
7
|
def STORE.[]=(key, value) transaction{|s| super } end
|
8
|
-
def STORE.each
|
9
|
-
YAML.load_file('games.yaml').sort_by{|k,v| -v }.each
|
8
|
+
def STORE.each(&block)
|
9
|
+
YAML.load_file('games.yaml').sort_by{|k,v| -v }.each(&block)
|
10
10
|
end
|
11
11
|
|
12
12
|
STORE['Pacman'] = 1
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<?xml version='1.0' encoding='utf-8' ?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Innate TodoList</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<h1>Organize your life and learn Innate</h1>
|
9
|
+
<%= @content %>
|
10
|
+
</body>
|
11
|
+
</html>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'innate/spec'
|
2
|
+
|
3
|
+
FileUtils.rm_f('todo.pstore')
|
4
|
+
|
5
|
+
require 'start'
|
6
|
+
require 'hpricot'
|
7
|
+
|
8
|
+
describe Todo do
|
9
|
+
behaves_like :mock, :multipart
|
10
|
+
|
11
|
+
it 'starts out without tasks' do
|
12
|
+
doc = Hpricot(get('/').body)
|
13
|
+
doc.at(:table).inner_text.strip.should.be.empty
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'adds a task and redirects back' do
|
17
|
+
got = post('/create', multipart('title' => 'first task'))
|
18
|
+
got.status.should == 302
|
19
|
+
got['Location'].should == 'http://example.org/'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'shows the task as pending' do
|
23
|
+
doc = Hpricot(get('/').body)
|
24
|
+
doc.at('td/input[@name=title]')['value'].should == 'first task'
|
25
|
+
doc.at('td/input[@name=done]')['checked'].should.be.nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'updates the task title and redirects back' do
|
29
|
+
got = post('/update', multipart('id' => 'first task', 'title' => 'wash dishes'))
|
30
|
+
got.status.should == 302
|
31
|
+
got['Location'].should == 'http://example.org/'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'shows the changed task title' do
|
35
|
+
doc = Hpricot(get('/').body)
|
36
|
+
doc.at('td/input[@name=title]')['value'].should == 'wash dishes'
|
37
|
+
doc.at('td/input[@name=done]')['checked'].should.be.nil
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'marks the task as done and redirects back' do
|
41
|
+
mp = multipart('id' => 'wash dishes', 'title' => 'wash dishes', 'done' => 'on')
|
42
|
+
got = post('/update', mp)
|
43
|
+
got.status.should == 302
|
44
|
+
got['Location'].should == 'http://example.org/'
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'shows the task as done' do
|
48
|
+
doc = Hpricot(get('/').body)
|
49
|
+
doc.at('td/input[@name=title]')['value'].should == 'wash dishes'
|
50
|
+
doc.at('td/input[@name=done]')['checked'].should == 'checked'
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'deletes the task and redirects back' do
|
54
|
+
got = post('/delete', multipart('id' => 'wash dishes'))
|
55
|
+
got.status.should == 302
|
56
|
+
got['Location'].should == 'http://example.org/'
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'shows no tasks' do
|
60
|
+
doc = Hpricot(get('/').body)
|
61
|
+
doc.at(:table).inner_text.strip.should.be.empty
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'innate'
|
3
|
+
require 'pstore'
|
4
|
+
|
5
|
+
LIST = PStore.new('todo.pstore')
|
6
|
+
|
7
|
+
class Todo
|
8
|
+
Innate.node '/'
|
9
|
+
layout 'default'
|
10
|
+
|
11
|
+
def index
|
12
|
+
@list = sync{|list| list.roots.map{|key| [key, list[key]] }}
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
redirect_referer unless request.post? and title = request[:title]
|
17
|
+
title.strip!
|
18
|
+
|
19
|
+
sync{ LIST[title] = false } unless title.empty?
|
20
|
+
redirect_referer
|
21
|
+
end
|
22
|
+
|
23
|
+
def update
|
24
|
+
id, title, done = request[:id, :title, :done]
|
25
|
+
redirect_referer unless request.post? and id and title
|
26
|
+
done = !!done
|
27
|
+
title.strip!
|
28
|
+
|
29
|
+
if id == title
|
30
|
+
sync{ LIST[id] = done }
|
31
|
+
elsif title != ''
|
32
|
+
sync{ LIST.delete(id); LIST[title] = done }
|
33
|
+
end
|
34
|
+
|
35
|
+
redirect_referer
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete
|
39
|
+
redirect_referer unless request.post? and id = request[:id]
|
40
|
+
sync{ LIST.delete(id) }
|
41
|
+
redirect_referer
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def sync
|
47
|
+
Innate.sync{ LIST.transaction{ yield(LIST) }}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Innate.start
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<form method="post" action="<%= r :create %>">
|
2
|
+
<fieldset>
|
3
|
+
<legend>Create new task</legend>
|
4
|
+
|
5
|
+
<label for="form_title">Title:</label>
|
6
|
+
<input id="form_title" type="text" name="title" />
|
7
|
+
|
8
|
+
<input type="submit" value="Create" />
|
9
|
+
</fieldset>
|
10
|
+
</form>
|
11
|
+
|
12
|
+
<table>
|
13
|
+
<% @list.each do |title, done| %>
|
14
|
+
<tr>
|
15
|
+
<form method="post" action="<%= r :update %>">
|
16
|
+
<input type="hidden" name="id" value="<%= h title %>" />
|
17
|
+
<td>
|
18
|
+
<input type="text" name="title" value="<%= h title %>" />
|
19
|
+
</td>
|
20
|
+
<td>
|
21
|
+
<% if done %>
|
22
|
+
<input type="checkbox" name="done" checked="checked" />
|
23
|
+
<% else %>
|
24
|
+
<input type="checkbox" name="done" />
|
25
|
+
<% end %>
|
26
|
+
</td>
|
27
|
+
<td>
|
28
|
+
<input type="submit" value="Update" />
|
29
|
+
</td>
|
30
|
+
</form>
|
31
|
+
<form method="post" action="<%= r :delete %>">
|
32
|
+
<input type="hidden" name="id" value="<%= h title %>" />
|
33
|
+
<td>
|
34
|
+
<input type="submit" value="Delete" />
|
35
|
+
</td>
|
36
|
+
</form>
|
37
|
+
</tr>
|
38
|
+
<% end %>
|
39
|
+
</table>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html>
|
4
4
|
<head>
|
5
|
-
<title
|
5
|
+
<title>MicroWiki <%= h @page %></title>
|
6
6
|
<style type="text/css">
|
7
7
|
a.exists{ color: #00f; }
|
8
8
|
a.missing{ color: #f00; }
|
@@ -1,13 +1,11 @@
|
|
1
|
-
# The minimal _why wiki in Innate
|
1
|
+
# The minimal _why wiki in Innate with ERB
|
2
2
|
|
3
3
|
%w[rubygems innate erb maruku yaml/store].each{|l| require(l) }
|
4
4
|
|
5
5
|
DB = YAML::Store.new('wiki.yaml') unless defined?(DB)
|
6
6
|
|
7
7
|
class Wiki
|
8
|
-
|
9
|
-
map '/'
|
10
|
-
provide :html => :erb
|
8
|
+
Innate.node '/'
|
11
9
|
layout 'wiki'
|
12
10
|
|
13
11
|
def index(page = 'Home')
|
@@ -27,10 +25,8 @@ class Wiki
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def save
|
30
|
-
redirect_referrer unless request.post?
|
31
|
-
|
32
28
|
page, text = request[:page, :text]
|
33
|
-
sync{ DB[page] = text } if page and text
|
29
|
+
sync{ DB[page] = text } if request.post? and page and text
|
34
30
|
|
35
31
|
redirect(r(page))
|
36
32
|
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
<% unless @page == 'Home' %>
|
2
|
-
|
2
|
+
<%= a('< Home', :Home) %>
|
3
3
|
<% end %>
|
4
|
+
|
4
5
|
<h1><%= h @page %></h1>
|
6
|
+
|
5
7
|
<% if @text.empty? %>
|
6
|
-
|
8
|
+
<%= a("Create #@page", :edit, @page) %>
|
7
9
|
<% else %>
|
8
|
-
|
9
|
-
<%= Maruku.new(@text).to_html %>
|
10
|
+
<%= a("Edit #@page", :edit, @page) %>
|
11
|
+
<%= Maruku.new(@text).to_html %>
|
10
12
|
<% end %>
|
@@ -1,8 +1,8 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'innate'
|
2
3
|
|
3
4
|
class Demo
|
4
|
-
|
5
|
-
map '/'
|
5
|
+
Innate.node '/'
|
6
6
|
|
7
7
|
def index
|
8
8
|
'Hello, World!'
|
@@ -14,9 +14,7 @@ class Demo
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
# Innate.middleware! to force a rebuild in the MiddlewareCompiler.
|
19
|
-
Innate.middleware :innate do |mw|
|
17
|
+
Innate.start do |mw|
|
20
18
|
# Makes sure all requests and responses conform to Rack protocol
|
21
19
|
mw.use Rack::Lint
|
22
20
|
|
@@ -32,12 +30,6 @@ Innate.middleware :innate do |mw|
|
|
32
30
|
# Reload modified files before request
|
33
31
|
mw.use Rack::Reloader
|
34
32
|
|
35
|
-
#
|
36
|
-
mw.
|
37
|
-
|
38
|
-
# This will try to find a static file in /public first, and try DynaMap if
|
39
|
-
# Rack::File returns a 404 status.
|
40
|
-
mw.cascade Rack::File.new('public'), Innate::DynaMap
|
33
|
+
# Start up the application
|
34
|
+
mw.innate
|
41
35
|
end
|
42
|
-
|
43
|
-
Innate.start
|
data/example/hello.rb
CHANGED
data/example/howto_spec.rb
CHANGED
@@ -1,60 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'innate'
|
2
|
-
require 'bacon'
|
3
3
|
|
4
4
|
class SpecMe
|
5
|
-
|
6
|
-
map '/'
|
5
|
+
Innate.node '/'
|
7
6
|
|
8
7
|
def index
|
9
8
|
"I should be at /"
|
10
9
|
end
|
11
10
|
|
12
11
|
def foo
|
13
|
-
|
12
|
+
response['Content-Type'] = 'text/css'
|
14
13
|
"I should be at /foo"
|
15
14
|
end
|
16
15
|
end
|
17
16
|
|
18
|
-
|
19
|
-
include Innate::Node
|
20
|
-
map '/too'
|
21
|
-
|
22
|
-
def index
|
23
|
-
"I should be at /too"
|
24
|
-
end
|
25
|
-
|
26
|
-
def foo
|
27
|
-
action.content_type = 'text/css'
|
28
|
-
"I should be at /too/foo"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
Innate.setup_middleware
|
33
|
-
|
34
|
-
Bacon.summary_on_exit
|
35
|
-
Bacon.extend(Bacon::TestUnitOutput)
|
17
|
+
require 'innate/spec'
|
36
18
|
|
37
19
|
describe 'An example spec' do
|
38
|
-
|
39
|
-
response = Innate::Mock.get(url)
|
40
|
-
response.status.should == 200
|
41
|
-
response.body.should == body
|
42
|
-
response.content_type.should == content_type
|
43
|
-
end
|
20
|
+
behaves_like :mock
|
44
21
|
|
45
22
|
should 'respond to /' do
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
assert('/foo', "I should be at /foo", 'text/css')
|
23
|
+
got = get('/')
|
24
|
+
got.status.should == 200
|
25
|
+
got.body.should == "I should be at /"
|
26
|
+
got['Content-Type'].should == 'text/html'
|
51
27
|
end
|
52
28
|
|
53
|
-
should 'respond to /
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
assert('/too/foo', "I should be at /too/foo", 'text/css')
|
29
|
+
should 'respond to /' do
|
30
|
+
got = get('/foo')
|
31
|
+
got.status.should == 200
|
32
|
+
got.body.should == "I should be at /foo"
|
33
|
+
got['Content-Type'].should == 'text/css'
|
59
34
|
end
|
60
35
|
end
|
data/example/link.rb
CHANGED
@@ -1,30 +1,22 @@
|
|
1
1
|
require 'innate'
|
2
2
|
|
3
3
|
class Linking
|
4
|
-
|
5
|
-
map '/'
|
4
|
+
Innate.node '/'
|
6
5
|
|
7
6
|
def index
|
8
|
-
"
|
9
|
-
a('Help?', :help)
|
10
|
-
end
|
11
|
-
|
12
|
-
def new
|
13
|
-
"Something new!"
|
7
|
+
"Index links to " + a('Help?', :help)
|
14
8
|
end
|
15
9
|
|
16
10
|
def help
|
17
|
-
"
|
18
|
-
Different.a('A Different Node', :another)
|
11
|
+
"Help links to " + Different.a('A Different Node', :another)
|
19
12
|
end
|
20
13
|
end
|
21
14
|
|
22
15
|
class Different
|
23
|
-
|
24
|
-
map '/link_to'
|
16
|
+
Innate.node '/link_to'
|
25
17
|
|
26
18
|
def another
|
27
|
-
a('
|
19
|
+
a('Another links even deeper', 'and/deeper')
|
28
20
|
end
|
29
21
|
|
30
22
|
def and__deeper
|
data/example/session.rb
CHANGED
@@ -1,26 +1,22 @@
|
|
1
1
|
require 'innate'
|
2
2
|
|
3
3
|
class Hello
|
4
|
-
|
5
|
-
map '/'
|
6
|
-
|
7
|
-
helper :link, :cgi
|
8
|
-
|
9
|
-
provide :html => :haml
|
4
|
+
Innate.node '/'
|
10
5
|
|
11
6
|
TEMPLATE = '
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
7
|
+
<html>
|
8
|
+
<head>
|
9
|
+
<title>Session example</title>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<h1>Session example</h1>
|
13
|
+
<p>
|
14
|
+
Value is: <%= session[:value] %><br />
|
15
|
+
<%= a :increment %><br />
|
16
|
+
<%= a :decrement %>
|
17
|
+
</p>
|
18
|
+
</body>
|
19
|
+
</html>
|
24
20
|
'.strip
|
25
21
|
|
26
22
|
def index
|
@@ -29,12 +25,12 @@ class Hello
|
|
29
25
|
end
|
30
26
|
|
31
27
|
def increment
|
32
|
-
session[:value]
|
28
|
+
session[:value] = session[:value].to_i + 1
|
33
29
|
TEMPLATE
|
34
30
|
end
|
35
31
|
|
36
32
|
def decrement
|
37
|
-
session[:value]
|
33
|
+
session[:value] = session[:value].to_i - 1
|
38
34
|
TEMPLATE
|
39
35
|
end
|
40
36
|
end
|