roda-i18n 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,98 @@
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
+
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: roda-i18n
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kematzy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: The Roda-i18n plugin enables easy addition of internationalisation (i18n)
14
+ and localisation support in Roda apps
15
+ email: kematzy@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - README.md
20
+ - MIT-LICENSE
21
+ files:
22
+ - MIT-LICENSE
23
+ - README.md
24
+ - Rakefile
25
+ - lib/roda/plugins/i18n.rb
26
+ - spec/fixtures/app/i18n/de.yml
27
+ - spec/fixtures/app/i18n/en.yml
28
+ - spec/fixtures/app/i18n/es.yml
29
+ - spec/fixtures/i18n/de.yml
30
+ - spec/fixtures/i18n/en.yml
31
+ - spec/fixtures/i18n/sv-se.yml
32
+ - spec/roda_i18n_coverage.rb
33
+ - spec/roda_i18n_spec.rb
34
+ - spec/spec_helper.rb
35
+ homepage: http://github.com/kematzy/roda-i18n
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options:
41
+ - "--quiet"
42
+ - "--line-numbers"
43
+ - "--inline-source"
44
+ - "--title"
45
+ - 'Roda-i18n: internationalisation plugin'
46
+ - "--main"
47
+ - README.md
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubyforge_project:
62
+ rubygems_version: 2.4.5
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: Roda Internationalisation plugin
66
+ test_files: []