sinatra 1.4.8 → 2.0.8.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sinatra might be problematic. Click here for more details.

Files changed (129) hide show
  1. checksums.yaml +5 -5
  2. data/AUTHORS.md +1 -0
  3. data/CHANGELOG.md +238 -54
  4. data/CONTRIBUTING.md +8 -8
  5. data/Gemfile +47 -47
  6. data/LICENSE +4 -1
  7. data/MAINTENANCE.md +42 -0
  8. data/README.de.md +650 -442
  9. data/README.es.md +738 -357
  10. data/README.fr.md +15 -15
  11. data/README.hu.md +37 -3
  12. data/README.ja.md +124 -66
  13. data/README.ko.md +14 -14
  14. data/README.malayalam.md +3141 -0
  15. data/README.md +530 -403
  16. data/README.pt-br.md +2361 -334
  17. data/README.pt-pt.md +2 -2
  18. data/README.ru.md +856 -607
  19. data/README.zh.md +90 -28
  20. data/Rakefile +77 -51
  21. data/SECURITY.md +35 -0
  22. data/VERSION +1 -0
  23. data/lib/sinatra/base.rb +177 -239
  24. data/lib/sinatra/indifferent_hash.rb +200 -0
  25. data/lib/sinatra/main.rb +30 -10
  26. data/lib/sinatra/show_exceptions.rb +102 -62
  27. data/lib/sinatra/version.rb +1 -1
  28. data/sinatra.gemspec +44 -8
  29. metadata +41 -166
  30. data/lib/sinatra/ext.rb +0 -17
  31. data/test/asciidoctor_test.rb +0 -72
  32. data/test/base_test.rb +0 -167
  33. data/test/builder_test.rb +0 -91
  34. data/test/coffee_test.rb +0 -96
  35. data/test/compile_test.rb +0 -183
  36. data/test/contest.rb +0 -91
  37. data/test/creole_test.rb +0 -65
  38. data/test/delegator_test.rb +0 -160
  39. data/test/encoding_test.rb +0 -20
  40. data/test/erb_test.rb +0 -116
  41. data/test/extensions_test.rb +0 -98
  42. data/test/filter_test.rb +0 -487
  43. data/test/haml_test.rb +0 -109
  44. data/test/helper.rb +0 -132
  45. data/test/helpers_test.rb +0 -1917
  46. data/test/integration/app.rb +0 -79
  47. data/test/integration_helper.rb +0 -236
  48. data/test/integration_test.rb +0 -104
  49. data/test/less_test.rb +0 -69
  50. data/test/liquid_test.rb +0 -77
  51. data/test/mapped_error_test.rb +0 -285
  52. data/test/markaby_test.rb +0 -80
  53. data/test/markdown_test.rb +0 -85
  54. data/test/mediawiki_test.rb +0 -68
  55. data/test/middleware_test.rb +0 -68
  56. data/test/nokogiri_test.rb +0 -67
  57. data/test/public/favicon.ico +0 -0
  58. data/test/public/hello+world.txt +0 -1
  59. data/test/rabl_test.rb +0 -89
  60. data/test/rack_test.rb +0 -45
  61. data/test/radius_test.rb +0 -59
  62. data/test/rdoc_test.rb +0 -66
  63. data/test/readme_test.rb +0 -130
  64. data/test/request_test.rb +0 -100
  65. data/test/response_test.rb +0 -63
  66. data/test/result_test.rb +0 -76
  67. data/test/route_added_hook_test.rb +0 -59
  68. data/test/routing_test.rb +0 -1456
  69. data/test/sass_test.rb +0 -115
  70. data/test/scss_test.rb +0 -88
  71. data/test/server_test.rb +0 -56
  72. data/test/settings_test.rb +0 -582
  73. data/test/sinatra_test.rb +0 -12
  74. data/test/slim_test.rb +0 -102
  75. data/test/static_test.rb +0 -266
  76. data/test/streaming_test.rb +0 -149
  77. data/test/stylus_test.rb +0 -90
  78. data/test/templates_test.rb +0 -382
  79. data/test/textile_test.rb +0 -65
  80. data/test/views/a/in_a.str +0 -1
  81. data/test/views/ascii.erb +0 -2
  82. data/test/views/b/in_b.str +0 -1
  83. data/test/views/calc.html.erb +0 -1
  84. data/test/views/error.builder +0 -3
  85. data/test/views/error.erb +0 -3
  86. data/test/views/error.haml +0 -3
  87. data/test/views/error.sass +0 -2
  88. data/test/views/explicitly_nested.str +0 -1
  89. data/test/views/foo/hello.test +0 -1
  90. data/test/views/hello.asciidoc +0 -1
  91. data/test/views/hello.builder +0 -1
  92. data/test/views/hello.coffee +0 -1
  93. data/test/views/hello.creole +0 -1
  94. data/test/views/hello.erb +0 -1
  95. data/test/views/hello.haml +0 -1
  96. data/test/views/hello.less +0 -5
  97. data/test/views/hello.liquid +0 -1
  98. data/test/views/hello.mab +0 -1
  99. data/test/views/hello.md +0 -1
  100. data/test/views/hello.mediawiki +0 -1
  101. data/test/views/hello.nokogiri +0 -1
  102. data/test/views/hello.rabl +0 -2
  103. data/test/views/hello.radius +0 -1
  104. data/test/views/hello.rdoc +0 -1
  105. data/test/views/hello.sass +0 -2
  106. data/test/views/hello.scss +0 -3
  107. data/test/views/hello.slim +0 -1
  108. data/test/views/hello.str +0 -1
  109. data/test/views/hello.styl +0 -2
  110. data/test/views/hello.test +0 -1
  111. data/test/views/hello.textile +0 -1
  112. data/test/views/hello.wlang +0 -1
  113. data/test/views/hello.yajl +0 -1
  114. data/test/views/layout2.builder +0 -3
  115. data/test/views/layout2.erb +0 -2
  116. data/test/views/layout2.haml +0 -2
  117. data/test/views/layout2.liquid +0 -2
  118. data/test/views/layout2.mab +0 -2
  119. data/test/views/layout2.nokogiri +0 -3
  120. data/test/views/layout2.rabl +0 -3
  121. data/test/views/layout2.radius +0 -2
  122. data/test/views/layout2.slim +0 -3
  123. data/test/views/layout2.str +0 -2
  124. data/test/views/layout2.test +0 -1
  125. data/test/views/layout2.wlang +0 -2
  126. data/test/views/nested.str +0 -1
  127. data/test/views/utf8.erb +0 -2
  128. data/test/wlang_test.rb +0 -87
  129. data/test/yajl_test.rb +0 -86
data/test/sass_test.rb DELETED
@@ -1,115 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- begin
4
- require 'sass'
5
-
6
- class SassTest < Minitest::Test
7
- def sass_app(options = {}, &block)
8
- mock_app do
9
- set :views, File.dirname(__FILE__) + '/views'
10
- set options
11
- get('/', &block)
12
- end
13
- get '/'
14
- end
15
-
16
- it 'renders inline Sass strings' do
17
- sass_app { sass "#sass\n :background-color white\n" }
18
- assert ok?
19
- assert_equal "#sass {\n background-color: white; }\n", body
20
- end
21
-
22
- it 'defaults content type to css' do
23
- sass_app { sass "#sass\n :background-color white\n" }
24
- assert ok?
25
- assert_equal "text/css;charset=utf-8", response['Content-Type']
26
- end
27
-
28
- it 'defaults allows setting content type per route' do
29
- sass_app do
30
- content_type :html
31
- sass "#sass\n :background-color white\n"
32
- end
33
- assert ok?
34
- assert_equal "text/html;charset=utf-8", response['Content-Type']
35
- end
36
-
37
- it 'defaults allows setting content type globally' do
38
- sass_app(:sass => { :content_type => 'html' }) {
39
- sass "#sass\n :background-color white\n"
40
- }
41
- assert ok?
42
- assert_equal "text/html;charset=utf-8", response['Content-Type']
43
- end
44
-
45
- it 'renders .sass files in views path' do
46
- sass_app { sass :hello }
47
- assert ok?
48
- assert_equal "#sass {\n background-color: white; }\n", body
49
- end
50
-
51
- it 'ignores the layout option' do
52
- sass_app { sass :hello, :layout => :layout2 }
53
- assert ok?
54
- assert_equal "#sass {\n background-color: white; }\n", body
55
- end
56
-
57
- it "raises error if template not found" do
58
- mock_app { get('/') { sass :no_such_template } }
59
- assert_raises(Errno::ENOENT) { get('/') }
60
- end
61
-
62
- it "passes SASS options to the Sass engine" do
63
- sass_app do
64
- sass(
65
- "#sass\n :background-color white\n :color black\n",
66
- :style => :compact
67
- )
68
- end
69
- assert ok?
70
- assert_equal("#sass { background-color: white; color: black; }\n", body)
71
- end
72
-
73
- it "passes default SASS options to the Sass engine" do
74
- mock_app do
75
- set :sass, {:style => :compact} # default Sass style is :nested
76
- get('/') { sass("#sass\n :background-color white\n :color black\n") }
77
- end
78
- get '/'
79
- assert ok?
80
- assert_equal "#sass { background-color: white; color: black; }\n", body
81
- end
82
-
83
- it "merges the default SASS options with the overrides" do
84
- mock_app do
85
- # default Sass attribute_syntax is :normal (with : in front)
86
- set :sass, {:style => :compact, :attribute_syntax => :alternate }
87
- get('/') { sass("#sass\n background-color: white\n color: black\n") }
88
- get('/raised') do
89
- # retains global attribute_syntax settings
90
- sass(
91
- "#sass\n :background-color white\n :color black\n",
92
- :style => :expanded
93
- )
94
- end
95
- get('/expanded_normal') do
96
- sass(
97
- "#sass\n :background-color white\n :color black\n",
98
- :style => :expanded, :attribute_syntax => :normal
99
- )
100
- end
101
- end
102
- get '/'
103
- assert ok?
104
- assert_equal "#sass { background-color: white; color: black; }\n", body
105
- assert_raises(Sass::SyntaxError) { get('/raised') }
106
- get '/expanded_normal'
107
- assert ok?
108
- assert_equal "#sass {\n background-color: white;\n color: black;\n}\n",
109
- body
110
- end
111
- end
112
-
113
- rescue LoadError
114
- warn "#{$!.to_s}: skipping sass tests"
115
- end
data/test/scss_test.rb DELETED
@@ -1,88 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
-
3
- begin
4
- require 'sass'
5
-
6
- class ScssTest < Minitest::Test
7
- def scss_app(options = {}, &block)
8
- mock_app do
9
- set :views, File.dirname(__FILE__) + '/views'
10
- set options
11
- get('/', &block)
12
- end
13
- get '/'
14
- end
15
-
16
- it 'renders inline Scss strings' do
17
- scss_app { scss "#scss {\n background-color: white; }\n" }
18
- assert ok?
19
- assert_equal "#scss {\n background-color: white; }\n", body
20
- end
21
-
22
- it 'defaults content type to css' do
23
- scss_app { scss "#scss {\n background-color: white; }\n" }
24
- assert ok?
25
- assert_equal "text/css;charset=utf-8", response['Content-Type']
26
- end
27
-
28
- it 'defaults allows setting content type per route' do
29
- scss_app do
30
- content_type :html
31
- scss "#scss {\n background-color: white; }\n"
32
- end
33
- assert ok?
34
- assert_equal "text/html;charset=utf-8", response['Content-Type']
35
- end
36
-
37
- it 'defaults allows setting content type globally' do
38
- scss_app(:scss => { :content_type => 'html' }) {
39
- scss "#scss {\n background-color: white; }\n"
40
- }
41
- assert ok?
42
- assert_equal "text/html;charset=utf-8", response['Content-Type']
43
- end
44
-
45
- it 'renders .scss files in views path' do
46
- scss_app { scss :hello }
47
- assert ok?
48
- assert_equal "#scss {\n background-color: white; }\n", body
49
- end
50
-
51
- it 'ignores the layout option' do
52
- scss_app { scss :hello, :layout => :layout2 }
53
- assert ok?
54
- assert_equal "#scss {\n background-color: white; }\n", body
55
- end
56
-
57
- it "raises error if template not found" do
58
- mock_app { get('/') { scss(:no_such_template) } }
59
- assert_raises(Errno::ENOENT) { get('/') }
60
- end
61
-
62
- it "passes scss options to the scss engine" do
63
- scss_app do
64
- scss(
65
- "#scss {\n background-color: white;\n color: black\n}",
66
- :style => :compact
67
- )
68
- end
69
- assert ok?
70
- assert_equal "#scss { background-color: white; color: black; }\n", body
71
- end
72
-
73
- it "passes default scss options to the scss engine" do
74
- mock_app do
75
- set :scss, {:style => :compact} # default scss style is :nested
76
- get('/') {
77
- scss("#scss {\n background-color: white;\n color: black;\n}")
78
- }
79
- end
80
- get '/'
81
- assert ok?
82
- assert_equal "#scss { background-color: white; color: black; }\n", body
83
- end
84
- end
85
-
86
- rescue LoadError
87
- warn "#{$!.to_s}: skipping scss tests"
88
- end
data/test/server_test.rb DELETED
@@ -1,56 +0,0 @@
1
- require File.expand_path('../helper', __FILE__)
2
- require 'stringio'
3
-
4
- module Rack::Handler
5
- class Mock
6
- extend Minitest::Assertions
7
- # Allow assertions in request context
8
- def self.assertions
9
- @assertions ||= 0
10
- end
11
-
12
- def self.assertions= assertions
13
- @assertions = assertions
14
- end
15
-
16
- def self.run(app, options={})
17
- assert(app < Sinatra::Base)
18
- assert_equal 9001, options[:Port]
19
- assert_equal 'foo.local', options[:Host]
20
- yield new
21
- end
22
-
23
- def stop
24
- end
25
- end
26
-
27
- register 'mock', 'Rack::Handler::Mock'
28
- end
29
-
30
- class ServerTest < Minitest::Test
31
- setup do
32
- mock_app do
33
- set :server, 'mock'
34
- set :bind, 'foo.local'
35
- set :port, 9001
36
- end
37
- $stderr = StringIO.new
38
- end
39
-
40
- def teardown
41
- $stderr = STDERR
42
- end
43
-
44
- it "locates the appropriate Rack handler and calls ::run" do
45
- @app.run!
46
- end
47
-
48
- it "sets options on the app before running" do
49
- @app.run! :sessions => true
50
- assert @app.sessions?
51
- end
52
-
53
- it "falls back on the next server handler when not found" do
54
- @app.run! :server => %w[foo bar mock]
55
- end
56
- end