bunyan 0.2.0 → 0.2.1
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.
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/VERSION +1 -1
- data/bunyan.gemspec +2 -3
- data/lib/bunyan.rb +9 -4
- data/spec/bunyan_spec.rb +26 -2
- data/spec/spec_helper.rb +0 -8
- metadata +3 -4
- data/spec/integration/non_rails_spec.rb +0 -14
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/bunyan.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bunyan}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Alex Sharp"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-04-06}
|
13
13
|
s.description = %q{Bunyan is a thin ruby wrapper around a MongoDB capped collection, created with high-performance, flexible logging in mind.}
|
14
14
|
s.email = %q{ajsharp@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -39,7 +39,6 @@ Gem::Specification.new do |s|
|
|
39
39
|
s.test_files = [
|
40
40
|
"spec/bunyan_spec.rb",
|
41
41
|
"spec/config_spec.rb",
|
42
|
-
"spec/integration/non_rails_spec.rb",
|
43
42
|
"spec/spec_helper.rb",
|
44
43
|
"examples/rails.rb"
|
45
44
|
]
|
data/lib/bunyan.rb
CHANGED
@@ -56,13 +56,18 @@ module Bunyan
|
|
56
56
|
|
57
57
|
private
|
58
58
|
def initialize_connection
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
begin
|
60
|
+
@db = Mongo::Connection.new.db(config.database)
|
61
|
+
@connection = @db.connection
|
62
|
+
@collection = retrieve_or_initialize_collection(config.collection)
|
63
|
+
rescue Mongo::ConnectionFailure => ex
|
64
|
+
@disabled = true
|
65
|
+
$stderr.puts 'An error occured trying to connect to MongoDB!'
|
66
|
+
end
|
62
67
|
end
|
63
68
|
|
64
69
|
def database_is_usable?
|
65
|
-
|
70
|
+
configured? && !disabled?
|
66
71
|
end
|
67
72
|
|
68
73
|
def ensure_required_options_exist
|
data/spec/bunyan_spec.rb
CHANGED
@@ -2,9 +2,9 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Bunyan::Logger do
|
4
4
|
before do
|
5
|
+
Mongo::Connection.unstub!(:new)
|
5
6
|
@logger = Bunyan::Logger.instance
|
6
7
|
@mock_database = nil
|
7
|
-
Mongo::Connection.unstub!(:new)
|
8
8
|
end
|
9
9
|
|
10
10
|
it 'should have a connection' do
|
@@ -13,11 +13,12 @@ describe Bunyan::Logger do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should have a reference to the mongo db object' do
|
16
|
+
configure_test_db
|
16
17
|
@logger.db.should be_instance_of Mongo::DB
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'should have a config hash' do
|
20
|
-
|
21
|
+
Bunyan::Logger.config.should respond_to :[]
|
21
22
|
end
|
22
23
|
|
23
24
|
|
@@ -26,6 +27,29 @@ describe Bunyan::Logger do
|
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
30
|
+
describe 'when a mongod instance is not running' do
|
31
|
+
before do
|
32
|
+
Mongo::Connection.stub!(:new).and_raise(Mongo::ConnectionFailure)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should not blow up' do
|
36
|
+
lambda {
|
37
|
+
Bunyan::Logger.configure do |c|
|
38
|
+
c.database 'doesnt_matter'
|
39
|
+
c.collection 'b/c mongod isnt running'
|
40
|
+
end
|
41
|
+
}.should_not raise_exception(Mongo::ConnectionFailure)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should mark bunyan as disabled' do
|
45
|
+
Bunyan::Logger.configure do |c|
|
46
|
+
c.database 'doesnt_matter'
|
47
|
+
c.collection 'b/c mongod isnt running'
|
48
|
+
end
|
49
|
+
Bunyan::Logger.instance.instance_variable_get(:@disabled).should == true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
29
53
|
describe 'when initializing the collection' do
|
30
54
|
before do
|
31
55
|
@conn = mock_mongo_connection
|
data/spec/spec_helper.rb
CHANGED
@@ -8,10 +8,6 @@ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
|
|
8
8
|
|
9
9
|
Spec::Runner.configure do |config|
|
10
10
|
|
11
|
-
config.after :each do
|
12
|
-
cleanup_bunyan_config
|
13
|
-
end
|
14
|
-
|
15
11
|
config.before :each do
|
16
12
|
mock_mongo_connection
|
17
13
|
end
|
@@ -29,10 +25,6 @@ Spec::Runner.configure do |config|
|
|
29
25
|
@mock_database
|
30
26
|
end
|
31
27
|
|
32
|
-
def cleanup_bunyan_config
|
33
|
-
Bunyan::Logger.instance_variable_set(:@config, Bunyan::Logger::Config.new)
|
34
|
-
end
|
35
|
-
|
36
28
|
def configure_test_db
|
37
29
|
Bunyan::Logger.configure do |config|
|
38
30
|
config.database 'bunyan_test'
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alex Sharp
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-06 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -99,6 +99,5 @@ summary: A MongoDB-based logging solution.
|
|
99
99
|
test_files:
|
100
100
|
- spec/bunyan_spec.rb
|
101
101
|
- spec/config_spec.rb
|
102
|
-
- spec/integration/non_rails_spec.rb
|
103
102
|
- spec/spec_helper.rb
|
104
103
|
- examples/rails.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# $LOAD_PATH.unshift(File.expand_path(File.dirname('../../lib/bunyan'))
|
2
|
-
#
|
3
|
-
# require 'bunyan'
|
4
|
-
#
|
5
|
-
# Bunyan::Logger.configure do |c|
|
6
|
-
# c.database 'bunyan_integration_db'
|
7
|
-
# c.collection 'test_log'
|
8
|
-
#
|
9
|
-
# c.size 104857600 # 100.megabytes
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# describe
|
13
|
-
#
|
14
|
-
# Bunyan::Logger.insert({ })
|