sinatra 2.0.0 → 2.0.8.1

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.

@@ -25,28 +25,63 @@ module Sinatra
25
25
 
26
26
  if prefers_plain_text?(env)
27
27
  content_type = "text/plain"
28
- exception = dump_exception(e)
28
+ body = dump_exception(e)
29
29
  else
30
30
  content_type = "text/html"
31
- exception = pretty(env, e)
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.join.bytesize.to_s
40
+ "Content-Length" => body.bytesize.to_s
45
41
  },
46
- body
42
+ [body]
47
43
  ]
48
44
  end
49
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)
83
+ end
84
+
50
85
  private
51
86
 
52
87
  def bad_request?(e)
@@ -360,6 +395,3 @@ enabled the <code>show_exceptions</code> setting.</p>
360
395
  HTML
361
396
  end
362
397
  end
363
-
364
- Rack::ShowExceptions.send :remove_const, "TEMPLATE"
365
- Rack::ShowExceptions.const_set "TEMPLATE", Sinatra::ShowExceptions::TEMPLATE
@@ -1,3 +1,3 @@
1
1
  module Sinatra
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.8.1'
3
3
  end
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://www.sinatrarb.com/"
8
+ s.homepage = "http://sinatrarb.com/"
9
9
  s.license = 'MIT'
10
10
  s.files = Dir['README*.md', 'lib/**/*', 'examples/*'] + [
11
11
  ".yardopts",
@@ -17,11 +17,35 @@ Gem::Specification.new 'sinatra', version do |s|
17
17
  "MAINTENANCE.md",
18
18
  "Rakefile",
19
19
  "SECURITY.md",
20
- "sinatra.gemspec"]
20
+ "sinatra.gemspec",
21
+ "VERSION"]
21
22
  s.test_files = s.files.select { |p| p =~ /^test\/.*_test.rb/ }
22
23
  s.extra_rdoc_files = s.files.select { |p| p =~ /^README/ } << 'LICENSE'
23
24
  s.rdoc_options = %w[--line-numbers --inline-source --title Sinatra --main README.rdoc --encoding=UTF-8]
24
25
 
26
+ if s.respond_to?(:metadata)
27
+ s.metadata = {
28
+ 'source_code_uri' => 'https://github.com/sinatra/sinatra',
29
+ 'changelog_uri' => 'https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md',
30
+ 'homepage_uri' => 'http://sinatrarb.com/',
31
+ 'bug_tracker_uri' => 'https://github.com/sinatra/sinatra/issues',
32
+ 'mailing_list_uri' => 'http://groups.google.com/group/sinatrarb',
33
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/sinatra'
34
+ }
35
+ else
36
+ msg = "RubyGems 2.0 or newer is required to protect against public "\
37
+ "gem pushes. You can update your rubygems version by running:\n\n"\
38
+ "gem install rubygems-update\n"\
39
+ "update_rubygems\n"\
40
+ "gem update --system"
41
+ raise <<-EOF
42
+ RubyGems 2.0 or newer is required to protect against public gem pushes. You can update your rubygems version by running:
43
+ gem install rubygems-update
44
+ update_rubygems:
45
+ gem update --system
46
+ EOF
47
+ end
48
+
25
49
  s.required_ruby_version = '>= 2.2.0'
26
50
 
27
51
  s.add_dependency 'rack', '~> 2.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.0
4
+ version: 2.0.8.1
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: 2017-05-07 00:00:00.000000000 Z
14
+ date: 2020-01-01 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
@@ -47,14 +47,14 @@ dependencies:
47
47
  requirements:
48
48
  - - '='
49
49
  - !ruby/object:Gem::Version
50
- version: 2.0.0
50
+ version: 2.0.8.1
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.0
57
+ version: 2.0.8.1
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mustermann
60
60
  requirement: !ruby/object:Gem::Requirement
@@ -81,6 +81,7 @@ extra_rdoc_files:
81
81
  - README.hu.md
82
82
  - README.ja.md
83
83
  - README.ko.md
84
+ - README.malayalam.md
84
85
  - README.md
85
86
  - README.pt-br.md
86
87
  - README.pt-pt.md
@@ -101,6 +102,7 @@ files:
101
102
  - README.hu.md
102
103
  - README.ja.md
103
104
  - README.ko.md
105
+ - README.malayalam.md
104
106
  - README.md
105
107
  - README.pt-br.md
106
108
  - README.pt-pt.md
@@ -108,6 +110,7 @@ files:
108
110
  - README.zh.md
109
111
  - Rakefile
110
112
  - SECURITY.md
113
+ - VERSION
111
114
  - examples/chat.rb
112
115
  - examples/simple.rb
113
116
  - examples/stream.ru
@@ -120,10 +123,16 @@ files:
120
123
  - lib/sinatra/show_exceptions.rb
121
124
  - lib/sinatra/version.rb
122
125
  - sinatra.gemspec
123
- homepage: http://www.sinatrarb.com/
126
+ homepage: http://sinatrarb.com/
124
127
  licenses:
125
128
  - MIT
126
- metadata: {}
129
+ metadata:
130
+ source_code_uri: https://github.com/sinatra/sinatra
131
+ changelog_uri: https://github.com/sinatra/sinatra/blob/master/CHANGELOG.md
132
+ homepage_uri: http://sinatrarb.com/
133
+ bug_tracker_uri: https://github.com/sinatra/sinatra/issues
134
+ mailing_list_uri: http://groups.google.com/group/sinatrarb
135
+ documentation_uri: https://www.rubydoc.info/gems/sinatra
127
136
  post_install_message:
128
137
  rdoc_options:
129
138
  - "--line-numbers"
@@ -147,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
156
  version: '0'
148
157
  requirements: []
149
158
  rubyforge_project:
150
- rubygems_version: 2.6.11
159
+ rubygems_version: 2.7.3
151
160
  signing_key:
152
161
  specification_version: 4
153
162
  summary: Classy web-development dressed in a DSL