Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Set __LINE__ correctly for rackup files. #397

Merged
merged 1 commit into from

3 participants

@ConradIrwin

Before this change the line numbers were off by one, which broke
debugging tools like Pry in addition to causing a smidgen of user
confusion.

Reported-At: pry/pry#571

@ConradIrwin ConradIrwin Set __LINE__ correctly for rackup files.
Before this change the line numbers were off by one, which broke
debugging tools like Pry in addition to causing a smidgen of user
confusion.

Reported-At: pry/pry#571
2fbf04b
@travisbot

This pull request fails (merged 2fbf04b into edc8b92).

@raggi raggi merged commit 279e6d2 into rack:master
@raggi
Owner

Thank you.

@ghost Unknown commented on the diff
test/spec_builder.rb
@@ -197,5 +197,11 @@ def config_file(name)
Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK'
$:.pop
end
+
+ it "sets __LINE__ correctly" do
+ app, options = Rack::Builder.parse_file config_file('line.ru')
@ghost
ghost added a note

Why not app, _ = … ? You can avoid any warnings that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 4, 2012
  1. @ConradIrwin

    Set __LINE__ correctly for rackup files.

    ConradIrwin authored
    Before this change the line numbers were off by one, which broke
    debugging tools like Pry in addition to causing a smidgen of user
    confusion.
    
    Reported-At: pry/pry#571
This page is out of date. Refresh to see the latest.
View
2  lib/rack/builder.rb
@@ -38,7 +38,7 @@ def self.parse_file(config, opts = Server::Options.new)
end
cfgfile.sub!(/^__END__\n.*\Z/m, '')
app = eval "Rack::Builder.new {\n" + cfgfile + "\n}.to_app",
- TOPLEVEL_BINDING, config
+ TOPLEVEL_BINDING, config, 0
else
require config
app = Object.const_get(::File.basename(config, '.rb').capitalize)
View
1  test/builder/line.ru
@@ -0,0 +1 @@
+run lambda{ |env| [200, {'Content-Type' => 'text/plain'}, [__LINE__.to_s]] }
View
6 test/spec_builder.rb
@@ -197,5 +197,11 @@ def config_file(name)
Rack::MockRequest.new(app).get("/").body.to_s.should.equal 'OK'
$:.pop
end
+
+ it "sets __LINE__ correctly" do
+ app, options = Rack::Builder.parse_file config_file('line.ru')
@ghost
ghost added a note

Why not app, _ = … ? You can avoid any warnings that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ options = nil # ignored, prevents warning
+ Rack::MockRequest.new(app).get("/").body.to_s.should.equal '1'
+ end
end
end
Something went wrong with that request. Please try again.