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.

@@ -132,13 +132,17 @@ module Sinatra
132
132
  super(*keys)
133
133
  end
134
134
 
135
- def merge!(other_hash)
136
- return super if other_hash.is_a?(self.class)
137
-
138
- other_hash.each_pair do |key, value|
139
- key = convert_key(key)
140
- value = yield(key, self[key], value) if block_given? && key?(key)
141
- self[key] = convert_value(value)
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(other_hash, &block)
150
- dup.merge!(other_hash, &block)
153
+ def merge(*other_hashes, &block)
154
+ dup.merge!(*other_hashes, &block)
151
155
  end
152
156
 
153
157
  def replace(other_hash)
@@ -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
- require 'optparse'
15
- OptionParser.new { |op|
16
- op.on('-p port', 'set the port (default is 4567)') { |val| set :port, Integer(val) }
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
- # Pulled from Rack::ShowExceptions in order to override TEMPLATE.
47
- # If Rack provides another way to override, this could be removed
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
@@ -1,3 +1,3 @@
1
1
  module Sinatra
2
- VERSION = '2.0.5'
2
+ VERSION = '2.1.0'
3
3
  end
@@ -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.2.0'
49
+ s.required_ruby_version = '>= 2.3.0'
50
50
 
51
- s.add_dependency 'rack', '~> 2.0'
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.5
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: 2018-12-22 00:00:00.000000000 Z
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.0'
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.0'
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.5
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.5
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.2.0
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
- rubyforge_project:
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