innate 2010.04 → 2010.06.18

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ PROJECT_README = 'README.md'
10
10
  PROJECT_VERSION = (ENV['VERSION'] || Date.today.strftime('%Y.%m.%d')).dup
11
11
 
12
12
  DEPENDENCIES = {
13
- 'rack' => {:version => '= 1.1.0'},
13
+ 'rack' => {:version => '>= 1.1.0'},
14
14
  }
15
15
 
16
16
  DEVELOPMENT_DEPENDENCIES = {
data/innate.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{innate}
5
- s.version = "2010.04"
5
+ s.version = "2010.06.18"
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 = %q{2010-04-04}
9
+ s.date = %q{2010-06-18}
10
10
  s.description = %q{Simple, straight-forward base for web-frameworks.}
11
11
  s.email = %q{m.fellinger@gmail.com}
12
12
  s.files = ["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/helper/send_file.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/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/send_file.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"]
@@ -21,20 +21,20 @@ Gem::Specification.new do |s|
21
21
  s.specification_version = 3
22
22
 
23
23
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
24
- s.add_runtime_dependency(%q<rack>, ["= 1.1.0"])
24
+ s.add_runtime_dependency(%q<rack>, [">= 1.1.0"])
25
+ s.add_development_dependency(%q<json>, ["~> 1.2.0"])
25
26
  s.add_development_dependency(%q<bacon>, [">= 1.1.0"])
26
27
  s.add_development_dependency(%q<rack-test>, [">= 0.5.3"])
27
- s.add_development_dependency(%q<json>, ["~> 1.2.0"])
28
28
  else
29
- s.add_dependency(%q<rack>, ["= 1.1.0"])
29
+ s.add_dependency(%q<rack>, [">= 1.1.0"])
30
+ s.add_dependency(%q<json>, ["~> 1.2.0"])
30
31
  s.add_dependency(%q<bacon>, [">= 1.1.0"])
31
32
  s.add_dependency(%q<rack-test>, [">= 0.5.3"])
32
- s.add_dependency(%q<json>, ["~> 1.2.0"])
33
33
  end
34
34
  else
35
- s.add_dependency(%q<rack>, ["= 1.1.0"])
35
+ s.add_dependency(%q<rack>, [">= 1.1.0"])
36
+ s.add_dependency(%q<json>, ["~> 1.2.0"])
36
37
  s.add_dependency(%q<bacon>, [">= 1.1.0"])
37
38
  s.add_dependency(%q<rack-test>, [">= 0.5.3"])
38
- s.add_dependency(%q<json>, ["~> 1.2.0"])
39
39
  end
40
40
  end
@@ -63,9 +63,6 @@ module Innate
63
63
  :BindAddress => config[:Host],
64
64
  :Port => config[:Port],
65
65
  :Logger => Log,
66
- :AccessLog => [
67
- [Log, ::WEBrick::AccessLog::COMMON_LOG_FORMAT],
68
- [Log, ::WEBrick::AccessLog::REFERER_LOG_FORMAT]]
69
66
  }
70
67
 
71
68
  handler.run(app, config)
@@ -75,8 +75,9 @@ module Innate
75
75
  end
76
76
  end
77
77
 
78
- # Renders an action view, doesn't execute any methods and won't wrap it
79
- # into a layout.
78
+ # Renders an action view and does not execute any methods.
79
+ # The rendered view will not be wrapped in a layout and instead
80
+ # will use the layout of the current action.
80
81
  # You can further tweak the action to be rendered by passing a block.
81
82
  #
82
83
  # @example usage
@@ -1,3 +1,3 @@
1
1
  module Innate
2
- VERSION = "2010.04"
2
+ VERSION = "2010.06.18"
3
3
  end
@@ -2,8 +2,11 @@ module Innate
2
2
  module View
3
3
  module Etanni
4
4
  def self.call(action, string)
5
- etanni = View.compile(string){|str| Innate::Etanni.new(str) }
6
- html = etanni.result(action.binding, (action.view || action.method))
5
+ etanni = View.compile(string) do |str|
6
+ filename = action.view || action.method
7
+ Innate::Etanni.new(str, filename)
8
+ end
9
+ html = etanni.result(action.instance)
7
10
  return html, Response.mime_type
8
11
  end
9
12
  end
@@ -11,24 +14,26 @@ module Innate
11
14
 
12
15
  class Etanni
13
16
  SEPARATOR = "E69t116A65n110N78i105S83e101P80a97R82a97T84o111R82"
14
- START = "\n_out_ << <<#{SEPARATOR}.chomp!\n"
17
+ CHOMP = "<<#{SEPARATOR}.chomp!"
18
+ START = "\n_out_ << #{CHOMP}\n"
15
19
  STOP = "\n#{SEPARATOR}\n"
16
20
  REPLACEMENT = "#{STOP}\\1#{START}"
17
21
 
18
- def initialize(template)
22
+ def initialize(template, filename = '<Etanni>')
19
23
  @template = template
24
+ @filename = filename
20
25
  compile
21
26
  end
22
27
 
23
- def compile
24
- temp = @template.dup
25
- temp.strip!
28
+ def compile(filename = @filename)
29
+ temp = @template.strip
26
30
  temp.gsub!(/<\?r\s+(.*?)\s+\?>/m, REPLACEMENT)
27
- @compiled = "_out_ = [<<#{SEPARATOR}.chomp!]\n#{temp}#{STOP}_out_"
31
+ @compiled = eval("lambda{ _out_ = [#{CHOMP}]\n#{temp}#{STOP}_out_.join }",
32
+ nil, @filename)
28
33
  end
29
34
 
30
- def result(binding, filename = '<Etanni>')
31
- eval(@compiled, binding, filename).join
35
+ def result(instance, filename = @filename)
36
+ instance.instance_eval(&@compiled)
32
37
  end
33
38
  end
34
39
  end
@@ -4,20 +4,24 @@ require 'innate/view/etanni'
4
4
  describe Etanni = Innate::Etanni do
5
5
  it 'renders a simple template' do
6
6
  etanni = Etanni.new('Hello, World!')
7
- etanni.result(binding).should == 'Hello, World!'
7
+ etanni.result(self).should == 'Hello, World!'
8
8
  end
9
9
 
10
10
  it 'allows use of Etanni::SEPARATOR inside interplated code' do
11
- etanni = Etanni.new('Hello #{name}')
12
- name = "\n#{Etanni::SEPARATOR}\n"
13
- etanni.result(binding).should == "Hello #{name}"
11
+ etanni = Etanni.new('Hello #{@name}')
12
+ @name = "\n#{Etanni::SEPARATOR}\n"
13
+ etanni.result(self).should == "Hello #{@name}"
14
14
  end
15
15
 
16
16
  it 'fails with SyntaxError or NameError when the SEPARATOR is used inside a template' do
17
- etanni = Etanni.new("Hello \n#{Etanni::SEPARATOR}\n")
18
- lambda{ etanni.result(binding) }.should.raise NameError
17
+ lambda{
18
+ etanni = Etanni.new("Hello \n#{Etanni::SEPARATOR}\n")
19
+ etanni.result(self)
20
+ }.should.raise NameError
19
21
 
20
- etanni = Etanni.new("<h1>Hello \n#{Etanni::SEPARATOR}\n</h1>")
21
- lambda{ etanni.result(binding) }.should.raise SyntaxError
22
+ lambda{
23
+ etanni = Etanni.new("<h1>Hello \n#{Etanni::SEPARATOR}\n</h1>")
24
+ etanni.result(self)
25
+ }.should.raise SyntaxError
22
26
  end
23
27
  end
metadata CHANGED
@@ -1,11 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: innate
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 16115
4
5
  prerelease: false
5
6
  segments:
6
7
  - 2010
7
- - 4
8
- version: "2010.04"
8
+ - 6
9
+ - 18
10
+ version: 2010.06.18
9
11
  platform: ruby
10
12
  authors:
11
13
  - Michael 'manveru' Fellinger
@@ -13,16 +15,18 @@ autorequire:
13
15
  bindir: bin
14
16
  cert_chain: []
15
17
 
16
- date: 2010-04-04 00:00:00 +09:00
18
+ date: 2010-06-18 00:00:00 +09:00
17
19
  default_executable:
18
20
  dependencies:
19
21
  - !ruby/object:Gem::Dependency
20
22
  name: rack
21
23
  prerelease: false
22
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - "="
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
29
+ hash: 19
26
30
  segments:
27
31
  - 1
28
32
  - 1
@@ -31,45 +35,51 @@ dependencies:
31
35
  type: :runtime
32
36
  version_requirements: *id001
33
37
  - !ruby/object:Gem::Dependency
34
- name: bacon
38
+ name: json
35
39
  prerelease: false
36
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
43
+ - - ~>
39
44
  - !ruby/object:Gem::Version
45
+ hash: 31
40
46
  segments:
41
47
  - 1
42
- - 1
48
+ - 2
43
49
  - 0
44
- version: 1.1.0
50
+ version: 1.2.0
45
51
  type: :development
46
52
  version_requirements: *id002
47
53
  - !ruby/object:Gem::Dependency
48
- name: rack-test
54
+ name: bacon
49
55
  prerelease: false
50
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ">="
53
60
  - !ruby/object:Gem::Version
61
+ hash: 19
54
62
  segments:
63
+ - 1
64
+ - 1
55
65
  - 0
56
- - 5
57
- - 3
58
- version: 0.5.3
66
+ version: 1.1.0
59
67
  type: :development
60
68
  version_requirements: *id003
61
69
  - !ruby/object:Gem::Dependency
62
- name: json
70
+ name: rack-test
63
71
  prerelease: false
64
72
  requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
65
74
  requirements:
66
- - - ~>
75
+ - - ">="
67
76
  - !ruby/object:Gem::Version
77
+ hash: 13
68
78
  segments:
69
- - 1
70
- - 2
71
79
  - 0
72
- version: 1.2.0
80
+ - 5
81
+ - 3
82
+ version: 0.5.3
73
83
  type: :development
74
84
  version_requirements: *id004
75
85
  description: Simple, straight-forward base for web-frameworks.
@@ -224,16 +234,20 @@ rdoc_options: []
224
234
  require_paths:
225
235
  - lib
226
236
  required_ruby_version: !ruby/object:Gem::Requirement
237
+ none: false
227
238
  requirements:
228
239
  - - ">="
229
240
  - !ruby/object:Gem::Version
241
+ hash: 3
230
242
  segments:
231
243
  - 0
232
244
  version: "0"
233
245
  required_rubygems_version: !ruby/object:Gem::Requirement
246
+ none: false
234
247
  requirements:
235
248
  - - ">="
236
249
  - !ruby/object:Gem::Version
250
+ hash: 25
237
251
  segments:
238
252
  - 1
239
253
  - 3