yogi_berra 0.0.4 → 0.0.5

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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzlmNzc4ZmM0OTY1MmZjNzc2NTM0YzA0NmM3ODM3OTU2ZDM0OGRmMw==
5
+ data.tar.gz: !binary |-
6
+ Y2E5ZmZjODVjODBlMGVjMGFjZDkzNjAzZGFjYmIzNmE2ZjdhYzI2Ng==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ Yzg3MzA1MmMwMDc2MDEyMzkxOTE1NWI2YjE2MDg5MzUzYmU1N2YxOWJmNzc3
10
+ NWVkMmY2NzI0NWU4ZWIwZTc1Y2I2NmY2YjZiNDQ3MDFkYWFjNmM2ZWVkZTMz
11
+ YjQxNTQ5NmUyMjdjYjFmZWNjMmE0NGE1OWZiOTZlNDliNjVjMmM=
12
+ data.tar.gz: !binary |-
13
+ YTczMDc2N2I1ZGFhMjEyMDcwNWYxNTgzOWRmMzAwZTJmMzM5NmU2ZDI2ZTAy
14
+ ZTE5OTdiMjA5MzRjOTIwYTUzN2NiMzg1ZDM3MDM2YTRkNjg0MTYzODRhM2Yw
15
+ YjkyZDk1NGI3NTIxNTk2M2U2MTQxNDlhOTNlODk4YmY4ZDE0ZTk=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yogi_berra (0.0.3)
4
+ yogi_berra (0.0.5)
5
5
  bson (= 1.8.3)
6
6
  mongo (= 1.8.3)
7
7
 
@@ -9,7 +9,7 @@ GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
11
  bson (1.8.3)
12
- builder (3.2.1)
12
+ builder (3.2.2)
13
13
  diff-lcs (1.2.4)
14
14
  mongo (1.8.3)
15
15
  bson (~> 1.8.3)
data/README.md CHANGED
@@ -49,7 +49,7 @@ Finally store a rescued exception:
49
49
  begin
50
50
  raise Exception
51
51
  rescue => raised
52
- YogiBerra.exceptionize(raised, environment, YogiBerra::Catcher.connection)
52
+ YogiBerra.exceptionize(raised)
53
53
  end
54
54
 
55
55
  View
@@ -3,7 +3,7 @@ module YogiBerra
3
3
  module ActionControllerCatcher
4
4
  # Sets up an alias chain to catch exceptions for Rails 2
5
5
  def self.included(base)
6
- YogiBerra::Catcher.load_db_settings
6
+ YogiBerra::Catcher.quick_connection(true)
7
7
  if base.method_defined?(:rescue_action_in_public)
8
8
  base.send(:alias_method, :rescue_action_in_public_without_yogi, :rescue_action_in_public)
9
9
  base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_yogi)
@@ -1,5 +1,6 @@
1
1
  require 'mongo'
2
2
  require 'facets'
3
+ require 'yaml'
3
4
 
4
5
  module YogiBerra
5
6
  class Catcher
@@ -38,8 +39,8 @@ module YogiBerra
38
39
  nil
39
40
  end
40
41
 
41
- def quick_connection
42
- load_db_settings unless @@settings
42
+ def quick_connection(load_settings = false)
43
+ load_db_settings if load_settings
43
44
 
44
45
  if @@settings
45
46
  host = @@settings["host"]
@@ -51,7 +52,7 @@ module YogiBerra
51
52
  YogiBerra::Logger.log("Couldn't connect to the mongo database on host: #{host} port: #{port}.", :error)
52
53
  end
53
54
  else
54
- YogiBerra::Logger.log("Couldn't load the yogi.yml file.", :error)
55
+ YogiBerra::Logger.log("Couldn't load the yogi.yml file.", :error) if load_settings
55
56
  end
56
57
  @@connection
57
58
  end
@@ -9,7 +9,7 @@ module YogiBerra
9
9
  data[:session] = parse_session(session) if session
10
10
  data.merge!(environment)
11
11
  end
12
- (YogiBerra::Catcher.connection || YogiBerra::Catcher.quick_connection)["caught_exceptions"].insert(data)
12
+ YogiBerra::Catcher.connection["caught_exceptions"].insert(data)
13
13
  end
14
14
 
15
15
  def self.parse_exception(notice)
@@ -2,7 +2,7 @@ module YogiBerra
2
2
  class ExceptionMiddleware
3
3
  def initialize(app)
4
4
  @app = app
5
- YogiBerra::Catcher.quick_connection
5
+ YogiBerra::Catcher.quick_connection(true)
6
6
  end
7
7
 
8
8
  def call(env)
@@ -1,3 +1,3 @@
1
1
  module YogiBerra
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  SPEC_FOLDER = File.dirname(__FILE__)
2
- require 'yaml'
3
2
  require 'yogi_berra'
4
3
  require 'rspec/mocks'
5
4
  # Helper methods
@@ -20,3 +19,13 @@ def build_session
20
19
  }
21
20
  end
22
21
 
22
+ def mock_mongo_client(client_should = false, connection_should = false)
23
+ mongo_client = double('mongo client')
24
+ mongo_connection = double('mongo connection')
25
+ Mongo::MongoClient.should_receive(:new) { mongo_client }
26
+ mongo_client.should_receive(:[]) { mongo_connection } if client_should
27
+ if connection_should
28
+ mongo_connection.should_receive(:[]) { mongo_connection }
29
+ mongo_connection.should_receive(:insert)
30
+ end
31
+ end
@@ -25,6 +25,7 @@ describe YogiBerra do
25
25
  end
26
26
 
27
27
  it "should grab a connection using the settings file" do
28
+ mock_mongo_client(true)
28
29
  connection = nil
29
30
  YogiBerra::Catcher.load_db_settings(@test_yaml)
30
31
  connection = YogiBerra::Catcher.quick_connection
@@ -32,6 +33,7 @@ describe YogiBerra do
32
33
  end
33
34
 
34
35
  it "should grab a connection to mongodb" do
36
+ mock_mongo_client
35
37
  yaml = nil
36
38
  yaml = YogiBerra::Catcher.load_db_settings(@test_yaml)
37
39
  db_client = YogiBerra::Catcher.db_client(YogiBerra::Catcher.settings["host"], YogiBerra::Catcher.settings["port"])
@@ -3,17 +3,13 @@ require 'spec_helper'
3
3
  describe YogiBerra do
4
4
  before(:each) do
5
5
  YogiBerra::Logger.stub(:log)
6
+ YogiBerra::Catcher.load_db_settings("#{SPEC_FOLDER}/fixtures/test.yml")
6
7
  end
7
8
 
8
9
  it "should store an exception" do
9
- YogiBerra::Catcher.connection = nil
10
10
  exception = build_exception
11
- mongo_client = double('mongo client')
12
- mongo_connection = double('mongo connection')
13
- Mongo::MongoClient.should_receive(:new) { mongo_client }
14
- mongo_client.should_receive(:[]) { mongo_connection }
15
- mongo_connection.should_receive(:[]) { mongo_connection }
16
- mongo_connection.should_receive(:insert)
11
+ mock_mongo_client(true, true)
12
+ YogiBerra::Catcher.quick_connection
17
13
  YogiBerra::Data.store!(exception)
18
14
  end
19
15
 
@@ -23,7 +19,7 @@ describe YogiBerra do
23
19
  parsed_data[:error_class].should == "Exception"
24
20
  parsed_data[:project].should == "test_yogi_project"
25
21
  parsed_data[:error_message].should == "Exception"
26
- parsed_data[:backtraces].size.should == 17
22
+ parsed_data[:backtraces].size.should > 1
27
23
  end
28
24
 
29
25
  it "should parse a session" do
@@ -6,6 +6,7 @@ describe YogiBerra::ExceptionMiddleware do
6
6
  end
7
7
 
8
8
  it "should call the upstream app with the environment" do
9
+ mock_mongo_client(true)
9
10
  environment = { 'key' => 'value' }
10
11
  app = lambda { |env| ['response', {}, env] }
11
12
  stack = YogiBerra::ExceptionMiddleware.new(app)
@@ -18,6 +19,7 @@ describe YogiBerra::ExceptionMiddleware do
18
19
  end
19
20
 
20
21
  it "deliver an exception raised while calling an upstream app" do
22
+ mock_mongo_client(true, true)
21
23
  exception = build_exception
22
24
  environment = { 'key' => 'value' }
23
25
  app = lambda do |env|
@@ -33,6 +35,7 @@ describe YogiBerra::ExceptionMiddleware do
33
35
  end
34
36
 
35
37
  it "should deliver an exception in rack.exception" do
38
+ mock_mongo_client(true, true)
36
39
  exception = build_exception
37
40
  environment = { 'key' => 'value' }
38
41
 
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yogi_berra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kevin Earl Krauss
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
11
+ date: 2013-08-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - '='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - '='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - '='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - '='
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: bson
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - '='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - '='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: mongo
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - '='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - '='
76
67
  - !ruby/object:Gem::Version
@@ -109,27 +100,26 @@ files:
109
100
  - spec/yogi_berra_logger_spec.rb
110
101
  homepage: http://github.com/earlonrails/yogi_berra
111
102
  licenses: []
103
+ metadata: {}
112
104
  post_install_message:
113
105
  rdoc_options: []
114
106
  require_paths:
115
107
  - lib
116
108
  required_ruby_version: !ruby/object:Gem::Requirement
117
- none: false
118
109
  requirements:
119
110
  - - ! '>='
120
111
  - !ruby/object:Gem::Version
121
112
  version: '0'
122
113
  required_rubygems_version: !ruby/object:Gem::Requirement
123
- none: false
124
114
  requirements:
125
115
  - - ! '>='
126
116
  - !ruby/object:Gem::Version
127
117
  version: '0'
128
118
  requirements: []
129
119
  rubyforge_project:
130
- rubygems_version: 1.8.24
120
+ rubygems_version: 2.0.5
131
121
  signing_key:
132
- specification_version: 3
122
+ specification_version: 4
133
123
  summary: Catches errors in your rails app and doesn't get in the way.
134
124
  test_files:
135
125
  - spec/fixtures/config/yogi.yml