manveru-innate 2009.04.01 → 2009.04.08

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGELOG +104 -0
  2. data/MANIFEST +18 -18
  3. data/Rakefile +3 -3
  4. data/example/app/retro_games.rb +6 -6
  5. data/example/app/todo/layout/default.erb +1 -1
  6. data/example/app/todo/view/index.erb +11 -11
  7. data/example/app/whywiki_erb/start.rb +1 -0
  8. data/example/app/whywiki_erb/view/{edit.html.erb → edit.erb} +0 -0
  9. data/example/app/whywiki_erb/view/{index.html.erb → index.erb} +0 -0
  10. data/example/howto_spec.rb +1 -1
  11. data/example/session.rb +3 -3
  12. data/innate.gemspec +3 -12
  13. data/lib/innate/action.rb +2 -1
  14. data/lib/innate/helper.rb +18 -27
  15. data/lib/innate/helper/cgi.rb +30 -20
  16. data/lib/innate/helper/render.rb +80 -0
  17. data/lib/innate/mock.rb +2 -3
  18. data/lib/innate/node.rb +79 -50
  19. data/lib/innate/options.rb +1 -1
  20. data/lib/innate/request.rb +3 -23
  21. data/lib/innate/spec.rb +3 -6
  22. data/lib/innate/version.rb +1 -1
  23. data/lib/innate/view/erb.rb +1 -1
  24. data/lib/innate/view/etanni.rb +2 -2
  25. data/lib/innate/view/none.rb +1 -1
  26. data/spec/innate/action/layout.rb +1 -1
  27. data/spec/innate/action/layout/file_layout.xhtml +1 -0
  28. data/spec/innate/helper/aspect.rb +6 -6
  29. data/spec/innate/helper/flash.rb +6 -6
  30. data/spec/innate/helper/render.rb +157 -0
  31. data/spec/innate/helper/view/aspect_hello.xhtml +1 -0
  32. data/spec/innate/helper/view/locals.xhtml +1 -0
  33. data/spec/innate/helper/view/loop.xhtml +4 -0
  34. data/spec/innate/helper/view/num.xhtml +1 -0
  35. data/spec/innate/helper/view/partial.xhtml +1 -0
  36. data/spec/innate/helper/view/recursive.xhtml +7 -0
  37. data/spec/innate/node/node.rb +5 -13
  38. data/spec/innate/node/view/another_layout/{another_layout.erb → another_layout.xhtml} +1 -1
  39. data/spec/innate/node/view/{bar.erb → bar.xhtml} +0 -0
  40. data/spec/innate/node/view/foo.html.xhtml +1 -0
  41. data/spec/innate/node/view/{only_view.erb → only_view.xhtml} +0 -0
  42. data/spec/innate/node/view/with_layout.xhtml +1 -0
  43. data/spec/innate/provides.rb +2 -2
  44. data/spec/innate/provides/list.html.xhtml +1 -0
  45. data/spec/innate/provides/list.txt.xhtml +1 -0
  46. data/spec/innate/state/fiber.rb +8 -7
  47. data/tasks/bacon.rake +38 -21
  48. metadata +22 -51
  49. data/lib/innate/helper/partial.rb +0 -93
  50. data/spec/innate/action/layout/file_layout.erb +0 -1
  51. data/spec/innate/helper/partial.rb +0 -101
  52. data/spec/innate/helper/view/aspect_hello.erb +0 -1
  53. data/spec/innate/helper/view/locals.erb +0 -1
  54. data/spec/innate/helper/view/loop.erb +0 -4
  55. data/spec/innate/helper/view/num.erb +0 -1
  56. data/spec/innate/helper/view/partial.erb +0 -1
  57. data/spec/innate/helper/view/recursive.erb +0 -8
  58. data/spec/innate/node/view/foo.html.erb +0 -1
  59. data/spec/innate/node/view/with_layout.erb +0 -1
  60. data/spec/innate/provides/list.html.erb +0 -1
  61. data/spec/innate/provides/list.txt.erb +0 -1
@@ -2,48 +2,65 @@ 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'
5
6
 
6
7
  specs = PROJECT_SPECS
7
8
 
8
9
  some_failed = false
9
- total = specs.size
10
+ specs_size = specs.size
10
11
  len = specs.map{|s| s.size }.sort.last
11
- tt = ta = tf = te = 0
12
+ total_tests = total_assertions = total_failures = total_errors = 0
13
+ totals = Vector[0, 0, 0, 0]
12
14
 
13
15
  red, yellow, green = "\e[31m%s\e[0m", "\e[33m%s\e[0m", "\e[32m%s\e[0m"
14
16
  left_format = "%4d/%d: %-#{len + 11}s"
15
17
  spec_format = "%d specifications (%d requirements), %d failures, %d errors"
16
18
 
17
19
  specs.each_with_index do |spec, idx|
18
- print(left_format % [idx + 1, total, spec])
20
+ print(left_format % [idx + 1, specs_size, spec])
19
21
 
20
22
  Open3.popen3(RUBY, spec) do |sin, sout, serr|
21
- out = sout.read
22
- err = serr.read
23
+ out = sout.read.strip
24
+ err = serr.read.strip
23
25
 
24
- ran = false
26
+ # this is conventional, see spec/innate/state/fiber.rb for usage
27
+ if out =~ /^Bacon::Error: (needed .*)/
28
+ puts(yellow % ("%6s %s" % ['', $1]))
29
+ else
30
+ total = nil
25
31
 
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
32
+ out.each_line do |line|
33
+ scanned = line.scanf(spec_format)
31
34
 
32
- if tests == 0 || failures + errors > 0
33
- puts((red % spec_format) % all)
34
- puts out
35
- puts err
36
- else
37
- puts((green % "%6d passed") % tests)
35
+ next unless scanned.size == 4
36
+
37
+ total = Vector[*scanned]
38
+ break
38
39
  end
39
40
 
40
- break
41
- end
41
+ if total
42
+ totals += total
43
+ tests, assertions, failures, errors = total_array = total.to_a
42
44
 
43
- puts(yellow % " skipped") unless ran
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
53
+ else
54
+ some_failed = true
55
+ puts(red % " failed")
56
+ puts out unless out.empty?
57
+ puts err unless err.empty?
58
+ end
59
+ end
44
60
  end
45
61
  end
46
62
 
47
- puts(spec_format % [tt, ta, tf, te])
63
+ total_color = some_failed ? red : green
64
+ puts(total_color % (spec_format % totals.to_a))
48
65
  exit 1 if some_failed
49
66
  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.04.01
4
+ version: 2009.04.08
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael 'manveru' Fellinger
@@ -9,39 +9,10 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-01 00:00:00 -07:00
12
+ date: 2009-04-08 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rack
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: 0.9.1
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: bacon
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "1.0"
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: json
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- version: 1.1.3
44
- version:
14
+ dependencies: []
15
+
45
16
  description: Simple, straight-forward base for web-frameworks.
46
17
  email: m.fellinger@gmail.com
47
18
  executables: []
@@ -64,8 +35,8 @@ files:
64
35
  - example/app/whywiki_erb/layout/wiki.html.erb
65
36
  - example/app/whywiki_erb/spec/wiki.rb
66
37
  - example/app/whywiki_erb/start.rb
67
- - example/app/whywiki_erb/view/edit.html.erb
68
- - example/app/whywiki_erb/view/index.html.erb
38
+ - example/app/whywiki_erb/view/edit.erb
39
+ - example/app/whywiki_erb/view/index.erb
69
40
  - example/custom_middleware.rb
70
41
  - example/hello.rb
71
42
  - example/howto_spec.rb
@@ -92,8 +63,8 @@ files:
92
63
  - lib/innate/helper/cgi.rb
93
64
  - lib/innate/helper/flash.rb
94
65
  - lib/innate/helper/link.rb
95
- - lib/innate/helper/partial.rb
96
66
  - lib/innate/helper/redirect.rb
67
+ - lib/innate/helper/render.rb
97
68
  - lib/innate/helper/send_file.rb
98
69
  - lib/innate/log.rb
99
70
  - lib/innate/log/color_formatter.rb
@@ -126,7 +97,7 @@ files:
126
97
  - spec/example/session.rb
127
98
  - spec/helper.rb
128
99
  - spec/innate/action/layout.rb
129
- - spec/innate/action/layout/file_layout.erb
100
+ - spec/innate/action/layout/file_layout.xhtml
130
101
  - spec/innate/cache/common.rb
131
102
  - spec/innate/cache/marshal.rb
132
103
  - spec/innate/cache/memory.rb
@@ -137,30 +108,30 @@ files:
137
108
  - spec/innate/helper/cgi.rb
138
109
  - spec/innate/helper/flash.rb
139
110
  - spec/innate/helper/link.rb
140
- - spec/innate/helper/partial.rb
141
111
  - spec/innate/helper/redirect.rb
112
+ - spec/innate/helper/render.rb
142
113
  - spec/innate/helper/send_file.rb
143
- - spec/innate/helper/view/aspect_hello.erb
144
- - spec/innate/helper/view/locals.erb
145
- - spec/innate/helper/view/loop.erb
146
- - spec/innate/helper/view/num.erb
147
- - spec/innate/helper/view/partial.erb
148
- - spec/innate/helper/view/recursive.erb
114
+ - spec/innate/helper/view/aspect_hello.xhtml
115
+ - spec/innate/helper/view/locals.xhtml
116
+ - spec/innate/helper/view/loop.xhtml
117
+ - spec/innate/helper/view/num.xhtml
118
+ - spec/innate/helper/view/partial.xhtml
119
+ - spec/innate/helper/view/recursive.xhtml
149
120
  - spec/innate/mock.rb
150
121
  - spec/innate/node/mapping.rb
151
122
  - spec/innate/node/node.rb
152
123
  - spec/innate/node/resolve.rb
153
- - spec/innate/node/view/another_layout/another_layout.erb
154
- - spec/innate/node/view/bar.erb
155
- - spec/innate/node/view/foo.html.erb
156
- - spec/innate/node/view/only_view.erb
157
- - spec/innate/node/view/with_layout.erb
124
+ - spec/innate/node/view/another_layout/another_layout.xhtml
125
+ - spec/innate/node/view/bar.xhtml
126
+ - spec/innate/node/view/foo.html.xhtml
127
+ - spec/innate/node/view/only_view.xhtml
128
+ - spec/innate/node/view/with_layout.xhtml
158
129
  - spec/innate/node/wrap_action_call.rb
159
130
  - spec/innate/options.rb
160
131
  - spec/innate/parameter.rb
161
132
  - spec/innate/provides.rb
162
- - spec/innate/provides/list.html.erb
163
- - spec/innate/provides/list.txt.erb
133
+ - spec/innate/provides/list.html.xhtml
134
+ - spec/innate/provides/list.txt.xhtml
164
135
  - spec/innate/request.rb
165
136
  - spec/innate/route.rb
166
137
  - spec/innate/session.rb
@@ -1,93 +0,0 @@
1
- # Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
2
- # All files in this distribution are subject to the terms of the Ruby license.
3
-
4
- module Innate
5
- module Helper
6
-
7
- # = Helper::Partial
8
- #
9
- # === Example Usage
10
- #
11
- # class MyController
12
- # def index
13
- # end
14
- #
15
- # def list
16
- # plain = request['plain']
17
- # "Hello World from List! Plain List == #{plain}"
18
- # end
19
- # end
20
- #
21
- #
22
- # <html>
23
- # <head><title>Partial Render Index</title></head>
24
- # <body>
25
- # #{render_partial(Rs(:list), 'plain' => true)}
26
- # </body>
27
- # </html>
28
- module Partial
29
- module_function
30
-
31
- # Renders a url 'inline'.
32
- #
33
- # +url+ normal URL, like you'd use for redirecting.
34
- # +options+ optional, will be used as request parameters.
35
- #
36
- # Issues a mock request to the given +url+ with +options+ turned into
37
- # query arguments.
38
- def render_partial(url, options = {})
39
- uri = URI(url)
40
- query = options # Innate::Current.request.params.merge(options)
41
- uri.query = Rack::Utils.build_query(query)
42
-
43
- body = nil
44
-
45
- Innate::Mock.session do |session|
46
- cookie = Innate::Current.session.cookie
47
- session.cookie = cookie
48
- body = session.get(uri.to_s, options).body
49
- end
50
-
51
- body
52
- end
53
-
54
- # Render the template file in view_root of the
55
- # current controller.
56
- #
57
- # TODO:
58
- # * Doesn't work for absolute paths, but there are no specs for that yet.
59
- # * the local variable hack isn't working because innate allocates a new
60
- # binding.
61
- # For now one can simply use instance variables, which I prefer anyway.
62
- #
63
- # the local binding hack:
64
- #
65
- # variables.each do |key, value|
66
- # value = "ObjectSpace._id2ref(#{value.object_id})"
67
- # eval "#{key} = #{value}", action.binding
68
- # end
69
-
70
- def render_template(path, variables = {})
71
- path = path.to_s
72
-
73
- ext = File.extname(path)
74
- basename = File.basename(path, ext)
75
-
76
- action = Innate::Current.action.dup
77
- action.layout = nil
78
- action.view = action.node.find_view(basename, 'html')
79
- action.method = action.node.find_method(basename, action.params)
80
-
81
- action.variables = action.variables.merge(variables)
82
- action.sync_variables(action)
83
-
84
- return action.call if action.valid?
85
- raise(ArgumentError, "cannot render %p" % path)
86
- end
87
-
88
- def render_action(method, *params)
89
- render_partial(r(method), *params)
90
- end
91
- end
92
- end
93
- end
@@ -1 +0,0 @@
1
- <p><%= @content %></p>
@@ -1,101 +0,0 @@
1
- require 'spec/helper'
2
-
3
- class SpecHelperPartial
4
- Innate.node '/'
5
- map_views '/'
6
-
7
- def index
8
- '<html><head><title><%= render_partial("/title") %></title></head></html>'
9
- end
10
-
11
- def title
12
- "Title"
13
- end
14
-
15
- def with_params
16
- '<html><head><title><%= render_partial("/message", :msg => "hello") %></title></head></html>'
17
- end
18
-
19
- def message
20
- "Message: #{request[:msg]}"
21
- end
22
-
23
- def without_ext
24
- render_template('partial')
25
- end
26
-
27
- def with_real_ext
28
- render_template('partial.erb')
29
- end
30
-
31
- def with_needed_ext
32
- render_template('partial.html')
33
- end
34
-
35
- def composed
36
- @here = 'there'
37
- 'From Action | ' << render_template("partial")
38
- end
39
-
40
- def recursive
41
- @n ||= 1
42
- end
43
-
44
- def with_variable
45
- here = 'there'
46
- render_template("partial", :here => here)
47
- end
48
- end
49
-
50
- class SpecHelperPartialWithLayout < SpecHelperPartial
51
- Innate.node '/with_layout'
52
- layout('layout')
53
-
54
- def layout
55
- '<h1>with layout</h1><%= @content %>'
56
- end
57
- end
58
-
59
- describe Innate::Helper::Partial do
60
- behaves_like :mock
61
-
62
- should 'render partials' do
63
- get('/').body.should == '<html><head><title>Title</title></head></html>'
64
- end
65
-
66
- should 'render partials with params' do
67
- get('/with_params').body.should == '<html><head><title>Message: hello</title></head></html>'
68
- end
69
-
70
- should 'be able to render a template in the current scope' do
71
- get('/composed').body.strip.should == "From Action | From Partial there"
72
- end
73
-
74
- should 'not require file extension' do
75
- get('/without_ext').body.should == "From Partial \n"
76
- end
77
-
78
- it "the real extension will just be stripped" do
79
- got = get('/with_real_ext').body.should == "From Partial \n"
80
- end
81
-
82
- it "works with the content representation instead" do
83
- get('/with_needed_ext').body.should == "From Partial \n"
84
- end
85
-
86
- should 'render_template in a loop' do
87
- get('/loop').body.gsub(/\s/,'').should == '12345'
88
- end
89
-
90
- should 'work recursively' do
91
- get('/recursive').body.gsub(/\s/,'').should == '{1{2{3{44}4}3}2}'
92
- end
93
-
94
- should 'render template with layout' do
95
- get('/with_layout/without_ext').body.should == "<h1>with layout</h1>From Partial \n"
96
- end
97
-
98
- it 'makes passed variables available in the template as instance variables' do
99
- get('/with_variable').body.should == "From Partial there\n"
100
- end
101
- end
@@ -1 +0,0 @@
1
- <%= @foo %> <%= @bar %>!
@@ -1 +0,0 @@
1
- <%= say %>, <%= to %>!
@@ -1,4 +0,0 @@
1
- <% (1..5).each do |n| %>
2
- <% @n = n %>
3
- <%= render_template('num') %>
4
- <% end %>
@@ -1 +0,0 @@
1
- <%= @n %>
@@ -1 +0,0 @@
1
- From Partial <%= @here %>
@@ -1,8 +0,0 @@
1
- {
2
- <%= @n %>
3
- <% if @n < 4 %>
4
- <% @n += 1 %>
5
- <%= render_template('recursive') %>
6
- <% end %>
7
- <%= @n %>
8
- }
@@ -1 +0,0 @@
1
- <% 10.times do |n| %><%= n %><% end %>
@@ -1 +0,0 @@
1
- <div class="content"><%= @content %></div>
@@ -1 +0,0 @@
1
- <ul><% @users.each do |user| %><li><%= user %></li><% end %></ul>
@@ -1 +0,0 @@
1
- <% @users.each do |user| %><%= "#{user}\n" %><% end %>