mini_logger 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +20 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/test/fixtures/test_config.yml +3 -0
- data/test/helper.rb +14 -0
- data/test/test_mini_logger.rb +12 -16
- metadata +91 -61
- data/lib/version.rb +0 -24
- data/test/unit_extensions.rb +0 -23
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
chronic (0.5.0)
|
5
|
+
delorean (1.1.0)
|
6
|
+
chronic
|
7
|
+
file-tail (1.0.6)
|
8
|
+
spruz (~> 0.2)
|
9
|
+
git (1.2.5)
|
10
|
+
jeweler (1.6.4)
|
11
|
+
bundler (~> 1.0)
|
12
|
+
git (>= 1.2.5)
|
13
|
+
rake
|
14
|
+
rake (0.9.2)
|
15
|
+
rcov (0.9.9)
|
16
|
+
shoulda (2.11.3)
|
17
|
+
spruz (0.2.9)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
bundler (~> 1.0.0)
|
24
|
+
delorean
|
25
|
+
file-tail
|
26
|
+
jeweler (~> 1.6.4)
|
27
|
+
rcov
|
28
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Javier Juarez
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
|
17
|
+
gem.name = "mini_logger"
|
18
|
+
gem.homepage = "http://github.com/jjuarez/mini_logger"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = 'A tiny logger utility for small applications'
|
21
|
+
gem.description = 'A minimal standard Logger wrapper perfect for CLI applications'
|
22
|
+
gem.email = "javier.juarez@gmail.com"
|
23
|
+
gem.authors = ["Javier Juarez"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "gema #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.7.0
|
data/test/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
data/test/test_mini_logger.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
|
-
|
2
|
-
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
3
|
-
|
4
|
-
require 'rubygems'
|
1
|
+
require 'helper'
|
5
2
|
require 'tmpdir'
|
6
3
|
require 'delorean'
|
7
4
|
require 'file/tail'
|
8
5
|
require 'mini_logger'
|
9
|
-
require '
|
10
|
-
require 'test/helpers/tail_file_helper'
|
6
|
+
require 'helpers/tail_file_helper'
|
11
7
|
|
12
8
|
|
13
9
|
class TestMiniLogger < Test::Unit::TestCase
|
@@ -16,7 +12,7 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
16
12
|
TEST_MESSAGE = "message"
|
17
13
|
|
18
14
|
|
19
|
-
|
15
|
+
should "validate loglevel" do
|
20
16
|
|
21
17
|
[:debug, 'info', :warn, 'error', :fatal].each do |l|
|
22
18
|
assert(MiniLogger.validate_log_level?(l), "Log level:'#{l} not validated")
|
@@ -28,7 +24,7 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
28
24
|
end
|
29
25
|
|
30
26
|
|
31
|
-
|
27
|
+
should "standarize log level" do
|
32
28
|
|
33
29
|
['debug', 'DEBUG', 'DeBuG'].all? { |l| l == MiniLogger::DEBUG }
|
34
30
|
['debug', 'DEBUG', 'DeBuG'].map { |l| l.to_sym }.all? { |l| l == MiniLogger::DEBUG }
|
@@ -47,7 +43,7 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
47
43
|
end
|
48
44
|
|
49
45
|
|
50
|
-
|
46
|
+
should "create a logger in debug level by default" do
|
51
47
|
|
52
48
|
##
|
53
49
|
# New configuration interface
|
@@ -66,7 +62,7 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
66
62
|
end
|
67
63
|
|
68
64
|
|
69
|
-
|
65
|
+
should "raise and argument error" do
|
70
66
|
|
71
67
|
[:this, 'set', :of, 'log', :levels, 'are', :evil].each do |l|
|
72
68
|
assert_raise(ArgumentError) { MiniLogger.configure(:level=>l) }
|
@@ -74,14 +70,14 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
74
70
|
end
|
75
71
|
|
76
72
|
|
77
|
-
|
73
|
+
should "create a logger from a configuration file" do
|
78
74
|
|
79
75
|
assert_equal(MiniLogger.configure(File.join(File.dirname(__FILE__), %w[fixtures test_config.yml])).level, MiniLogger::ERROR)
|
80
76
|
assert_raise(Errno::ENOENT) { MiniLogger.configure("ThisFileDoNotExist.yml") }
|
81
77
|
end
|
82
78
|
|
83
79
|
|
84
|
-
|
80
|
+
should "confire various loggers" do
|
85
81
|
|
86
82
|
test_logger = MiniLogger.configure
|
87
83
|
assert(test_logger.debug?)
|
@@ -109,7 +105,7 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
109
105
|
end
|
110
106
|
|
111
107
|
|
112
|
-
|
108
|
+
should "change log levels" do
|
113
109
|
|
114
110
|
test_logger = MiniLogger.configure(:dev=>STDERR, :level=>:debug)
|
115
111
|
assert(test_logger.debug?)
|
@@ -134,7 +130,7 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
134
130
|
end
|
135
131
|
|
136
132
|
|
137
|
-
|
133
|
+
should "not change to invalid log level" do
|
138
134
|
|
139
135
|
test_logger = MiniLogger.configure
|
140
136
|
|
@@ -150,7 +146,7 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
150
146
|
end
|
151
147
|
|
152
148
|
|
153
|
-
|
149
|
+
should "write messages in diferents log levels" do
|
154
150
|
|
155
151
|
log_file_name = File.join(Dir.tmpdir, 'mini_logger_test.log')
|
156
152
|
test_logger = MiniLogger.configure(:dev=>log_file_name, :level=>:debug)
|
@@ -178,4 +174,4 @@ class TestMiniLogger < Test::Unit::TestCase
|
|
178
174
|
|
179
175
|
File.delete(log_file_name) if File.exist? log_file_name
|
180
176
|
end
|
181
|
-
end
|
177
|
+
end
|
metadata
CHANGED
@@ -1,97 +1,127 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_logger
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 1
|
10
|
-
version: 0.6.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Javier Juarez
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
requirement: &
|
12
|
+
date: 2011-07-11 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: file-tail
|
16
|
+
requirement: &2157589320 !ruby/object:Gem::Requirement
|
22
17
|
none: false
|
23
|
-
requirements:
|
24
|
-
- -
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
version: "0"
|
30
|
-
version_requirements: *id001
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
31
22
|
type: :development
|
32
|
-
name: jeweler
|
33
23
|
prerelease: false
|
34
|
-
|
35
|
-
|
24
|
+
version_requirements: *2157589320
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: delorean
|
27
|
+
requirement: &2157588820 !ruby/object:Gem::Requirement
|
36
28
|
none: false
|
37
|
-
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
version: "0"
|
44
|
-
version_requirements: *id002
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
45
33
|
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2157588820
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: shoulda
|
38
|
+
requirement: &2157588340 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2157588340
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: &2157587860 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2157587860
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: jeweler
|
60
|
+
requirement: &2157587380 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 1.6.4
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2157587380
|
69
|
+
- !ruby/object:Gem::Dependency
|
46
70
|
name: rcov
|
71
|
+
requirement: &2157586900 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
47
78
|
prerelease: false
|
79
|
+
version_requirements: *2157586900
|
48
80
|
description: A minimal standard Logger wrapper perfect for CLI applications
|
49
81
|
email: javier.juarez@gmail.com
|
50
82
|
executables: []
|
51
|
-
|
52
83
|
extensions: []
|
53
|
-
|
54
|
-
|
84
|
+
extra_rdoc_files:
|
85
|
+
- LICENSE.txt
|
86
|
+
- README.rdoc
|
87
|
+
files:
|
88
|
+
- Gemfile
|
89
|
+
- Gemfile.lock
|
90
|
+
- LICENSE.txt
|
55
91
|
- README.rdoc
|
56
|
-
|
92
|
+
- Rakefile
|
93
|
+
- VERSION
|
57
94
|
- lib/mini_logger.rb
|
58
|
-
-
|
95
|
+
- test/fixtures/test_config.yml
|
96
|
+
- test/helper.rb
|
59
97
|
- test/helpers/tail_file_helper.rb
|
60
98
|
- test/test_mini_logger.rb
|
61
|
-
- test/unit_extensions.rb
|
62
|
-
- README.rdoc
|
63
99
|
homepage: http://github.com/jjuarez/mini_logger
|
64
|
-
licenses:
|
100
|
+
licenses:
|
65
101
|
- MIT
|
66
102
|
post_install_message:
|
67
103
|
rdoc_options: []
|
68
|
-
|
69
|
-
require_paths:
|
104
|
+
require_paths:
|
70
105
|
- lib
|
71
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
107
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
segments:
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
segments:
|
78
113
|
- 0
|
79
|
-
|
80
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
hash: -872984071507759344
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
116
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
segments:
|
87
|
-
- 0
|
88
|
-
version: "0"
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
89
121
|
requirements: []
|
90
|
-
|
91
|
-
rubyforge_project: http://github.com/jjuarez/mini_logger
|
122
|
+
rubyforge_project:
|
92
123
|
rubygems_version: 1.8.5
|
93
124
|
signing_key:
|
94
125
|
specification_version: 3
|
95
126
|
summary: A tiny logger utility for small applications
|
96
127
|
test_files: []
|
97
|
-
|
data/lib/version.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module MiniLogger
|
2
|
-
class Version
|
3
|
-
|
4
|
-
INFO = {
|
5
|
-
:major =>0,
|
6
|
-
:minor =>6,
|
7
|
-
:patch =>1
|
8
|
-
}
|
9
|
-
|
10
|
-
def self.number(version_info=INFO)
|
11
|
-
|
12
|
-
if RUBY_VERSION =~ /1\.8\.\d/
|
13
|
-
[version_info[:major], version_info[:minor],version_info[:patch]].join('.')
|
14
|
-
else
|
15
|
-
version_info.values.join('.')
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
NAME = 'mini_logger'
|
21
|
-
NUMBER = "#{number()}"
|
22
|
-
VERSION = [NAME, NUMBER].join('-')
|
23
|
-
end
|
24
|
-
end
|
data/test/unit_extensions.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'test/unit'
|
3
|
-
|
4
|
-
|
5
|
-
module Test::Unit
|
6
|
-
|
7
|
-
class TestCase
|
8
|
-
|
9
|
-
def self.must(name, &block)
|
10
|
-
|
11
|
-
test_name = "test_#{name.gsub(/\s+/,'_')}".to_sym
|
12
|
-
defined = instance_method(test_name) rescue false
|
13
|
-
|
14
|
-
raise "#{test_name} is already defined in #{self}" if defined
|
15
|
-
|
16
|
-
if block_given?
|
17
|
-
define_method(test_name, &block)
|
18
|
-
else
|
19
|
-
define_method(test_name) { flunk "No implementation provided for #{name}" }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|