simplelog 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/simplelog.rb +1 -2
- data/test/simplelog_test.rb +7 -4
- metadata +2 -2
data/lib/simplelog.rb
CHANGED
@@ -8,7 +8,6 @@
|
|
8
8
|
# This makes it ideal for situations where you need simple logging, or when an
|
9
9
|
# existing application grows and you need to save output in a hurry.
|
10
10
|
|
11
|
-
require 'date'
|
12
11
|
require 'ftools'
|
13
12
|
|
14
13
|
# Here we redefine puts
|
@@ -66,7 +65,7 @@ class Simplelog
|
|
66
65
|
|
67
66
|
# Directory and filename. Subsequent underscores are removed.
|
68
67
|
def Simplelog.filename
|
69
|
-
"#@@dir
|
68
|
+
"#@@dir/" << "#{@@name}_#{Time.now.strftime("%Y-%m-%d_%H%M")}.txt".gsub(/_{2,}/, "_")
|
70
69
|
end
|
71
70
|
|
72
71
|
def Simplelog.save
|
data/test/simplelog_test.rb
CHANGED
@@ -24,9 +24,9 @@ class Simplelogtest < Test::Unit::TestCase
|
|
24
24
|
puts "Some more text for tests"
|
25
25
|
puts "We are testing"
|
26
26
|
assert_match(/testing\n$/, Simplelog.logtext)
|
27
|
-
today =
|
27
|
+
today = "Sunday"
|
28
28
|
puts today
|
29
|
-
assert_match(/#{today
|
29
|
+
assert_match(/#{today}\n$/, Simplelog.logtext)
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_p
|
@@ -62,8 +62,11 @@ class Simplelogtest < Test::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_filename
|
65
|
-
fname = "#@dirname
|
66
|
-
assert_equal(Simplelog.filename
|
65
|
+
fname = "#@dirname/#{@logname}_#{Time.now.strftime("%Y-%m-%d_%H%M")}.txt"
|
66
|
+
assert_equal(fname, Simplelog.filename)
|
67
|
+
Simplelog.name = "many___many___underscores___"
|
68
|
+
corrected_fname = "#@dirname/many_many_underscores_#{Time.now.strftime("%Y-%m-%d_%H%M")}.txt"
|
69
|
+
assert_equal(corrected_fname, Simplelog.filename)
|
67
70
|
end
|
68
71
|
|
69
72
|
def test_save
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: simplelog
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date:
|
6
|
+
version: 0.2.2
|
7
|
+
date: 2007-01-07 00:00:00 +01:00
|
8
8
|
summary: The simplest logger ever. Just require 'simplelog' and all puts statements are logged to .txt as well as shown on screen.
|
9
9
|
require_paths:
|
10
10
|
- lib
|