innate 2011.12 → 2012.03

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ PROJECT_README = 'README.md'
9
9
  PROJECT_VERSION = (ENV['VERSION'] || Date.today.strftime('%Y.%m.%d')).dup
10
10
 
11
11
  DEPENDENCIES = {
12
- 'rack' => {:version => '~> 1.4.0'},
12
+ 'rack' => {:version => '~> 1.4.1'},
13
13
  }
14
14
 
15
15
  DEVELOPMENT_DEPENDENCIES = {
@@ -2,35 +2,35 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "innate"
5
- s.version = "2011.12"
5
+ s.version = "2012.03"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.3.1") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Michael 'manveru' Fellinger"]
9
- s.date = "2011-12-28"
9
+ s.date = "2012-03-07"
10
10
  s.description = "Simple, straight-forward base for web-frameworks."
11
11
  s.email = "m.fellinger@gmail.com"
12
12
  s.files = [".gems", ".gitignore", ".load_gemset", ".rvmrc", ".travis.yml", "AUTHORS", "CHANGELOG", "COPYING", "MANIFEST", "README.md", "Rakefile", "example/app/retro_games.rb", "example/app/todo/layout/default.xhtml", "example/app/todo/spec/todo.rb", "example/app/todo/start.rb", "example/app/todo/view/index.xhtml", "example/app/whywiki_erb/layout/wiki.html.erb", "example/app/whywiki_erb/spec/wiki.rb", "example/app/whywiki_erb/start.rb", "example/app/whywiki_erb/view/edit.erb", "example/app/whywiki_erb/view/index.erb", "example/custom_middleware.rb", "example/hello.rb", "example/howto_spec.rb", "example/link.rb", "example/provides.rb", "example/session.rb", "innate.gemspec", "lib/innate.rb", "lib/innate/action.rb", "lib/innate/adapter.rb", "lib/innate/cache.rb", "lib/innate/cache/api.rb", "lib/innate/cache/drb.rb", "lib/innate/cache/file_based.rb", "lib/innate/cache/marshal.rb", "lib/innate/cache/memory.rb", "lib/innate/cache/yaml.rb", "lib/innate/current.rb", "lib/innate/dynamap.rb", "lib/innate/helper.rb", "lib/innate/helper/aspect.rb", "lib/innate/helper/cgi.rb", "lib/innate/helper/flash.rb", "lib/innate/helper/link.rb", "lib/innate/helper/redirect.rb", "lib/innate/helper/render.rb", "lib/innate/log.rb", "lib/innate/log/color_formatter.rb", "lib/innate/log/hub.rb", "lib/innate/middleware_compiler.rb", "lib/innate/mock.rb", "lib/innate/node.rb", "lib/innate/options.rb", "lib/innate/options/dsl.rb", "lib/innate/options/stub.rb", "lib/innate/rack_file_wrapper.rb", "lib/innate/request.rb", "lib/innate/response.rb", "lib/innate/route.rb", "lib/innate/session.rb", "lib/innate/session/flash.rb", "lib/innate/spec.rb", "lib/innate/spec/bacon.rb", "lib/innate/state.rb", "lib/innate/state/accessor.rb", "lib/innate/traited.rb", "lib/innate/trinity.rb", "lib/innate/version.rb", "lib/innate/view.rb", "lib/innate/view/erb.rb", "lib/innate/view/etanni.rb", "lib/innate/view/none.rb", "spec/example/app/retro_games.rb", "spec/example/hello.rb", "spec/example/link.rb", "spec/example/provides.rb", "spec/example/session.rb", "spec/helper.rb", "spec/innate/action/layout.rb", "spec/innate/action/layout/file_layout.xhtml", "spec/innate/cache/common.rb", "spec/innate/cache/marshal.rb", "spec/innate/cache/memory.rb", "spec/innate/cache/yaml.rb", "spec/innate/dynamap.rb", "spec/innate/etanni.rb", "spec/innate/helper.rb", "spec/innate/helper/aspect.rb", "spec/innate/helper/cgi.rb", "spec/innate/helper/flash.rb", "spec/innate/helper/link.rb", "spec/innate/helper/redirect.rb", "spec/innate/helper/render.rb", "spec/innate/helper/view/aspect_hello.xhtml", "spec/innate/helper/view/locals.xhtml", "spec/innate/helper/view/loop.xhtml", "spec/innate/helper/view/num.xhtml", "spec/innate/helper/view/partial.xhtml", "spec/innate/helper/view/recursive.xhtml", "spec/innate/mock.rb", "spec/innate/modes.rb", "spec/innate/node/mapping.rb", "spec/innate/node/node.rb", "spec/innate/node/resolve.rb", "spec/innate/node/view/another_layout/another_layout.xhtml", "spec/innate/node/view/bar.xhtml", "spec/innate/node/view/cat2/cat22.xhtml", "spec/innate/node/view/cat3/cat33.xhtml", "spec/innate/node/view/foo.html.xhtml", "spec/innate/node/view/only_view.xhtml", "spec/innate/node/view/sub/baz.xhtml", "spec/innate/node/view/sub/foo/baz.xhtml", "spec/innate/node/view/with_layout.xhtml", "spec/innate/node/wrap_action_call.rb", "spec/innate/options.rb", "spec/innate/parameter.rb", "spec/innate/provides.rb", "spec/innate/provides/list.html.xhtml", "spec/innate/provides/list.txt.xhtml", "spec/innate/request.rb", "spec/innate/response.rb", "spec/innate/route.rb", "spec/innate/session.rb", "spec/innate/traited.rb", "tasks/authors.rake", "tasks/bacon.rake", "tasks/changelog.rake", "tasks/gem.rake", "tasks/gem_setup.rake", "tasks/grancher.rake", "tasks/manifest.rake", "tasks/rcov.rake", "tasks/release.rake", "tasks/reversion.rake", "tasks/setup.rake", "tasks/ycov.rake"]
13
13
  s.homepage = "http://github.com/manveru/innate"
14
14
  s.require_paths = ["lib"]
15
15
  s.rubyforge_project = "innate"
16
- s.rubygems_version = "1.8.10"
16
+ s.rubygems_version = "1.8.15"
17
17
  s.summary = "Powerful web-framework wrapper for Rack."
18
18
 
19
19
  if s.respond_to? :specification_version then
20
20
  s.specification_version = 3
21
21
 
22
22
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
23
- s.add_runtime_dependency(%q<rack>, ["~> 1.4.0"])
24
- s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
23
+ s.add_runtime_dependency(%q<rack>, ["~> 1.4.1"])
25
24
  s.add_development_dependency(%q<rack-test>, [">= 0.6.1"])
25
+ s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
26
26
  else
27
- s.add_dependency(%q<rack>, ["~> 1.4.0"])
28
- s.add_dependency(%q<bacon>, [">= 1.1.0"])
27
+ s.add_dependency(%q<rack>, ["~> 1.4.1"])
29
28
  s.add_dependency(%q<rack-test>, [">= 0.6.1"])
29
+ s.add_dependency(%q<bacon>, [">= 1.1.0"])
30
30
  end
31
31
  else
32
- s.add_dependency(%q<rack>, ["~> 1.4.0"])
33
- s.add_dependency(%q<bacon>, [">= 1.1.0"])
32
+ s.add_dependency(%q<rack>, ["~> 1.4.1"])
34
33
  s.add_dependency(%q<rack-test>, [">= 0.6.1"])
34
+ s.add_dependency(%q<bacon>, [">= 1.1.0"])
35
35
  end
36
36
  end
@@ -102,11 +102,10 @@ module Innate
102
102
  # @param [Cache] cache
103
103
  def self.register(cache)
104
104
  key = cache.name.to_s
105
- source = "def self.#{key}() @#{key}; end
106
- def self.#{key}=(o) @#{key} = o; end"
107
- self.class_eval(source, __FILE__, __LINE__)
105
+ return if respond_to?(key) && respond_to?("#{key}=")
106
+ (class << self; self; end).send(:attr_accessor, key)
108
107
 
109
- self.send("#{key}=", cache)
108
+ send("#{key}=", cache)
110
109
  end
111
110
 
112
111
  def self.add(*names)
@@ -52,7 +52,7 @@ module Innate
52
52
  # This method is mostly here in case you include this helper elsewhere
53
53
  # and don't want (or can't) type SomeNode.r all the time.
54
54
  #
55
- # The usage is identical with {route}.
55
+ # The usage is identical with {Innate::Helper::Link#route}.
56
56
  #
57
57
  # @param [#to_s] name
58
58
  # @return [URI] to the location
@@ -134,7 +134,7 @@ module Innate
134
134
  # @api internal
135
135
  # @author manveru
136
136
  def render_custom(action_name, variables = {})
137
- unless action = resolve(action_name.to_s)
137
+ unless action = resolve(action_name.to_s, :needs_method => false)
138
138
  raise(ArgumentError, "No Action %p on #{self}" % [action_name])
139
139
  end
140
140
 
@@ -3,14 +3,14 @@ class Logger
3
3
  #
4
4
  # The basic mapping of ANSI colors is as follows:
5
5
  #
6
- # | reset | bold | dark | underline | blink | negative
7
- # MOD | 0 | 1 | 2 | 4 | 5 | 7
6
+ # | reset | bold | dark | underline | blink | negative
7
+ # MOD | 0 | 1 | 2 | 4 | 5 | 7
8
8
  #
9
- # | black | red | green | yellow | blue | magenta | cyan | white
10
- # FG | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37
11
- # BG | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47
9
+ # | black | red | green | yellow | blue | magenta | cyan | white
10
+ # FG | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37
11
+ # BG | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47
12
12
  #
13
- # The output is done by: "\e[#{mod};#{fg};#{bg}m#{string}\e[0m"
13
+ # The output is done by: ``\e[#{mod};#{fg};#{bg}m#{string}\e[0m``.
14
14
  # The suffix is to reset the terminal to the original state again.
15
15
  class ColorFormatter < Formatter
16
16
  LEVEL_COLOR = {
@@ -32,7 +32,7 @@ module Innate
32
32
  end
33
33
 
34
34
  def cascade(*apps)
35
- @app = Rack::Cascade.new(apps)
35
+ @app = Rack::Cascade.new(apps, [404, 405])
36
36
  end
37
37
 
38
38
  # Default application for Innate
@@ -13,7 +13,7 @@ module Innate
13
13
  # scheme.
14
14
  #
15
15
  # This makes dispatching more fun, avoids a lot of processing that is done by
16
- # {Rack} anyway and lets you tailor your application down to the last action
16
+ # Rack anyway and lets you tailor your application down to the last action
17
17
  # exactly the way you want without worrying about side-effects to other
18
18
  # {Node}s.
19
19
  #
@@ -269,7 +269,7 @@ module Innate
269
269
  end
270
270
 
271
271
  # Let's try to find some valid action for given +path+.
272
- # Otherwise we dispatch to {action_missing}.
272
+ # Otherwise we dispatch to {Innate::Node#action_missing}.
273
273
  #
274
274
  # @param [String] path from env['PATH_INFO']
275
275
  #
@@ -356,16 +356,18 @@ module Innate
356
356
  # html.
357
357
  #
358
358
  # @param [String] path
359
+ # @param [Hash] options
359
360
  #
360
361
  # @return [nil, Action]
361
362
  #
362
363
  # @api external
363
364
  # @see Node::find_provide Node::update_method_arities Node::find_action
364
365
  # @author manveru
365
- def resolve(path)
366
+ def resolve(path, options = {})
366
367
  name, wish, engine = find_provide(path)
367
368
  node = (respond_to?(:ancestors) && respond_to?(:new)) ? self : self.class
368
- action = Action.create(:node => node, :wish => wish, :engine => engine, :path => path)
369
+ action = Action.create(:node => node, :wish => wish, :engine => engine, :path => path, :options => options)
370
+ action.options.key?(:needs_method) || action.options[:needs_method] = node.needs_method?
369
371
 
370
372
  if content_type = node.ancestral_trait["#{wish}_content_type"]
371
373
  action.options = {:content_type => content_type}
@@ -376,7 +378,8 @@ module Innate
376
378
  node.fill_action(action, name)
377
379
  end
378
380
 
379
- # Resolve possible provides for the given +path+ from {provides}.
381
+ # Resolve possible provides for the given +path+ from
382
+ # {Innate::Node#provides}.
380
383
  #
381
384
  # @param [String] path
382
385
  #
@@ -414,7 +417,7 @@ module Innate
414
417
  # Action#wish Action#merge!
415
418
  # @author manveru
416
419
  def fill_action(action, given_name)
417
- needs_method = self.needs_method?
420
+ needs_method = action.options[:needs_method]
418
421
  wish = action.wish
419
422
 
420
423
  patterns_for(given_name) do |name, params|
@@ -558,8 +561,8 @@ module Innate
558
561
 
559
562
  # Try to find the best template for the given basename and wish.
560
563
  #
561
- # This method is mostly here for symetry with {to_layout} and to allow you
562
- # overriding the template lookup easily.
564
+ # This method is mostly here for symetry with {Innate::Node#to_layout} and
565
+ # to allow you overriding the template lookup easily.
563
566
  #
564
567
  # @param [#to_s] action_name
565
568
  # @param [#to_s] wish
@@ -650,7 +653,7 @@ module Innate
650
653
  # Define a layout to use on this Node.
651
654
  #
652
655
  # A Node can only have one layout, although the template being chosen can
653
- # depend on {provides}.
656
+ # depend on {Innate::Node#provides}.
654
657
  #
655
658
  # @example
656
659
  # layout :foo
@@ -991,7 +994,8 @@ module Innate
991
994
  ancestral_trait[:needs_method]
992
995
  end
993
996
 
994
- # This will return true if the only provides set are by {Node::included}.
997
+ # This will return true if the only provides set are by
998
+ # {Innate::Node.included}.
995
999
  #
996
1000
  # The reasoning behind this is to determine whether the user has touched
997
1001
  # the provides at all, in which case we will not override the provides in
@@ -47,21 +47,23 @@ module Innate
47
47
  # Builds a trait from all the ancestors, closer ancestors overwrite distant
48
48
  # ancestors
49
49
  #
50
- # class Foo
51
- # include Innate::Traited
52
- # trait :one => :eins, :first => :erstes
53
- # end
50
+ # @example
51
+ # class Foo
52
+ # include Innate::Traited
53
+ # trait :one => :eins, :first => :erstes
54
+ # end
54
55
  #
55
- # class Bar < Foo
56
- # trait :two => :zwei
57
- # end
56
+ # class Bar < Foo
57
+ # trait :two => :zwei
58
+ # end
58
59
  #
59
- # class Foobar < Bar
60
- # trait :three => :drei, :first => :overwritten
61
- # end
60
+ # class Foobar < Bar
61
+ # trait :three => :drei, :first => :overwritten
62
+ # end
62
63
  #
63
- # Foobar.ancestral_trait
64
- # # => {:three => :drei, :two => :zwei, :one => :eins, :first => :overwritten}
64
+ # Foobar.ancestral_trait # => {
65
+ # :three => :drei, :two => :zwei, :one => :eins, :first => :overwritten
66
+ # }
65
67
  def ancestral_trait
66
68
  klass = self.kind_of?(Module) ? self : self.class
67
69
  ANCESTRAL_TRAITS[klass] ||=
@@ -1,3 +1,3 @@
1
1
  module Innate
2
- VERSION = "2011.12"
2
+ VERSION = "2012.03"
3
3
  end
@@ -96,6 +96,21 @@ class SpecHelperRenderFile
96
96
  end
97
97
  end
98
98
 
99
+ class SpecHelperRenderNeedsMethodView
100
+ Innate.node '/render_needs_method_view'
101
+ map_views '/'
102
+ layout :layout
103
+ trait :needs_method => true
104
+
105
+ def layout
106
+ '{ #{@content} }'
107
+ end
108
+
109
+ def without_method_or_layout
110
+ render_view(:num, :n => 42)
111
+ end
112
+ end
113
+
99
114
  describe Innate::Helper::Render do
100
115
  describe '#render_full' do
101
116
  behaves_like :rack_test
@@ -139,6 +154,10 @@ describe Innate::Helper::Render do
139
154
  it 'renders action without calling the method or applying layout' do
140
155
  get('/render_view/without_method_or_layout').body.should == '{ 42 }'
141
156
  end
157
+
158
+ it 'renders action even when needs_method is true' do
159
+ get('/render_needs_method_view/without_method_or_layout').body.should == '{ 42 }'
160
+ end
142
161
  end
143
162
 
144
163
  describe 'misc functionality' do
metadata CHANGED
@@ -1,55 +1,78 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: innate
3
- version: !ruby/object:Gem::Version
4
- version: '2011.12'
3
+ version: !ruby/object:Gem::Version
4
+ hash: 8061
5
5
  prerelease:
6
+ segments:
7
+ - 2012
8
+ - 3
9
+ version: "2012.03"
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Michael 'manveru' Fellinger
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2011-12-28 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2012-03-07 00:00:00 Z
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
15
20
  name: rack
16
- requirement: &16472440 !ruby/object:Gem::Requirement
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
17
23
  none: false
18
- requirements:
24
+ requirements:
19
25
  - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 1.4.0
26
+ - !ruby/object:Gem::Version
27
+ hash: 5
28
+ segments:
29
+ - 1
30
+ - 4
31
+ - 1
32
+ version: 1.4.1
22
33
  type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rack-test
23
37
  prerelease: false
24
- version_requirements: *16472440
25
- - !ruby/object:Gem::Dependency
26
- name: bacon
27
- requirement: &16472000 !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
28
39
  none: false
29
- requirements:
30
- - - ! '>='
31
- - !ruby/object:Gem::Version
32
- version: 1.1.0
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 5
44
+ segments:
45
+ - 0
46
+ - 6
47
+ - 1
48
+ version: 0.6.1
33
49
  type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: bacon
34
53
  prerelease: false
35
- version_requirements: *16472000
36
- - !ruby/object:Gem::Dependency
37
- name: rack-test
38
- requirement: &16471480 !ruby/object:Gem::Requirement
54
+ requirement: &id003 !ruby/object:Gem::Requirement
39
55
  none: false
40
- requirements:
41
- - - ! '>='
42
- - !ruby/object:Gem::Version
43
- version: 0.6.1
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 19
60
+ segments:
61
+ - 1
62
+ - 1
63
+ - 0
64
+ version: 1.1.0
44
65
  type: :development
45
- prerelease: false
46
- version_requirements: *16471480
66
+ version_requirements: *id003
47
67
  description: Simple, straight-forward base for web-frameworks.
48
68
  email: m.fellinger@gmail.com
49
69
  executables: []
70
+
50
71
  extensions: []
72
+
51
73
  extra_rdoc_files: []
52
- files:
74
+
75
+ files:
53
76
  - .gems
54
77
  - .gitignore
55
78
  - .load_gemset
@@ -189,26 +212,38 @@ files:
189
212
  - tasks/ycov.rake
190
213
  homepage: http://github.com/manveru/innate
191
214
  licenses: []
215
+
192
216
  post_install_message:
193
217
  rdoc_options: []
194
- require_paths:
218
+
219
+ require_paths:
195
220
  - lib
196
- required_ruby_version: !ruby/object:Gem::Requirement
221
+ required_ruby_version: !ruby/object:Gem::Requirement
197
222
  none: false
198
- requirements:
199
- - - ! '>='
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- required_rubygems_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ hash: 3
227
+ segments:
228
+ - 0
229
+ version: "0"
230
+ required_rubygems_version: !ruby/object:Gem::Requirement
203
231
  none: false
204
- requirements:
205
- - - ! '>='
206
- - !ruby/object:Gem::Version
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ hash: 25
236
+ segments:
237
+ - 1
238
+ - 3
239
+ - 1
207
240
  version: 1.3.1
208
241
  requirements: []
242
+
209
243
  rubyforge_project: innate
210
- rubygems_version: 1.8.10
244
+ rubygems_version: 1.8.15
211
245
  signing_key:
212
246
  specification_version: 3
213
247
  summary: Powerful web-framework wrapper for Rack.
214
248
  test_files: []
249
+