exception_manager 1.0.0 → 1.0.1

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: eb305107f1c6f84dd05546de27dbfe8981d0abf7
4
- data.tar.gz: 532f25870f02b30b67307f43edcff07951ae9b08
3
+ metadata.gz: a2b7bd30e1110138537b3d70ee54266961f104a1
4
+ data.tar.gz: 07e922005c2cc946ee42659ba04e62c0d337d601
5
5
  SHA512:
6
- metadata.gz: e397bf900e4f40e762ecc2d37465b3415bc51ae15d6d22423285529ab0b832599bc4357a295d7d495f6ebef22c4278b99b56b95c0d699d9e8a4828ef6adf2794
7
- data.tar.gz: ccf737eb0b0bf15288bd19ec90bbecd15eaf7e9fe3fa8685577df191e87a4545d75b48f0aea46da49768ace6dae303c27fe52c016fe66bdca99713937ca9fced
6
+ metadata.gz: 93a042dffe11b970638082809d42b1e988a77afa8a9db563616dc09c5da3730020d5eded8ffca591c167a551dfa8077ea0996fedbeab5da2adf9e099919c92b3
7
+ data.tar.gz: e305069cddbef11b3a40246cb471b646b1e63d9141fa7ce5787cad91c532951d330927c85c77f978eb9031352831b4cac11e9d4682399035bacdee91442584b3
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.0
4
+ - 2.1.0
5
+ - 2.0.0
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ [![Build Status](https://travis-ci.org/iliabylich/exception_manager.svg?branch=master)](https://travis-ci.org/iliabylich/exception_manager)
2
+ [![Code Climate](https://codeclimate.com/github/iliabylich/exception_manager/badges/gpa.svg)](https://codeclimate.com/github/iliabylich/exception_manager)
3
+
1
4
  # ExceptionManager
2
5
 
3
6
  Gem for better exception recording.
@@ -10,6 +10,8 @@ module ExceptionManager
10
10
  autoload :SubjectInstanceVariables, 'exception_manager/methods/subject_instance_variables'
11
11
  autoload :SubjectClassVariables, 'exception_manager/methods/subject_class_variables'
12
12
  end
13
+
14
+ DisabledError = Class.new(StandardError)
13
15
  end
14
16
 
15
17
  require 'exception_manager/patch'
@@ -47,4 +47,8 @@ module ExceptionManager::Config
47
47
  @logger = Logger.new(STDOUT)
48
48
  end
49
49
  attr_writer :logger
50
+
51
+ def required!
52
+ raise ExceptionManager::DisabledError if disabled?
53
+ end
50
54
  end
@@ -1,5 +1,6 @@
1
1
  class ExceptionManager::Methods::Locals
2
2
  def self.run(exception_binding)
3
+ ExceptionManager.required!
3
4
  exception_binding.eval %q{
4
5
  local_variables.inject({}) do |hash, local_variable_name|
5
6
  hash[local_variable_name] = eval(local_variable_name.to_s)
@@ -1,5 +1,6 @@
1
1
  class ExceptionManager::Methods::Subject
2
2
  def self.run(exception_binding)
3
+ ExceptionManager.required!
3
4
  exception_binding.eval('self')
4
5
  end
5
6
  end
@@ -1,5 +1,6 @@
1
1
  class ExceptionManager::Methods::SubjectClassVariables
2
2
  def self.run(exception_binding)
3
+ ExceptionManager.required!
3
4
  exception_binding.eval %q{
4
5
  klass = is_a?(Class) ? self : self.class
5
6
  klass.class_variables.inject({}) do |hash, class_variable_name|
@@ -1,5 +1,6 @@
1
1
  class ExceptionManager::Methods::SubjectInstanceVariables
2
2
  def self.run(exception_binding)
3
+ ExceptionManager.required!
3
4
  exception_binding.eval %q{
4
5
  instance_variables.inject({}) do |hash, instance_variable_name|
5
6
  hash[instance_variable_name] = instance_variable_get(instance_variable_name)
@@ -2,7 +2,7 @@ module ExceptionManager
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 0
5
+ PATCH = 1
6
6
  STRING = [MAJOR, MINOR, PATCH].join('.')
7
7
  end
8
8
  end
@@ -15,6 +15,16 @@ describe ExceptionManager do
15
15
  end
16
16
  end
17
17
 
18
+ shared_examples 'requires ExceptionManager to be enabled' do |method_name|
19
+ context 'when ExceptionManager is disabled' do
20
+ before { ExceptionManager.disable! }
21
+
22
+ it 'raises error' do
23
+ expect { error.locals }.to raise_error(ExceptionManager::DisabledError)
24
+ end
25
+ end
26
+ end
27
+
18
28
  describe 'Exception#locals' do
19
29
  let(:expected) do
20
30
  {
@@ -26,12 +36,16 @@ describe ExceptionManager do
26
36
  it 'returns Hash of local variables available when #raise happened' do
27
37
  expect(error.locals).to eq(expected)
28
38
  end
39
+
40
+ include_examples 'requires ExceptionManager to be enabled', :locals
29
41
  end
30
42
 
31
43
  describe 'Exception#subject' do
32
44
  it 'returns context of place when subject was raised' do
33
45
  expect(error.subject).to be_a(Letter)
34
46
  end
47
+
48
+ include_examples 'requires ExceptionManager to be enabled', :locals
35
49
  end
36
50
 
37
51
  describe 'Exception#subject_instance_variables' do
@@ -45,6 +59,8 @@ describe ExceptionManager do
45
59
  it 'returns instance variables of #subject when #raise happened' do
46
60
  expect(error.subject_instance_variables).to eq(expected)
47
61
  end
62
+
63
+ include_examples 'requires ExceptionManager to be enabled', :locals
48
64
  end
49
65
 
50
66
  describe 'Exception#subject_class_variables' do
@@ -57,6 +73,8 @@ describe ExceptionManager do
57
73
  it 'returns class variables of #subject when #raise happened' do
58
74
  expect(error.subject_class_variables).to eq(expected)
59
75
  end
76
+
77
+ include_examples 'requires ExceptionManager to be enabled', :locals
60
78
  end
61
79
 
62
80
  describe 'Exception#summary' do
@@ -77,5 +95,7 @@ describe ExceptionManager do
77
95
  expect(error.summary[:subject_instance_variables]).to be_a(Hash)
78
96
  expect(error.summary[:subject_class_variables]).to be_a(Hash)
79
97
  end
98
+
99
+ include_examples 'requires ExceptionManager to be enabled', :locals
80
100
  end
81
101
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bylich
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - .gitignore
77
77
  - .rspec
78
+ - .travis.yml
78
79
  - Gemfile
79
80
  - LICENSE.txt
80
81
  - README.md