gorillib 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,6 +32,7 @@ Gem::Specification.new do |gem|
32
32
  end
33
33
 
34
34
  gem.add_development_dependency('bundler', ["~> 1.1"])
35
+ gem.add_development_dependency('log4r', ["~> 1.1.10"])
35
36
  gem.add_development_dependency('pry', [">= 0"])
36
37
  gem.add_development_dependency('rspec', [">= 2.8"])
37
38
  gem.add_development_dependency('rake', [">= 0"])
@@ -0,0 +1,20 @@
1
+ require 'log4r'
2
+
3
+ module Gorillib
4
+ module Logger
5
+ def self.included(base)
6
+ base.send :include, ClassMethods
7
+ base.extend ClassMethods
8
+ end
9
+
10
+ module ClassMethods
11
+ def log
12
+ logger_name = case self
13
+ when Module then name
14
+ else self.class.name
15
+ end
16
+ @log ||= Log4r::Logger[logger_name] || Log4r::Logger.new(logger_name)
17
+ end
18
+ end
19
+ end
20
+ end
@@ -15,8 +15,6 @@ def Log.dump *args
15
15
  ].join("\t"))
16
16
  end unless Log.respond_to?(:dump)
17
17
 
18
-
19
-
20
18
  # TODO: allow swappable loggers more cleanly
21
19
 
22
20
  # unless defined?(Log)
@@ -1,3 +1,3 @@
1
1
  module Gorillib
2
- VERSION = '0.5.2'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'gorillib/logger'
3
+
4
+ describe Gorillib::Logger, simple_spec: true do
5
+ let(:logged_class) do
6
+ module X
7
+ class Y
8
+ include Gorillib::Logger
9
+ end
10
+ end
11
+
12
+ X::Y
13
+ end
14
+ let(:expected_logger){ Log4r::Logger[logged_class.name] }
15
+
16
+ it 'returns a Log4r logger indexed by class name' do
17
+ logged_class.new.log.should eql(expected_logger)
18
+ end
19
+ it 'returns a Log4r logger indexed by name, if this is a class' do
20
+ logged_class.log.should eql(expected_logger)
21
+ end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gorillib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-04-02 00:00:00.000000000 Z
12
+ date: 2014-04-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.1'
62
+ - !ruby/object:Gem::Dependency
63
+ name: log4r
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.1.10
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.1.10
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: pry
64
80
  requirement: !ruby/object:Gem::Requirement
@@ -193,6 +209,7 @@ files:
193
209
  - lib/gorillib/hashlike/keys.rb
194
210
  - lib/gorillib/hashlike/reverse_merge.rb
195
211
  - lib/gorillib/hashlike/slice.rb
212
+ - lib/gorillib/logger.rb
196
213
  - lib/gorillib/logger/log.rb
197
214
  - lib/gorillib/metaprogramming/class_attribute.rb
198
215
  - lib/gorillib/metaprogramming/concern.rb
@@ -296,6 +313,7 @@ files:
296
313
  - spec/gorillib/hashlike/hashlike_via_accessors_spec.rb
297
314
  - spec/gorillib/hashlike_spec.rb
298
315
  - spec/gorillib/logger/log_spec.rb
316
+ - spec/gorillib/logger_spec.rb
299
317
  - spec/gorillib/metaprogramming/class_attribute_spec.rb
300
318
  - spec/gorillib/metaprogramming/delegation_spec.rb
301
319
  - spec/gorillib/metaprogramming/singleton_class_spec.rb
@@ -347,7 +365,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
347
365
  version: '0'
348
366
  segments:
349
367
  - 0
350
- hash: -2332590126612092657
368
+ hash: 1171001497887410062
351
369
  required_rubygems_version: !ruby/object:Gem::Requirement
352
370
  none: false
353
371
  requirements:
@@ -356,7 +374,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
356
374
  version: '0'
357
375
  segments:
358
376
  - 0
359
- hash: -2332590126612092657
377
+ hash: 1171001497887410062
360
378
  requirements: []
361
379
  rubyforge_project:
362
380
  rubygems_version: 1.8.25
@@ -392,6 +410,7 @@ test_files:
392
410
  - spec/gorillib/hashlike/hashlike_via_accessors_spec.rb
393
411
  - spec/gorillib/hashlike_spec.rb
394
412
  - spec/gorillib/logger/log_spec.rb
413
+ - spec/gorillib/logger_spec.rb
395
414
  - spec/gorillib/metaprogramming/class_attribute_spec.rb
396
415
  - spec/gorillib/metaprogramming/delegation_spec.rb
397
416
  - spec/gorillib/metaprogramming/singleton_class_spec.rb