bunyan 0.2.1 → 0.2.2

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 CHANGED
@@ -1,3 +1,8 @@
1
+ Version 0.2.2
2
+ =============
3
+ * No longer pass messages to the collection if a Mongo connection could not be established
4
+ * Bunyan now uses the new bson_ext c extension, per version 0.20.0 of the ruby driver
5
+
1
6
  Version 0.2.1
2
7
  =============
3
8
  * Bunyan now fails silently when a connection error occurs
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
- gem 'mongo', '>= 0.19'
2
- gem 'mongo_ext', '>= 0.19'
1
+ gem 'bson_ext', '>= 0.20.1'
2
+ gem 'mongo', '>= 0.20'
3
3
 
4
4
  group :test do
5
5
  gem 'rspec', '>= 1.3.0'
data/README.md CHANGED
@@ -56,7 +56,8 @@ More
56
56
 
57
57
  TODO
58
58
  ====
59
- * Fail silently if no mongo server running
59
+ * <del>Fail silently if no mongo server running</del>
60
60
  * Ability to limit bunyan to only run in certain environments
61
61
  * Add middleware client for easy drop-in to rails/rack apps
62
+ * Add ability to connect to a remote mongo server
62
63
  * <del>Ability to configure size of capped collection</del>
data/Rakefile CHANGED
@@ -7,8 +7,8 @@ begin
7
7
  gemspec.email = "ajsharp@gmail.com"
8
8
  gemspec.homepage = "http://github.com/ajsharp/bunyan"
9
9
  gemspec.authors = ["Alex Sharp"]
10
- gemspec.add_dependency 'mongo', '>= 0.19'
11
- gemspec.add_dependency 'mongo_ext', '>= 0.19'
10
+ gemspec.add_dependency 'mongo', '>= 0.20.1'
11
+ gemspec.add_dependency 'bson_ext', '>= 0.20.1'
12
12
  end
13
13
  Jeweler::GemcutterTasks.new
14
14
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
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.1"
8
+ s.version = "0.2.2"
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-04-06}
12
+ s.date = %q{2010-04-10}
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 = [
@@ -48,15 +48,15 @@ Gem::Specification.new do |s|
48
48
  s.specification_version = 3
49
49
 
50
50
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
- s.add_runtime_dependency(%q<mongo>, [">= 0.19"])
52
- s.add_runtime_dependency(%q<mongo_ext>, [">= 0.19"])
51
+ s.add_runtime_dependency(%q<mongo>, [">= 0.20.1"])
52
+ s.add_runtime_dependency(%q<bson_ext>, [">= 0.20.1"])
53
53
  else
54
- s.add_dependency(%q<mongo>, [">= 0.19"])
55
- s.add_dependency(%q<mongo_ext>, [">= 0.19"])
54
+ s.add_dependency(%q<mongo>, [">= 0.20.1"])
55
+ s.add_dependency(%q<bson_ext>, [">= 0.20.1"])
56
56
  end
57
57
  else
58
- s.add_dependency(%q<mongo>, [">= 0.19"])
59
- s.add_dependency(%q<mongo_ext>, [">= 0.19"])
58
+ s.add_dependency(%q<mongo>, [">= 0.20.1"])
59
+ s.add_dependency(%q<bson_ext>, [">= 0.20.1"])
60
60
  end
61
61
  end
62
62
 
data/lib/bunyan.rb CHANGED
@@ -38,7 +38,8 @@ module Bunyan
38
38
  end
39
39
 
40
40
  def disabled?
41
- !!config.disabled
41
+ # @TODO: Refactor this. Yuck.
42
+ config.nil? || (!config.nil? && config.disabled?)
42
43
  end
43
44
 
44
45
  def method_missing(method, *args, &block)
@@ -61,7 +62,9 @@ module Bunyan
61
62
  @connection = @db.connection
62
63
  @collection = retrieve_or_initialize_collection(config.collection)
63
64
  rescue Mongo::ConnectionFailure => ex
64
- @disabled = true
65
+ # @TODO: I don't like how I'm overloading @config.disabled
66
+ # for user disabling and error disabling
67
+ @config.disabled = true
65
68
  $stderr.puts 'An error occured trying to connect to MongoDB!'
66
69
  end
67
70
  end
data/lib/bunyan/config.rb CHANGED
@@ -35,6 +35,10 @@ module Bunyan
35
35
  end
36
36
  alias_method :disabled=, :disabled
37
37
 
38
+ def disabled?
39
+ !!@disabled
40
+ end
41
+
38
42
  # default size is 50 megabytes
39
43
  def size(new_size = nil)
40
44
  new_size.nil? ? @size : @size = new_size
data/spec/bunyan_spec.rb CHANGED
@@ -46,7 +46,7 @@ describe 'when a mongod instance is not running' do
46
46
  c.database 'doesnt_matter'
47
47
  c.collection 'b/c mongod isnt running'
48
48
  end
49
- Bunyan::Logger.instance.instance_variable_get(:@disabled).should == true
49
+ Bunyan::Logger.should be_disabled
50
50
  end
51
51
  end
52
52
 
@@ -138,11 +138,12 @@ describe 'when bunyan is disabled' do
138
138
  end
139
139
  end
140
140
 
141
+ # @NOTE: Some of these tests rely on other tests not modifying the mongo
142
+ # config object. This is not good, though much harder to achieve per-example
143
+ # independence when testing a singleton object.
141
144
  describe 'when bunyan is not configured' do
142
145
  it 'should not try to send messages to mongo' do
143
- Bunyan::Logger.instance.stub!(:configured?).and_return(false)
144
- Bunyan::Logger.should_not be_configured
145
- Bunyan::Logger.should_not be_disabled
146
+ Bunyan::Logger.instance.stub!(:config).and_return(nil)
146
147
  %w(insert count find).each do |command|
147
148
  Bunyan::Logger.collection.should_not_receive(command)
148
149
  Bunyan::Logger.send command
@@ -150,3 +151,4 @@ describe 'when bunyan is not configured' do
150
151
  end
151
152
  end
152
153
 
154
+
data/spec/config_spec.rb CHANGED
@@ -96,3 +96,23 @@ describe 'bunyan logger configuration' do
96
96
  end
97
97
  end
98
98
 
99
+ describe Bunyan::Logger::Config, "#disabled?" do
100
+ before :each do
101
+ @config = Bunyan::Logger::Config.new
102
+ end
103
+
104
+ it 'should be false if @disabled is nil' do
105
+ @config.disabled = nil
106
+ @config.should_not be_disabled
107
+ end
108
+
109
+ it 'should be true if @disabled is true' do
110
+ @config.disabled = true
111
+ @config.should be_disabled
112
+ end
113
+
114
+ it 'should be false if @isabled is false' do
115
+ @config.disabled = false
116
+ @config.should_not be_disabled
117
+ end
118
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
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-04-06 00:00:00 -07:00
17
+ date: 2010-04-10 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,13 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  segments:
28
28
  - 0
29
- - 19
30
- version: "0.19"
29
+ - 20
30
+ - 1
31
+ version: 0.20.1
31
32
  type: :runtime
32
33
  version_requirements: *id001
33
34
  - !ruby/object:Gem::Dependency
34
- name: mongo_ext
35
+ name: bson_ext
35
36
  prerelease: false
36
37
  requirement: &id002 !ruby/object:Gem::Requirement
37
38
  requirements:
@@ -39,8 +40,9 @@ dependencies:
39
40
  - !ruby/object:Gem::Version
40
41
  segments:
41
42
  - 0
42
- - 19
43
- version: "0.19"
43
+ - 20
44
+ - 1
45
+ version: 0.20.1
44
46
  type: :runtime
45
47
  version_requirements: *id002
46
48
  description: Bunyan is a thin ruby wrapper around a MongoDB capped collection, created with high-performance, flexible logging in mind.