web-console 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cccaecbc9077b0e460d946cc12b7a740c1832885
4
- data.tar.gz: a554f379e1a93e39794530da43da5964da36a074
3
+ metadata.gz: bf5732bddc2528664e5567694ec06c4c4a6c0fab
4
+ data.tar.gz: 302c11d030141cde9b568ff1a5c50f6f3cdbead9
5
5
  SHA512:
6
- metadata.gz: 552ed1aca142857e5bb4d6e21b50c151348b9538018ed4464cf3c0b00d016272db4758cfbd0d96ee2c603f998536e8ab8f71e9a345f2d423d1fd2cbdebbd3335
7
- data.tar.gz: 81df2259f8350875c61108d8edb3a274d4a169e91dd67a874d5b4dd32c2629fe17b7aaa1135fcd65c54b5316892aa83b61cab272c9df004986bfdfd53cd53ad7
6
+ metadata.gz: cd24a5c51ea68a52e01adb457a16a716b5b3d608f9e817f1bc8c0123ed688029f54363cebcca80eafe2d11e300cae467880d3536e89d21ca088e8513b78b95f0
7
+ data.tar.gz: 36b4e435412d84bbea06f5a3cda46a90a3cb440a0e6eb2f603649042be804d2760fa043e3ab319b3a060b12a46f83d064e10d7263eeea9cdc3ab58d9f9d4719c
@@ -26,7 +26,7 @@ application, add the following to your `Gemfile`.
26
26
 
27
27
  ```ruby
28
28
  group :development do
29
- gem 'web-console', '~> 3.0'
29
+ gem 'web-console'
30
30
  end
31
31
  ```
32
32
 
@@ -7,6 +7,7 @@ module WebConsole
7
7
 
8
8
  autoload :View
9
9
  autoload :Evaluator
10
+ autoload :ExceptionMapper
10
11
  autoload :Session
11
12
  autoload :Response
12
13
  autoload :Request
@@ -0,0 +1,33 @@
1
+ module WebConsole
2
+ class ExceptionMapper
3
+ def initialize(exception)
4
+ @backtrace = exception.backtrace
5
+ @bindings = exception.bindings
6
+ end
7
+
8
+ def first
9
+ guess_the_first_application_binding || @bindings.first
10
+ end
11
+
12
+ def [](index)
13
+ guess_binding_for_index(index) || @bindings[index]
14
+ end
15
+
16
+ private
17
+
18
+ def guess_binding_for_index(index)
19
+ file, line = @backtrace[index].to_s.split(':')
20
+ line = line.to_i
21
+
22
+ @bindings.find do |binding|
23
+ binding.eval('__FILE__') == file && binding.eval('__LINE__') == line
24
+ end
25
+ end
26
+
27
+ def guess_the_first_application_binding
28
+ @bindings.find do |binding|
29
+ binding.eval('__FILE__').to_s.start_with?(Rails.root.to_s)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -30,9 +30,9 @@ module WebConsole
30
30
  # storage.
31
31
  def from(storage)
32
32
  if exc = storage[:__web_console_exception]
33
- new(exc.bindings)
33
+ new(ExceptionMapper.new(exc))
34
34
  elsif binding = storage[:__web_console_binding]
35
- new(binding)
35
+ new([binding])
36
36
  end
37
37
  end
38
38
  end
@@ -42,8 +42,8 @@ module WebConsole
42
42
 
43
43
  def initialize(bindings)
44
44
  @id = SecureRandom.hex(16)
45
- @bindings = Array(bindings)
46
- @evaluator = Evaluator.new(application_binding || @bindings.first)
45
+ @bindings = bindings
46
+ @evaluator = Evaluator.new(bindings.first)
47
47
 
48
48
  store_into_memory
49
49
  end
@@ -64,10 +64,6 @@ module WebConsole
64
64
 
65
65
  private
66
66
 
67
- def application_binding
68
- @bindings.find { |b| b.eval('__FILE__').to_s.start_with?(Rails.root.to_s) }
69
- end
70
-
71
67
  def store_into_memory
72
68
  inmemory_storage[id] = self
73
69
  end
@@ -1,3 +1,3 @@
1
1
  module WebConsole
2
- VERSION = '3.2.1'
2
+ VERSION = '3.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web-console
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Somerville
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-06-14 00:00:00.000000000 Z
14
+ date: 2016-06-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: railties
@@ -73,12 +73,12 @@ files:
73
73
  - lib/web_console.rb
74
74
  - lib/web_console/errors.rb
75
75
  - lib/web_console/evaluator.rb
76
+ - lib/web_console/exception_mapper.rb
76
77
  - lib/web_console/extensions.rb
77
78
  - lib/web_console/integration.rb
78
79
  - lib/web_console/integration/cruby.rb
79
80
  - lib/web_console/integration/rubinius.rb
80
81
  - lib/web_console/locales/en.yml
81
- - lib/web_console/mapper.rb
82
82
  - lib/web_console/middleware.rb
83
83
  - lib/web_console/railtie.rb
84
84
  - lib/web_console/request.rb
@@ -1,14 +0,0 @@
1
- module WebConsole
2
- class Mapper
3
- def initialize(exception)
4
- @exception = exception
5
- @bindings = exception.bindings
6
- end
7
-
8
- def [](index)
9
- trace = @exception.backtrace[index]
10
- file, line = trace.to_s.strip(':')
11
- @bindings.find { |b| b.eval('__FILE__') == file && b.eval('__LINE__') == line }
12
- end
13
- end
14
- end