simplelog 0.2.1 → 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/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\\#{@@name}_#{Date.today.to_s}.txt".sub("__", "_")
68
+ "#@@dir/" << "#{@@name}_#{Time.now.strftime("%Y-%m-%d_%H%M")}.txt".gsub(/_{2,}/, "_")
70
69
  end
71
70
 
72
71
  def Simplelog.save
@@ -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 = Date.today
27
+ today = "Sunday"
28
28
  puts today
29
- assert_match(/#{today.to_s}\n$/, Simplelog.logtext)
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\\#{@logname}_#{Date.today.to_s}.txt"
66
- assert_equal(Simplelog.filename, fname)
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.1
7
- date: 2006-11-07 00:00:00 +01:00
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