sinatra 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sinatra might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/AUTHORS.md +1 -0
- data/CHANGELOG.md +258 -37
- data/CONTRIBUTING.md +7 -7
- data/Gemfile +15 -6
- data/MAINTENANCE.md +2 -15
- data/README.de.md +22 -22
- data/README.es.md +772 -362
- data/README.fr.md +188 -91
- data/README.hu.md +3 -3
- data/README.ja.md +84 -54
- data/README.ko.md +7 -7
- data/README.malayalam.md +3141 -0
- data/README.md +165 -113
- data/README.pt-br.md +2366 -339
- data/README.pt-pt.md +3 -3
- data/README.ru.md +835 -564
- data/README.zh.md +83 -21
- data/Rakefile +10 -7
- data/VERSION +1 -0
- data/examples/chat.rb +2 -1
- data/examples/rainbows.conf +3 -0
- data/examples/rainbows.rb +20 -0
- data/examples/stream.ru +4 -4
- data/lib/sinatra/base.rb +160 -123
- data/lib/sinatra/indifferent_hash.rb +79 -15
- data/lib/sinatra/main.rb +30 -11
- data/lib/sinatra/show_exceptions.rb +8 -11
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +25 -7
- metadata +20 -22
@@ -1,4 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
$stderr.puts <<EOF if !Hash.method_defined?(:slice) && !$LOAD_PATH.grep(%r{gems/activesupport}).empty? && ENV['SINATRA_ACTIVESUPPORT_WARNING'] != 'false'
|
3
|
+
WARNING: If you plan to load any of ActiveSupport's core extensions to Hash, be
|
4
|
+
sure to do so *before* loading Sinatra::Application or Sinatra::Base. If not,
|
5
|
+
you may disregard this warning.
|
6
|
+
|
7
|
+
Set SINATRA_ACTIVESUPPORT_WARNING=false in the environment to hide this warning.
|
8
|
+
EOF
|
9
|
+
|
2
10
|
module Sinatra
|
3
11
|
# A poor man's ActiveSupport::HashWithIndifferentAccess, with all the Rails-y
|
4
12
|
# stuff removed.
|
@@ -41,11 +49,15 @@ module Sinatra
|
|
41
49
|
end
|
42
50
|
|
43
51
|
def initialize(*args)
|
44
|
-
|
52
|
+
args.map!(&method(:convert_value))
|
53
|
+
|
54
|
+
super(*args)
|
45
55
|
end
|
46
56
|
|
47
57
|
def default(*args)
|
48
|
-
|
58
|
+
args.map!(&method(:convert_key))
|
59
|
+
|
60
|
+
super(*args)
|
49
61
|
end
|
50
62
|
|
51
63
|
def default=(value)
|
@@ -61,7 +73,9 @@ module Sinatra
|
|
61
73
|
end
|
62
74
|
|
63
75
|
def fetch(key, *args)
|
64
|
-
|
76
|
+
args.map!(&method(:convert_value))
|
77
|
+
|
78
|
+
super(convert_key(key), *args)
|
65
79
|
end
|
66
80
|
|
67
81
|
def [](key)
|
@@ -101,20 +115,34 @@ module Sinatra
|
|
101
115
|
end if method_defined?(:dig) # Added in Ruby 2.3
|
102
116
|
|
103
117
|
def fetch_values(*keys)
|
104
|
-
|
118
|
+
keys.map!(&method(:convert_key))
|
119
|
+
|
120
|
+
super(*keys)
|
105
121
|
end if method_defined?(:fetch_values) # Added in Ruby 2.3
|
106
122
|
|
107
|
-
def
|
108
|
-
|
109
|
-
end
|
123
|
+
def slice(*keys)
|
124
|
+
keys.map!(&method(:convert_key))
|
110
125
|
|
111
|
-
|
112
|
-
|
126
|
+
self.class[super(*keys)]
|
127
|
+
end if method_defined?(:slice) # Added in Ruby 2.5
|
113
128
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
129
|
+
def values_at(*keys)
|
130
|
+
keys.map!(&method(:convert_key))
|
131
|
+
|
132
|
+
super(*keys)
|
133
|
+
end
|
134
|
+
|
135
|
+
def merge!(*other_hashes)
|
136
|
+
other_hashes.each do |other_hash|
|
137
|
+
if other_hash.is_a?(self.class)
|
138
|
+
super(other_hash)
|
139
|
+
else
|
140
|
+
other_hash.each_pair do |key, value|
|
141
|
+
key = convert_key(key)
|
142
|
+
value = yield(key, self[key], value) if block_given? && key?(key)
|
143
|
+
self[key] = convert_value(value)
|
144
|
+
end
|
145
|
+
end
|
118
146
|
end
|
119
147
|
|
120
148
|
self
|
@@ -122,14 +150,50 @@ module Sinatra
|
|
122
150
|
|
123
151
|
alias_method :update, :merge!
|
124
152
|
|
125
|
-
def merge(
|
126
|
-
dup.merge!(
|
153
|
+
def merge(*other_hashes, &block)
|
154
|
+
dup.merge!(*other_hashes, &block)
|
127
155
|
end
|
128
156
|
|
129
157
|
def replace(other_hash)
|
130
158
|
super(other_hash.is_a?(self.class) ? other_hash : self.class[other_hash])
|
131
159
|
end
|
132
160
|
|
161
|
+
if method_defined?(:transform_values!) # Added in Ruby 2.4
|
162
|
+
def transform_values(&block)
|
163
|
+
dup.transform_values!(&block)
|
164
|
+
end
|
165
|
+
|
166
|
+
def transform_values!
|
167
|
+
super
|
168
|
+
super(&method(:convert_value))
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
if method_defined?(:transform_keys!) # Added in Ruby 2.5
|
173
|
+
def transform_keys(&block)
|
174
|
+
dup.transform_keys!(&block)
|
175
|
+
end
|
176
|
+
|
177
|
+
def transform_keys!
|
178
|
+
super
|
179
|
+
super(&method(:convert_key))
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def select(*args, &block)
|
184
|
+
return to_enum(:select) unless block_given?
|
185
|
+
dup.tap { |hash| hash.select!(*args, &block) }
|
186
|
+
end
|
187
|
+
|
188
|
+
def reject(*args, &block)
|
189
|
+
return to_enum(:reject) unless block_given?
|
190
|
+
dup.tap { |hash| hash.reject!(*args, &block) }
|
191
|
+
end
|
192
|
+
|
193
|
+
def compact
|
194
|
+
dup.tap(&:compact!)
|
195
|
+
end if method_defined?(:compact) # Added in Ruby 2.4
|
196
|
+
|
133
197
|
private
|
134
198
|
|
135
199
|
def convert_key(key)
|
data/lib/sinatra/main.rb
CHANGED
@@ -1,6 +1,30 @@
|
|
1
|
-
require 'sinatra/base'
|
2
|
-
|
3
1
|
module Sinatra
|
2
|
+
ParamsConfig = {}
|
3
|
+
|
4
|
+
if ARGV.any?
|
5
|
+
require 'optparse'
|
6
|
+
parser = OptionParser.new { |op|
|
7
|
+
op.on('-p port', 'set the port (default is 4567)') { |val| ParamsConfig[:port] = Integer(val) }
|
8
|
+
op.on('-s server', 'specify rack server/handler') { |val| ParamsConfig[:server] = val }
|
9
|
+
op.on('-q', 'turn on quiet mode (default is off)') { ParamsConfig[:quiet] = true }
|
10
|
+
op.on('-x', 'turn on the mutex lock (default is off)') { ParamsConfig[:lock] = true }
|
11
|
+
op.on('-e env', 'set the environment (default is development)') do |val|
|
12
|
+
ENV['RACK_ENV'] = val
|
13
|
+
ParamsConfig[:environment] = val.to_sym
|
14
|
+
end
|
15
|
+
op.on('-o addr', "set the host (default is (env == 'development' ? 'localhost' : '0.0.0.0'))") do |val|
|
16
|
+
ParamsConfig[:bind] = val
|
17
|
+
end
|
18
|
+
}
|
19
|
+
begin
|
20
|
+
parser.parse!(ARGV.dup)
|
21
|
+
rescue => evar
|
22
|
+
ParamsConfig[:optparse_error] = evar
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'sinatra/base'
|
27
|
+
|
4
28
|
class Application < Base
|
5
29
|
|
6
30
|
# we assume that the first file that requires 'sinatra' is the
|
@@ -11,18 +35,13 @@ module Sinatra
|
|
11
35
|
set :run, Proc.new { File.expand_path($0) == File.expand_path(app_file) }
|
12
36
|
|
13
37
|
if run? && ARGV.any?
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
op.on('-o addr', "set the host (default is #{bind})") { |val| set :bind, val }
|
18
|
-
op.on('-e env', 'set the environment (default is development)') { |val| set :environment, val.to_sym }
|
19
|
-
op.on('-s server', 'specify rack server/handler (default is thin)') { |val| set :server, val }
|
20
|
-
op.on('-q', 'turn on quiet mode (default is off)') { set :quiet, true }
|
21
|
-
op.on('-x', 'turn on the mutex lock (default is off)') { set :lock, true }
|
22
|
-
}.parse!(ARGV.dup)
|
38
|
+
error = ParamsConfig.delete(:optparse_error)
|
39
|
+
raise error if error
|
40
|
+
ParamsConfig.each { |k, v| set k, v }
|
23
41
|
end
|
24
42
|
end
|
25
43
|
|
44
|
+
remove_const(:ParamsConfig)
|
26
45
|
at_exit { Application.run! if $!.nil? && Application.run? }
|
27
46
|
end
|
28
47
|
|
@@ -25,28 +25,28 @@ module Sinatra
|
|
25
25
|
|
26
26
|
if prefers_plain_text?(env)
|
27
27
|
content_type = "text/plain"
|
28
|
-
|
28
|
+
body = dump_exception(e)
|
29
29
|
else
|
30
30
|
content_type = "text/html"
|
31
|
-
|
31
|
+
body = pretty(env, e)
|
32
32
|
end
|
33
33
|
|
34
34
|
env["rack.errors"] = errors
|
35
35
|
|
36
|
-
# Post 893a2c50 in rack/rack, the #pretty method above, implemented in
|
37
|
-
# Rack::ShowExceptions, returns a String instead of an array.
|
38
|
-
body = Array(exception)
|
39
|
-
|
40
36
|
[
|
41
37
|
500,
|
42
38
|
{
|
43
39
|
"Content-Type" => content_type,
|
44
|
-
"Content-Length" => body.
|
40
|
+
"Content-Length" => body.bytesize.to_s
|
45
41
|
},
|
46
|
-
body
|
42
|
+
[body]
|
47
43
|
]
|
48
44
|
end
|
49
45
|
|
46
|
+
def template
|
47
|
+
TEMPLATE
|
48
|
+
end
|
49
|
+
|
50
50
|
private
|
51
51
|
|
52
52
|
def bad_request?(e)
|
@@ -360,6 +360,3 @@ enabled the <code>show_exceptions</code> setting.</p>
|
|
360
360
|
HTML
|
361
361
|
end
|
362
362
|
end
|
363
|
-
|
364
|
-
Rack::ShowExceptions.send :remove_const, "TEMPLATE"
|
365
|
-
Rack::ShowExceptions.const_set "TEMPLATE", Sinatra::ShowExceptions::TEMPLATE
|
data/lib/sinatra/version.rb
CHANGED
data/sinatra.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new 'sinatra', version do |s|
|
|
5
5
|
s.summary = "Classy web-development dressed in a DSL"
|
6
6
|
s.authors = ["Blake Mizerany", "Ryan Tomayko", "Simon Rozet", "Konstantin Haase"]
|
7
7
|
s.email = "sinatrarb@googlegroups.com"
|
8
|
-
s.homepage = "http://
|
8
|
+
s.homepage = "http://sinatrarb.com/"
|
9
9
|
s.license = 'MIT'
|
10
10
|
s.files = Dir['README*.md', 'lib/**/*', 'examples/*'] + [
|
11
11
|
".yardopts",
|
@@ -17,14 +17,32 @@ Gem::Specification.new 'sinatra', version do |s|
|
|
17
17
|
"MAINTENANCE.md",
|
18
18
|
"Rakefile",
|
19
19
|
"SECURITY.md",
|
20
|
-
"sinatra.gemspec"
|
21
|
-
|
22
|
-
s.extra_rdoc_files =
|
23
|
-
s.rdoc_options = %w[--line-numbers --
|
20
|
+
"sinatra.gemspec",
|
21
|
+
"VERSION"]
|
22
|
+
s.extra_rdoc_files = %w[README.md LICENSE]
|
23
|
+
s.rdoc_options = %w[--line-numbers --title Sinatra --main README.rdoc --encoding=UTF-8]
|
24
24
|
|
25
|
-
s.
|
25
|
+
if s.respond_to?(:metadata)
|
26
|
+
s.metadata = {
|
27
|
+
'source_code_uri' => 'https://github.com/sinatra/sinatra',
|
28
|
+
'changelog_uri' => 'https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md',
|
29
|
+
'homepage_uri' => 'http://sinatrarb.com/',
|
30
|
+
'bug_tracker_uri' => 'https://github.com/sinatra/sinatra/issues',
|
31
|
+
'mailing_list_uri' => 'http://groups.google.com/group/sinatrarb',
|
32
|
+
'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra'
|
33
|
+
}
|
34
|
+
else
|
35
|
+
raise <<-EOF
|
36
|
+
RubyGems 2.0 or newer is required to protect against public gem pushes. You can update your rubygems version by running:
|
37
|
+
gem install rubygems-update
|
38
|
+
update_rubygems:
|
39
|
+
gem update --system
|
40
|
+
EOF
|
41
|
+
end
|
26
42
|
|
27
|
-
s.
|
43
|
+
s.required_ruby_version = '>= 2.3.0'
|
44
|
+
|
45
|
+
s.add_dependency 'rack', '~> 2.2'
|
28
46
|
s.add_dependency 'tilt', '~> 2.0'
|
29
47
|
s.add_dependency 'rack-protection', version
|
30
48
|
s.add_dependency 'mustermann', '~> 1.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Blake Mizerany
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2022-02-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rack
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '2.
|
22
|
+
version: '2.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
29
|
+
version: '2.2'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: tilt
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -47,14 +47,14 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - '='
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 2.
|
50
|
+
version: 2.2.0
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - '='
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 2.
|
57
|
+
version: 2.2.0
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mustermann
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,17 +75,7 @@ email: sinatrarb@googlegroups.com
|
|
75
75
|
executables: []
|
76
76
|
extensions: []
|
77
77
|
extra_rdoc_files:
|
78
|
-
- README.de.md
|
79
|
-
- README.es.md
|
80
|
-
- README.fr.md
|
81
|
-
- README.hu.md
|
82
|
-
- README.ja.md
|
83
|
-
- README.ko.md
|
84
78
|
- README.md
|
85
|
-
- README.pt-br.md
|
86
|
-
- README.pt-pt.md
|
87
|
-
- README.ru.md
|
88
|
-
- README.zh.md
|
89
79
|
- LICENSE
|
90
80
|
files:
|
91
81
|
- ".yardopts"
|
@@ -101,6 +91,7 @@ files:
|
|
101
91
|
- README.hu.md
|
102
92
|
- README.ja.md
|
103
93
|
- README.ko.md
|
94
|
+
- README.malayalam.md
|
104
95
|
- README.md
|
105
96
|
- README.pt-br.md
|
106
97
|
- README.pt-pt.md
|
@@ -108,7 +99,10 @@ files:
|
|
108
99
|
- README.zh.md
|
109
100
|
- Rakefile
|
110
101
|
- SECURITY.md
|
102
|
+
- VERSION
|
111
103
|
- examples/chat.rb
|
104
|
+
- examples/rainbows.conf
|
105
|
+
- examples/rainbows.rb
|
112
106
|
- examples/simple.rb
|
113
107
|
- examples/stream.ru
|
114
108
|
- lib/sinatra.rb
|
@@ -120,14 +114,19 @@ files:
|
|
120
114
|
- lib/sinatra/show_exceptions.rb
|
121
115
|
- lib/sinatra/version.rb
|
122
116
|
- sinatra.gemspec
|
123
|
-
homepage: http://
|
117
|
+
homepage: http://sinatrarb.com/
|
124
118
|
licenses:
|
125
119
|
- MIT
|
126
|
-
metadata:
|
120
|
+
metadata:
|
121
|
+
source_code_uri: https://github.com/sinatra/sinatra
|
122
|
+
changelog_uri: https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md
|
123
|
+
homepage_uri: http://sinatrarb.com/
|
124
|
+
bug_tracker_uri: https://github.com/sinatra/sinatra/issues
|
125
|
+
mailing_list_uri: http://groups.google.com/group/sinatrarb
|
126
|
+
documentation_uri: https://www.rubydoc.info/gems/sinatra
|
127
127
|
post_install_message:
|
128
128
|
rdoc_options:
|
129
129
|
- "--line-numbers"
|
130
|
-
- "--inline-source"
|
131
130
|
- "--title"
|
132
131
|
- Sinatra
|
133
132
|
- "--main"
|
@@ -139,15 +138,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
138
|
requirements:
|
140
139
|
- - ">="
|
141
140
|
- !ruby/object:Gem::Version
|
142
|
-
version: 2.
|
141
|
+
version: 2.3.0
|
143
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
143
|
requirements:
|
145
144
|
- - ">="
|
146
145
|
- !ruby/object:Gem::Version
|
147
146
|
version: '0'
|
148
147
|
requirements: []
|
149
|
-
|
150
|
-
rubygems_version: 2.6.11
|
148
|
+
rubygems_version: 3.1.2
|
151
149
|
signing_key:
|
152
150
|
specification_version: 4
|
153
151
|
summary: Classy web-development dressed in a DSL
|