sinatra 2.0.5 → 2.1.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 +4 -4
- data/CHANGELOG.md +74 -0
- data/CONTRIBUTING.md +1 -7
- data/Gemfile +8 -2
- data/README.de.md +4 -4
- data/README.es.md +3 -3
- data/README.fr.md +183 -86
- data/README.hu.md +3 -3
- data/README.ja.md +2 -2
- data/README.ko.md +2 -2
- data/README.md +69 -34
- data/README.pt-br.md +2357 -330
- data/README.pt-pt.md +3 -3
- data/README.ru.md +4 -4
- data/README.zh.md +2 -2
- data/Rakefile +8 -5
- data/VERSION +1 -1
- 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 +107 -73
- data/lib/sinatra/indifferent_hash.rb +13 -9
- data/lib/sinatra/main.rb +30 -11
- data/lib/sinatra/show_exceptions.rb +2 -37
- data/lib/sinatra/version.rb +1 -1
- data/sinatra.gemspec +2 -2
- metadata +10 -9
@@ -132,13 +132,17 @@ module Sinatra
|
|
132
132
|
super(*keys)
|
133
133
|
end
|
134
134
|
|
135
|
-
def merge!(
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
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
|
142
146
|
end
|
143
147
|
|
144
148
|
self
|
@@ -146,8 +150,8 @@ module Sinatra
|
|
146
150
|
|
147
151
|
alias_method :update, :merge!
|
148
152
|
|
149
|
-
def merge(
|
150
|
-
dup.merge!(
|
153
|
+
def merge(*other_hashes, &block)
|
154
|
+
dup.merge!(*other_hashes, &block)
|
151
155
|
end
|
152
156
|
|
153
157
|
def replace(other_hash)
|
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
|
|
@@ -43,43 +43,8 @@ module Sinatra
|
|
43
43
|
]
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
# in the future.
|
49
|
-
def pretty(env, exception)
|
50
|
-
req = Rack::Request.new(env)
|
51
|
-
|
52
|
-
# This double assignment is to prevent an "unused variable" warning on
|
53
|
-
# Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me.
|
54
|
-
path = path = (req.script_name + req.path_info).squeeze("/")
|
55
|
-
|
56
|
-
# This double assignment is to prevent an "unused variable" warning on
|
57
|
-
# Ruby 1.9.3. Yes, it is dumb, but I don't like Ruby yelling at me.
|
58
|
-
frames = frames = exception.backtrace.map { |line|
|
59
|
-
frame = OpenStruct.new
|
60
|
-
if line =~ /(.*?):(\d+)(:in `(.*)')?/
|
61
|
-
frame.filename = $1
|
62
|
-
frame.lineno = $2.to_i
|
63
|
-
frame.function = $4
|
64
|
-
|
65
|
-
begin
|
66
|
-
lineno = frame.lineno-1
|
67
|
-
lines = ::File.readlines(frame.filename)
|
68
|
-
frame.pre_context_lineno = [lineno-CONTEXT, 0].max
|
69
|
-
frame.pre_context = lines[frame.pre_context_lineno...lineno]
|
70
|
-
frame.context_line = lines[lineno].chomp
|
71
|
-
frame.post_context_lineno = [lineno+CONTEXT, lines.size].min
|
72
|
-
frame.post_context = lines[lineno+1..frame.post_context_lineno]
|
73
|
-
rescue
|
74
|
-
end
|
75
|
-
|
76
|
-
frame
|
77
|
-
else
|
78
|
-
nil
|
79
|
-
end
|
80
|
-
}.compact
|
81
|
-
|
82
|
-
TEMPLATE.result(binding)
|
46
|
+
def template
|
47
|
+
TEMPLATE
|
83
48
|
end
|
84
49
|
|
85
50
|
private
|
data/lib/sinatra/version.rb
CHANGED
data/sinatra.gemspec
CHANGED
@@ -46,9 +46,9 @@ RubyGems 2.0 or newer is required to protect against public gem pushes. You can
|
|
46
46
|
EOF
|
47
47
|
end
|
48
48
|
|
49
|
-
s.required_ruby_version = '>= 2.
|
49
|
+
s.required_ruby_version = '>= 2.3.0'
|
50
50
|
|
51
|
-
s.add_dependency 'rack', '~> 2.
|
51
|
+
s.add_dependency 'rack', '~> 2.2'
|
52
52
|
s.add_dependency 'tilt', '~> 2.0'
|
53
53
|
s.add_dependency 'rack-protection', version
|
54
54
|
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.0
|
4
|
+
version: 2.1.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: 2020-09-04 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.0
|
50
|
+
version: 2.1.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.0
|
57
|
+
version: 2.1.0
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: mustermann
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,6 +112,8 @@ files:
|
|
112
112
|
- SECURITY.md
|
113
113
|
- VERSION
|
114
114
|
- examples/chat.rb
|
115
|
+
- examples/rainbows.conf
|
116
|
+
- examples/rainbows.rb
|
115
117
|
- examples/simple.rb
|
116
118
|
- examples/stream.ru
|
117
119
|
- lib/sinatra.rb
|
@@ -148,15 +150,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
150
|
requirements:
|
149
151
|
- - ">="
|
150
152
|
- !ruby/object:Gem::Version
|
151
|
-
version: 2.
|
153
|
+
version: 2.3.0
|
152
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
155
|
requirements:
|
154
156
|
- - ">="
|
155
157
|
- !ruby/object:Gem::Version
|
156
158
|
version: '0'
|
157
159
|
requirements: []
|
158
|
-
|
159
|
-
rubygems_version: 2.7.6
|
160
|
+
rubygems_version: 3.1.2
|
160
161
|
signing_key:
|
161
162
|
specification_version: 4
|
162
163
|
summary: Classy web-development dressed in a DSL
|