lumber 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 0.9.2
2
+ -----
3
+
4
+ custom task <a280ac8> [Matt Conway]
5
+ handle logger delegation, a.l.a. ActionView->ActionController <54aa99a> [Matt Conway]
6
+ extra test <0504aa9> [Matt Conway]
7
+ use canonical gem <1e6d3f9> [Matt Conway]
8
+
1
9
  0.9.1
2
10
  -----
3
11
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.1
1
+ 0.9.2
data/lib/lumber/lumber.rb CHANGED
@@ -139,7 +139,7 @@ module Lumber
139
139
  # logger of the new class
140
140
  parent = clazz.superclass
141
141
  while ! parent.nil?
142
- if defined?(parent.logger) && parent.logger
142
+ if parent.method_defined?(:logger) && parent.method_defined?(:logger=) && parent.logger
143
143
  parent_is_registered = @@registered_loggers.values.find {|v| parent.logger.fullname.index(v) == 0}
144
144
  if parent_is_registered
145
145
  clazz.logger = Log4r::Logger.new("#{parent.logger.fullname}::#{clazz.name}")
data/test/lumber_test.rb CHANGED
@@ -48,6 +48,30 @@ class LumberTest < Test::Unit::TestCase
48
48
  assert_valid_logger('Foo1', "root::foo1")
49
49
  end
50
50
 
51
+ should "not register new logger for subclasses of classes that delegate logger" do
52
+ assert !defined?(Foo1) # ActionController::Base
53
+ assert !defined?(Foo2) # ActionView::Base
54
+ assert !defined?(Foo3) # Subclass of ActionView::Base
55
+ Lumber.setup_logger_hierarchy("Foo1", "root::foo1")
56
+ eval "class ::Foo1; end"
57
+ eval "class ::Foo2; delegate :logger, :to => Foo1; end"
58
+ eval "class ::Foo3 < Foo2; end"
59
+ assert_valid_logger('Foo1', "root::foo1")
60
+ assert Foo2.new.logger == Foo1.logger
61
+ assert Foo3.new.logger == Foo1.logger
62
+ end
63
+
64
+ should "allow registering independent loggers for classes in a hierarchy" do
65
+ assert !defined?(Foo1)
66
+ assert !defined?(Foo2)
67
+ Lumber.setup_logger_hierarchy("Foo1", "root::foo1")
68
+ Lumber.setup_logger_hierarchy("Foo2", "root::foo2")
69
+ new_class('Foo1')
70
+ new_class('Foo2', 'Foo1')
71
+ assert_valid_logger('Foo1', "root::foo1")
72
+ assert_valid_logger('Foo2', "root::foo2")
73
+ end
74
+
51
75
  should "prevent cattr_accessor for a class registered before the class is defined" do
52
76
  assert !defined?(Foo1)
53
77
  Lumber.setup_logger_hierarchy("Foo1", "root::foo1")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Conway
@@ -13,7 +13,7 @@ date: 2009-10-16 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: thoughtbot-shoulda
16
+ name: shoulda
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement