mini_logger 0.1.4 → 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/lib/mini_logger.rb CHANGED
@@ -3,23 +3,29 @@ require 'logger'
3
3
 
4
4
 
5
5
  module MiniLogger
6
- class << self
6
+ extend self
7
7
 
8
- DEFAULT_CONFIGURATION = { :log_channel=>STDERR, :log_level=>::Logger::INFO }
9
- VALID_METHODS = [ :debug, :info, :warn, :error, :fatal ]
8
+ DEFAULT_CONFIGURATION = { :log_channel=>STDERR, :log_level=>::Logger::INFO }
9
+ VALID_METHODS = [ :debug, :info, :warn, :error, :fatal ]
10
10
 
11
- def method_missing( method, *arguments, &block )
12
-
13
- self.configure unless @logger
14
- @logger.send( method, arguments.length == 1 ? arguments[0] : arguments ) if VALID_METHODS.include?( method )
15
- end
11
+ def configure( atts = DEFAULT_CONFIGURATION )
16
12
 
17
- def configure( atts = DEFAULT_CONFIGURATION )
18
-
19
- @logger ||= Logger.new( atts[:log_channel] )
20
- @logger.level ||= atts[:log_level]
21
-
22
- self
23
- end
13
+ @logger ||= ::Logger.new( atts[:log_channel] )
14
+ @logger.level ||= atts[:log_level]
15
+
16
+ self
24
17
  end
18
+
19
+ def method_missing( method, *arguments, &block )
20
+
21
+ self.configure unless @logger
22
+
23
+ if( VALID_METHODS.include?( method ) )
24
+ if( block_given? )
25
+ @logger.send( method, arguments, block )
26
+ else
27
+ @logger.send( method, arguments )
28
+ end
29
+ end
30
+ end
25
31
  end
data/lib/version.rb CHANGED
@@ -1,11 +1,12 @@
1
- module Version
2
- module Info
3
- MAJOR = 0
4
- MINOR = 1
5
- PATCH = 4
6
- end
1
+ module MiniLogger
2
+ module Version
3
+ INFO = {
4
+ :major =>0,
5
+ :minor =>2,
6
+ :patch =>2
7
+ }
7
8
 
8
- NAME = 'mini_logger'
9
- INFO = "#{Info::MAJOR}.#{Info::MINOR}.#{Info::PATCH}"
10
- COMPLETE = "#{NAME}-#{INFO}"
11
- end
9
+ NAME = 'mini_logger'
10
+ VERSION = INFO.values.join( '.' )
11
+ end
12
+ end
@@ -1,13 +1,41 @@
1
1
  $:.unshift( File.join( File.dirname( __FILE__ ), %w[.. .. lib] ) )
2
2
 
3
+
4
+ require 'rubygems'
3
5
  require 'test/unit'
4
- require 'mocha'
6
+ require 'shoulda'
5
7
  require 'mini_logger'
6
8
 
7
9
 
8
10
  class TestMiniLogger < Test::Unit::TestCase
9
11
 
10
- def test_case_all
11
- fail( "Not implemented yet" )
12
+ context "A Logger" do
13
+
14
+ MiniLogger.configure( :log_channel=>STDOUT, :log_level=>::Logger::DEBUG )
15
+ end
16
+
17
+ should "Debug" do
18
+
19
+ assert( MiniLogger.debug( "debug XXX" ) )
20
+ end
21
+
22
+ should "Info" do
23
+
24
+ assert( MiniLogger.info( "info XXX" ) )
25
+ end
26
+
27
+ should "Warn" do
28
+
29
+ assert( MiniLogger.warn( "warn XXX" ) )
30
+ end
31
+
32
+ should "Error" do
33
+
34
+ assert( MiniLogger.error( "error XXX" ) )
35
+ end
36
+
37
+ should "Fatal" do
38
+
39
+ assert( MiniLogger.fatal( "fatal XXX" ) )
12
40
  end
13
41
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: mini_logger
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.4
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Javier Juarez
@@ -10,21 +10,11 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-17 00:00:00 +01:00
13
+ date: 2011-03-04 00:00:00 +01:00
14
14
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: config_context
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- type: :runtime
25
- prerelease: false
26
- version_requirements: *id001
27
- description: My config DSL
15
+ dependencies: []
16
+
17
+ description: My tiny logger
28
18
  email: javier.juarez@gmail.com
29
19
  executables: []
30
20
 
@@ -64,6 +54,6 @@ rubyforge_project: http://github.com/jjuarez/mini_logger
64
54
  rubygems_version: 1.5.2
65
55
  signing_key:
66
56
  specification_version: 3
67
- summary: A Config Context for little applications
57
+ summary: A real simple logger utility
68
58
  test_files:
69
59
  - test/unit/tc_mini_logger.rb