innate 2010.03 → 2010.04

Sign up to get free protection for your applications and to get access to all the features.
data/AUTHORS CHANGED
@@ -1,9 +1,10 @@
1
1
  Following persons have contributed to innate.
2
2
  (Sorted by number of submitted patches, then alphabetically)
3
3
 
4
- 754 Michael Fellinger <m.fellinger@gmail.com>
4
+ 760 Michael Fellinger <m.fellinger@gmail.com>
5
5
  31 Tadahiko Uehara <kikofx@gmail.com>
6
6
  8 Pistos <gitsomegrace.5.pistos@geoshell.com>
7
+ 5 injekt <injekt.me@gmail.com>
7
8
  5 Ryan Grove <ryan@wonko.com>
8
9
  3 Lin Jen-Shin <godfat@godfat.org>
9
10
  2 Andreas Karlsson <andreas@proxel.se>
@@ -11,6 +12,7 @@ Following persons have contributed to innate.
11
12
  2 Arnaud Meuret <arnaud@meuret.name>
12
13
  2 TJ Vanderpoel <bougy.man@gmail.com>
13
14
  2 Zoxc <zoxc32@gmail.com>
15
+ 1 crab <crabtw@gmail.com>
14
16
  1 Jérémy Zurcher <jeremy@asynk.ch>
15
17
  1 ravage <ravage@fragmentized.net>
16
18
  1 Sam Carr <samcarr@gmail.com>
data/CHANGELOG CHANGED
@@ -1,3 +1,54 @@
1
+ [b796644 | 2010-04-04 00:56:06 UTC] Michael Fellinger <m.fellinger@gmail.com>
2
+
3
+ * Version 2010.04
4
+
5
+ [1aeacca | 2010-04-03 14:45:46 UTC] injekt <injekt.me@gmail.com>
6
+
7
+ * fixed redirect spec
8
+
9
+ [0a71ec2 | 2010-04-03 14:42:52 UTC] injekt <injekt.me@gmail.com>
10
+
11
+ * fixed redirect spec
12
+
13
+ [6eedc76 | 2010-03-29 14:07:51 UTC] injekt <injekt.me@gmail.com>
14
+
15
+ * minor fixes to README
16
+
17
+ [b5787a4 | 2010-03-29 08:31:03 UTC] injekt <injekt.me@gmail.com>
18
+
19
+ * Added support for case-insensitive View lookups
20
+
21
+ Removed case sensitive restriction when using Controller::engine
22
+ for View lookup; :haml is as good as :Haml
23
+
24
+ [edc00df | 2010-03-27 14:55:07 UTC] injekt <injekt.me@gmail.com>
25
+
26
+ * fixed doc for flash helper (depreciated method)
27
+
28
+ [2e4bdbd | 2010-03-24 06:18:35 UTC] Michael Fellinger <m.fellinger@gmail.com>
29
+
30
+ * Add spec for how to pass arguments to provide actions
31
+
32
+ [d09ff45 | 2010-03-18 16:37:27 UTC] Michael Fellinger <m.fellinger@gmail.com>
33
+
34
+ * Fix some issues, don't split Content-Type at all
35
+
36
+ [abe842c | 2010-03-18 16:33:41 UTC] Michael Fellinger <m.fellinger@gmail.com>
37
+
38
+ * Make sure ; doesn't break Content-Type
39
+
40
+ [acce333 | 2010-03-18 03:26:03 UTC] Michael Fellinger <m.fellinger@gmail.com>
41
+
42
+ * The Response Content-Type option should influence default mime type
43
+
44
+ [7ad4de7 | 2010-03-11 04:44:42 UTC] crab <crabtw@gmail.com>
45
+
46
+ * use Innate.options.prefix as redirect fallback
47
+
48
+ [e13e2b2 | 2010-03-09 01:48:06 UTC] Michael Fellinger <m.fellinger@gmail.com>
49
+
50
+ * Fix .dup in Rakefile
51
+
1
52
  [4fa40fc | 2010-03-08 13:53:00 UTC] Michael Fellinger <m.fellinger@gmail.com>
2
53
 
3
54
  * Version 2010.03
data/MANIFEST CHANGED
@@ -115,6 +115,7 @@ spec/innate/provides.rb
115
115
  spec/innate/provides/list.html.xhtml
116
116
  spec/innate/provides/list.txt.xhtml
117
117
  spec/innate/request.rb
118
+ spec/innate/response.rb
118
119
  spec/innate/route.rb
119
120
  spec/innate/session.rb
120
121
  spec/innate/traited.rb
data/README.md CHANGED
@@ -470,7 +470,7 @@ there is no need to keep this around.
470
470
 
471
471
  ### Contrib
472
472
 
473
- Ramaze got quite some things in contrib, some of them used widely, others not at
473
+ Ramaze has some things in contrib, some of them used widely, others not at
474
474
  all.
475
475
 
476
476
  I'm still going through these, putting what is suitable for a wider audience
@@ -507,8 +507,8 @@ Ruby stdlib.
507
507
 
508
508
  ### Templating
509
509
 
510
- The basic functionality for templating is provided by Innate, it only provides a
511
- `None` and `ERB` templating engine. The other engines are in Ramaze.
510
+ The basic functionality for templating is provided by Innate, it only provides the
511
+ `None`, `Etanni` and `ERB` templating engines. The other engines are in Ramaze.
512
512
 
513
513
  #### Ezamar
514
514
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'date'
7
7
  PROJECT_SPECS = FileList['spec/{innate,example}/**/*.rb'].exclude('common.rb')
8
8
  PROJECT_MODULE = 'Innate'
9
9
  PROJECT_README = 'README.md'
10
- PROJECT_VERSION = ENV['VERSION'].dup || Date.today.strftime('%Y.%m.%d')
10
+ PROJECT_VERSION = (ENV['VERSION'] || Date.today.strftime('%Y.%m.%d')).dup
11
11
 
12
12
  DEPENDENCIES = {
13
13
  'rack' => {:version => '= 1.1.0'},
data/innate.gemspec CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{innate}
5
- s.version = "2010.03"
5
+ s.version = "2010.04"
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-03-08}
9
+ s.date = %q{2010-04-04}
10
10
  s.description = %q{Simple, straight-forward base for web-frameworks.}
11
11
  s.email = %q{m.fellinger@gmail.com}
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/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"]
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"]
13
13
  s.homepage = %q{http://github.com/manveru/innate}
14
14
  s.require_paths = ["lib"]
15
15
  s.rubyforge_project = %q{innate}
@@ -19,7 +19,7 @@ module Innate
19
19
  # On the first request, for example on registering:
20
20
  #
21
21
  # flash[:error] = "You should reconsider your username, it's taken already"
22
- # redirect R(self, :register)
22
+ # redirect r(:register)
23
23
  #
24
24
  # This is the request from the redirect:
25
25
  #
@@ -4,14 +4,14 @@ module Innate
4
4
  def respond(body, status = 200, header = {})
5
5
  response.write body
6
6
  response.status = status
7
- header['Content-Type'] ||= 'text/html'
7
+ header['Content-Type'] ||= Response.mime_type
8
8
  header.each{|key, value| response[key] = value }
9
9
 
10
10
  throw(:respond, response)
11
11
  end
12
12
 
13
13
  def respond!(body, status = 200, header = {})
14
- header['Content-Type'] ||= 'text/html'
14
+ header['Content-Type'] ||= Response.mime_type
15
15
  throw(:respond, Response.new(body, status, header))
16
16
  end
17
17
 
@@ -70,7 +70,7 @@ module Innate
70
70
  "<a href='#{target}'>#{h target}</a>!"
71
71
  end
72
72
 
73
- def redirect_referrer(fallback = '/')
73
+ def redirect_referrer(fallback = Innate.options.prefix)
74
74
  if (referer = request.env['HTTP_REFERER']) && (url = request.url)
75
75
  referer_uri, request_uri = URI(referer), URI(url)
76
76
 
@@ -7,6 +7,10 @@ module Innate
7
7
  :headers, {'Content-Type' => 'text/html'}
8
8
  end
9
9
 
10
+ def self.mime_type
11
+ options[:headers]['Content-Type'] || 'text/html'
12
+ end
13
+
10
14
  def reset
11
15
  self.status = 200
12
16
  self.header.delete('Content-Type')
@@ -1,3 +1,3 @@
1
1
  module Innate
2
- VERSION = "2010.03"
2
+ VERSION = "2010.04"
3
3
  end
@@ -7,7 +7,7 @@ module Innate
7
7
  erb = View.compile(string){|str| ::ERB.new(str, nil, '%<>') }
8
8
  erb.filename = (action.view || action.method).to_s
9
9
  html = erb.result(action.binding)
10
- return html, 'text/html'
10
+ return html, Response.mime_type
11
11
  end
12
12
  end
13
13
  end
@@ -4,7 +4,7 @@ module Innate
4
4
  def self.call(action, string)
5
5
  etanni = View.compile(string){|str| Innate::Etanni.new(str) }
6
6
  html = etanni.result(action.binding, (action.view || action.method))
7
- return html, 'text/html'
7
+ return html, Response.mime_type
8
8
  end
9
9
  end
10
10
  end
@@ -2,7 +2,7 @@ module Innate
2
2
  module View
3
3
  module None
4
4
  def self.call(action, string)
5
- return string.to_s, 'text/html'
5
+ return string.to_s, Response.mime_type
6
6
  end
7
7
  end
8
8
  end
data/lib/innate/view.rb CHANGED
@@ -50,8 +50,12 @@ module Innate
50
50
  # No mutex is used in Fiber environment, see Innate::State and subclasses.
51
51
  def obtain(klass, root = Object)
52
52
  Innate.sync do
53
- klass.to_s.scan(/\w+/){|part| root = root.const_get(part) }
54
- return root
53
+ view_name = /^#{klass.to_s.downcase.dup.delete('_')}$/i
54
+ if view = View.constants.grep(view_name).first
55
+ root.const_get(view)
56
+ else
57
+ raise(NameError, "View #{klass} not found")
58
+ end
55
59
  end
56
60
  end
57
61
 
@@ -20,6 +20,10 @@ class SpecRedirectHelper
20
20
  end
21
21
 
22
22
  def redirect_referer_action
23
+ redirect_referer
24
+ end
25
+
26
+ def redirect_referer_with_fallback
23
27
  redirect_referer(r(:noop))
24
28
  end
25
29
 
@@ -90,17 +94,17 @@ describe Innate::Helper::Redirect do
90
94
  end
91
95
 
92
96
  should 'redirect to referer' do
93
- header 'HTTP_REFERER', "#@uri/index"
97
+ header 'REFERER', "#@uri/noop"
94
98
  get("#@uri/redirect_referer_action")
95
99
 
96
100
  last_response.status.should == 302
97
- last_response.headers['Location'].should == "#@uri/index"
101
+ last_response.headers['Location'].should == "#@uri/noop"
98
102
  last_response.headers['Content-Type'].should == "text/html"
99
103
  end
100
104
 
101
105
  should 'redirect to fallback if referrer is identical' do
102
- header 'HTTP_REFERER', "#@uri/redirect_referer_action"
103
- get("#@uri/redirect_referer_action")
106
+ header 'REFERER', "#@uri/redirect_referer_with_fallback"
107
+ get("#@uri/redirect_referer_with_fallback")
104
108
 
105
109
  last_response.status.should == 302
106
110
  last_response.headers['Location'].should == "#@uri/noop"
@@ -19,6 +19,10 @@ class SpecNodeProvides
19
19
  def string
20
20
  'Just 42'
21
21
  end
22
+
23
+ def args(*args)
24
+ args
25
+ end
22
26
  end
23
27
 
24
28
  class SpecNodeProvidesTemplates
@@ -62,6 +66,12 @@ describe 'Content representation' do
62
66
  it 'defaults to html presentation' do
63
67
  assert_wish('/string', 'Just 42', 'text/html')
64
68
  end
69
+
70
+ it 'takes arguments with <name>/arg1/arg2.json' do
71
+ assert_wish('/args', '[]', 'text/html')
72
+ assert_wish('/args.json', '[]', 'application/json')
73
+ assert_wish('/args/a/b/c.json', '["a","b","c"]', 'application/json')
74
+ end
65
75
  end
66
76
 
67
77
  describe 'with templates' do
@@ -0,0 +1,32 @@
1
+ require File.expand_path('../../helper', __FILE__)
2
+
3
+ class SpecResponse
4
+ Innate.node '/'
5
+
6
+ def index
7
+ "some text"
8
+ end
9
+ end
10
+
11
+ describe Innate::Response do
12
+ describe 'Content-Type' do
13
+ behaves_like :rack_test
14
+
15
+ it 'responds with text/html by default' do
16
+ got = get('/')
17
+ got['Content-Type'].should == 'text/html'
18
+ end
19
+
20
+ it 'changes when option is changed' do
21
+ Innate::Response.options.headers['Content-Type'] = 'text/plain'
22
+ got = get('/')
23
+ got['Content-Type'].should == 'text/plain'
24
+ end
25
+
26
+ it 'is ok with extended value' do
27
+ Innate::Response.options.headers['Content-Type'] = 'text/plain; charset=utf-8'
28
+ got = get('/')
29
+ got['Content-Type'].should == 'text/plain; charset=utf-8'
30
+ end
31
+ end
32
+ end
metadata CHANGED
@@ -4,8 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2010
7
- - 3
8
- version: "2010.03"
7
+ - 4
8
+ version: "2010.04"
9
9
  platform: ruby
10
10
  authors:
11
11
  - Michael 'manveru' Fellinger
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2010-03-08 00:00:00 +09:00
16
+ date: 2010-04-04 00:00:00 +09:00
17
17
  default_executable:
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
@@ -198,6 +198,7 @@ files:
198
198
  - spec/innate/provides/list.html.xhtml
199
199
  - spec/innate/provides/list.txt.xhtml
200
200
  - spec/innate/request.rb
201
+ - spec/innate/response.rb
201
202
  - spec/innate/route.rb
202
203
  - spec/innate/session.rb
203
204
  - spec/innate/traited.rb