roda-i18n 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,98 +0,0 @@
1
- # $:.unshift(File.join(File.dirname(File.dirname(File.expand_path(__FILE__))), 'lib'))
2
-
3
- if ENV['COVERAGE']
4
- require File.join(File.dirname(File.expand_path(__FILE__)), "roda_i18n_coverage")
5
- SimpleCov.roda_i18n_coverage
6
- end
7
-
8
- ENV['RACK_ENV'] = 'test'
9
-
10
- require 'rubygems'
11
- require 'roda'
12
- require 'tilt/erubis'
13
- require 'rack/test'
14
- require 'r18n-core'
15
- require 'minitest/autorun'
16
- require 'minitest/hooks/default'
17
- require 'kramdown'
18
- require 'date'
19
-
20
- require "#{File.dirname(__FILE__)}/../lib/roda/plugins/i18n"
21
-
22
- class Minitest::HooksSpec
23
- include Rack::Test::Methods
24
-
25
- def rt(path,opts={})
26
- get path
27
- last_response.body
28
- end
29
-
30
- def app(type=nil, &block)
31
- case type
32
- when :new
33
- @app = _app{route(&block)}
34
- when :bare
35
- @app = _app(&block)
36
- when Symbol
37
- @app = _app do
38
- plugin type
39
- route(&block)
40
- end
41
- else
42
- @app ||= _app{route(&block)}
43
- end
44
- end
45
-
46
- def req(path='/', env={})
47
- if path.is_a?(Hash)
48
- env = path
49
- else
50
- env['PATH_INFO'] = path
51
- end
52
-
53
- env = {"REQUEST_METHOD" => "GET", "PATH_INFO" => "/", "SCRIPT_NAME" => ""}.merge(env)
54
- @app.call(env)
55
- end
56
-
57
- def status(path='/', env={})
58
- req(path, env)[0]
59
- end
60
-
61
- def header(name, path='/', env={})
62
- req(path, env)[1][name]
63
- end
64
-
65
- def body(path='/', env={})
66
- s = ''
67
- b = req(path, env)[2]
68
- b.each{|x| s << x}
69
- b.close if b.respond_to?(:close)
70
- s
71
- end
72
-
73
- def _app(&block)
74
- c = Class.new(Roda)
75
- c.plugin :render
76
- c.plugin(:not_found){raise "path #{request.path_info} not found"}
77
- c.use Rack::Session::Cookie, :secret=>'topsecret'
78
- c.class_eval do
79
- def erb(s, opts={})
80
- render(opts.merge(:inline=>s))
81
- end
82
- end
83
- c.class_eval(&block)
84
- c
85
- end
86
-
87
- # syntactic sugar
88
- def _body
89
- last_response.body
90
- end
91
-
92
- # syntactic sugar
93
- def _status
94
- last_response.status
95
- end
96
-
97
- end
98
-