diff options
author | Sebastian Staudt <koraktor@gmail.com> | 2012-02-13 00:16:13 +0100 |
---|---|---|
committer | Sebastian Staudt <koraktor@gmail.com> | 2012-02-13 00:17:40 +0100 |
commit | daf5d4aa41f979089e704228d15031579849bfc7 (patch) | |
tree | 8f70c66027cb06b38055f669eb440bbf378dd8e7 /lib/bundler/dsl.rb | |
parent | aa7c47c767e49e8b6eaba4a1629498d6fce36ef0 (diff) | |
download | bundler-daf5d4aa41f979089e704228d15031579849bfc7.tar.gz |
Improved error formatting for missing DSL methods
Diffstat (limited to 'lib/bundler/dsl.rb')
-rw-r--r-- | lib/bundler/dsl.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 2824452b74..47e141022f 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -156,12 +156,13 @@ module Bundler def method_missing(name, *args) call = caller[0].split ':' - line = call[1] - content = Bundler.read_file(call[0]).lines.to_a[line.to_i - 1] + line = call[1].to_i + lines = ([0, line - 3].max)..line + 2 + content = Bundler.read_file(call[0]).lines.to_a[lines].join(' ').strip raise GemfileError, "The Gemfile doesn't support the method `#{name}`.\n" \ "Please check your Gemfile's syntax at line #{line}:\n\n" \ - " #{content}" + " #{content}\n" end # Deprecated methods |