debuglog 1.0.0 → 1.0.1

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.
@@ -1,66 +1,79 @@
1
- D "Debuglog auto configuration" do
2
- D.<< {
3
- DebugLog.send :wipe_slate_clean_for_testing
4
- DebugLog.autoconfigure
5
- }
6
-
7
- D "Debuglog and DebugLog are the same thing" do
8
- Id Debuglog, DebugLog
9
- end
10
- D "Methods are defined in Kernel" do
11
- kernel_methods = Kernel.instance_methods
12
- T { kernel_methods.include? :debug }
13
- T { kernel_methods.include? :trace }
14
- T { kernel_methods.include? :time }
15
- end
16
- D "debug" do
17
- debug "abc123"
18
- T :debuglog, /abc123/, "debug.log"
19
- debug -189
20
- T :debuglog, /-189/, "debug.log"
21
- D "multiple arguments" do
22
- x = 5
23
- debug "The value of x is ", x, "!"
24
- T :debuglog, /The value of x is 5!/, "debug.log"
25
- end
26
- D "multi-line text" do
27
- text = "I must go down to the seas again\nTo the lonely sea and the sky\nAnd all I want is a tall ship\nAnd a star to steer her by\n -- John Masefield"
28
- debug text
29
- log_text_lines = File.read("debug.log").split("\n").last(5)
30
- # The text in the log file should be indented to look good.
31
- Mt log_text_lines.shift, /\[\d\d\.\d\] I must go down to the seas again$/
32
- Eq log_text_lines.shift, " To the lonely sea and the sky"
33
- Eq log_text_lines.shift, " And all I want is a tall ship"
34
- Eq log_text_lines.shift, " And a star to steer her by"
35
- Eq log_text_lines.shift, " -- John Masefield"
36
- end
37
- end
38
- D "trace" do
39
- D "array" do
40
- foo = [1,2,3]
41
- trace :foo, binding
42
- T :debuglog, /foo == \[1, 2, 3\]/, "debug.log"
43
- end
44
- D "string" do
45
- str = "blah"
46
- trace :str, binding
47
- T :debuglog, /str == "blah"/, "debug.log"
48
- end
49
- D "truncate output" do
50
- str = "x" * 100
51
- trace :str, binding, 30
52
- T :debuglog, /str == "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\.\.\./, "debug.log"
53
- end
54
- D "different formats" do
55
- # not really interested in this feature at the moment
56
- end
57
- end
58
- D "time" do
59
- time('sum to 10') { 1+2+3+4+5+6+7+8+9+10 }
60
- T :debuglog, /sum to 10: .* sec/, "debug.log"
61
- D "return value of block is accessible" do
62
- sum = time('sum') { 1 + 1 }
63
- Eq sum, 2
64
- end
65
- end
66
- end
1
+ D "Debuglog auto configuration" do
2
+
3
+ D.<< {
4
+ DebugLog.send :wipe_slate_clean_for_testing
5
+ DebugLog.autoconfigure
6
+ }
7
+
8
+ D "Debuglog and DebugLog are the same thing" do
9
+ Id Debuglog, DebugLog
10
+ end
11
+
12
+ D "Methods are defined in Kernel" do
13
+ kernel_methods = Kernel.instance_methods
14
+ T { kernel_methods.include? :debug }
15
+ T { kernel_methods.include? :trace }
16
+ T { kernel_methods.include? :time }
17
+ end
18
+
19
+ D "debug" do
20
+ debug "abc123"
21
+ T :debuglog, /abc123/, "debug.log"
22
+ debug -189
23
+ T :debuglog, /-189/, "debug.log"
24
+ D "multiple arguments" do
25
+ x = 5
26
+ debug "The value of x is ", x, "!"
27
+ T :debuglog, /The value of x is 5!/, "debug.log"
28
+ end
29
+ D "multi-line text" do
30
+ text = "I must go down to the seas again\nTo the lonely sea and the sky\nAnd all I want is a tall ship\nAnd a star to steer her by\n -- John Masefield"
31
+ debug text
32
+ log_text_lines = File.read("debug.log").split("\n").last(5)
33
+ # The text in the log file should be indented to look good.
34
+ Mt log_text_lines.shift, /\[\d\d\.\d\] I must go down to the seas again$/
35
+ Eq log_text_lines.shift, " To the lonely sea and the sky"
36
+ Eq log_text_lines.shift, " And all I want is a tall ship"
37
+ Eq log_text_lines.shift, " And a star to steer her by"
38
+ Eq log_text_lines.shift, " -- John Masefield"
39
+ end
40
+ end
41
+
42
+ D "trace" do
43
+ D "array" do
44
+ foo = [1,2,3]
45
+ trace :foo, binding
46
+ T :debuglog, /foo == \[1, 2, 3\]/, "debug.log"
47
+ end
48
+ D "string" do
49
+ str = "blah"
50
+ trace :str, binding
51
+ T :debuglog, /str == "blah"/, "debug.log"
52
+ end
53
+ D "truncate output" do
54
+ D "output that is too long" do
55
+ str = "x" * 100
56
+ trace :str, binding, 30
57
+ T :debuglog, /str == "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx\.\.\./, "debug.log"
58
+ end
59
+ D "output that is not too long" do
60
+ str = "x" * 10
61
+ trace :str, binding, 30
62
+ T :debuglog, /str == "xxxxxxxxxx"$/, "debug.log"
63
+ end
64
+ end
65
+ D "different formats" do
66
+ # not really interested in this feature at the moment
67
+ end
68
+ end
69
+
70
+ D "time" do
71
+ time('sum to 10') { 1+2+3+4+5+6+7+8+9+10 }
72
+ T :debuglog, /sum to 10: .* sec/, "debug.log"
73
+ D "return value of block is accessible" do
74
+ sum = time('sum') { 1 + 1 }
75
+ Eq sum, 2
76
+ end
77
+ end
78
+
79
+ end
@@ -1,39 +1,41 @@
1
- D "DebugLog manual configuration (successful)" do
2
- D.< { DebugLog.send :wipe_slate_clean_for_testing }
3
-
4
- D ":debug => :my_debug, :filename => 'xyz.txt'" do
5
- Debuglog.configure(:debug => :my_debug, :filename => 'xyz.txt')
6
- D "my_debug method works" do
7
- my_debug "abc123"
8
- T :debuglog, /abc123/, "xyz.txt"
9
- end
10
- D "debug, trace and time methods are not defined" do
11
- E(NoMethodError) { debug "abc123" }
12
- E(NoMethodError) { trace :x, binding }
13
- E(NoMethodError) { time('task') { :foo } }
14
- end
15
- end
16
-
17
- D ":trace => :my_trace, :time => :my_time" do
18
- Debuglog.configure(:trace => :my_trace, :time => :my_time)
19
- D "my_trace and my_time methods work" do
20
- foo = :chorus
21
- my_trace "foo", binding
22
- xT :debuglog, /foo == :chorus/, "debug.log"
23
- my_time('blah') { :dotdotdot }
24
- T :debuglog, /blah: .* sec/, "debug.log"
25
- end
26
- D "debug method not defined" do
27
- E(NoMethodError) { debug "..." }
28
- end
29
- end
30
-
31
- D "empty configuration" do
32
- Debuglog.configure({})
33
- D "debug, trace and time methods don't work" do
34
- E(NoMethodError) { debug "abc123" }
35
- E(NoMethodError) { trace :x, binding }
36
- E(NoMethodError) { time('task') { :foo } }
37
- end
38
- end
39
- end
1
+ D "DebugLog manual configuration (successful)" do
2
+
3
+ D.< { DebugLog.send :wipe_slate_clean_for_testing }
4
+
5
+ D ":debug => :my_debug, :filename => 'xyz.txt'" do
6
+ Debuglog.configure(:debug => :my_debug, :filename => 'xyz.txt')
7
+ D "my_debug method works" do
8
+ my_debug "abc123"
9
+ T :debuglog, /abc123/, "xyz.txt"
10
+ end
11
+ D "debug, trace and time methods are not defined" do
12
+ E(NoMethodError) { debug "abc123" }
13
+ E(NoMethodError) { trace :x, binding }
14
+ E(NoMethodError) { time('task') { :foo } }
15
+ end
16
+ end
17
+
18
+ D ":trace => :my_trace, :time => :my_time" do
19
+ Debuglog.configure(:trace => :my_trace, :time => :my_time)
20
+ D "my_trace and my_time methods work" do
21
+ foo = :chorus
22
+ my_trace "foo", binding
23
+ xT :debuglog, /foo == :chorus/, "debug.log"
24
+ my_time('blah') { :dotdotdot }
25
+ T :debuglog, /blah: .* sec/, "debug.log"
26
+ end
27
+ D "debug method not defined" do
28
+ E(NoMethodError) { debug "..." }
29
+ end
30
+ end
31
+
32
+ D "empty configuration" do
33
+ Debuglog.configure({})
34
+ D "debug, trace and time methods don't work" do
35
+ E(NoMethodError) { debug "abc123" }
36
+ E(NoMethodError) { trace :x, binding }
37
+ E(NoMethodError) { time('task') { :foo } }
38
+ end
39
+ end
40
+
41
+ end
@@ -1,27 +1,29 @@
1
- D "DebugLog manual configuration (unsuccessful)" do
2
- D.< { DebugLog.send :wipe_slate_clean_for_testing }
3
-
4
- D "clash with existing :debug method" do
5
- def Kernel.debug() :foo end
6
- E(DebugLog::Error) { DebugLog.autoconfigure }
7
- end
8
-
9
- D "clash with custom methods" do
10
- def Kernel.my_debug() :foo end
11
- def Kernel.my_trace() :foo end
12
- def Kernel.my_time() :foo end
13
- E(DebugLog::Error) { DebugLog.configure(:debug => :my_debug) }
14
- E(DebugLog::Error) { DebugLog.configure(:trace => :my_trace) }
15
- E(DebugLog::Error) { DebugLog.configure(:time => :my_time) }
16
- end
17
-
18
- D "calling methods without having configured -> error" do
19
- # At this point DebugLog is not configured.
20
- E(NameError) { debug }
21
- E(DebugLog::Error) { DebugLog.call_method(:debug, "...") }
22
- end
23
-
24
- D "specifying unwritable log file -> error" do
25
- E(DebugLog::Error) { DebugLog.configure(:filename => '/fodsfw/fgsg/e/debug.log') }
26
- end
27
- end
1
+ D "DebugLog manual configuration (unsuccessful)" do
2
+
3
+ D.< { DebugLog.send :wipe_slate_clean_for_testing }
4
+
5
+ D "clash with existing :debug method" do
6
+ def Kernel.debug() :foo end
7
+ E(DebugLog::Error) { DebugLog.autoconfigure }
8
+ end
9
+
10
+ D "clash with custom methods" do
11
+ def Kernel.my_debug() :foo end
12
+ def Kernel.my_trace() :foo end
13
+ def Kernel.my_time() :foo end
14
+ E(DebugLog::Error) { DebugLog.configure(:debug => :my_debug) }
15
+ E(DebugLog::Error) { DebugLog.configure(:trace => :my_trace) }
16
+ E(DebugLog::Error) { DebugLog.configure(:time => :my_time) }
17
+ end
18
+
19
+ D "calling methods without having configured -> error" do
20
+ # At this point DebugLog is not configured.
21
+ E(NameError) { debug }
22
+ E(DebugLog::Error) { DebugLog.call_method(:debug, "...") }
23
+ end
24
+
25
+ D "specifying unwritable log file -> error" do
26
+ E(DebugLog::Error) { DebugLog.configure(:filename => '/fodsfw/fgsg/e/debug.log') }
27
+ end
28
+
29
+ end
metadata CHANGED
@@ -1,75 +1,92 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: debuglog
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 0
8
- - 0
9
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Gavin Sinclair
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2010-12-12 00:00:00 +11:00
18
- default_executable:
19
- dependencies: []
20
-
21
- description: " require 'debuglog' and record debugging information (including variable traces\n and timing information) to the file debug.log -- cheap and easy.\n"
22
- email: gsinclair@gmail.com
12
+ date: 2012-01-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: &2169395720 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2169395720
25
+ - !ruby/object:Gem::Dependency
26
+ name: whitestone
27
+ requirement: &2169395240 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2169395240
36
+ description: ! " require 'debuglog' and record debugging information (including
37
+ variable traces\n and timing information) to the file debug.log -- cheap and
38
+ easy.\n"
39
+ email:
40
+ - gsinclair@gmail.com
23
41
  executables: []
24
-
25
42
  extensions: []
26
-
27
43
  extra_rdoc_files: []
28
-
29
- files:
44
+ files:
45
+ - .gitignore
46
+ - Gemfile
47
+ - History.txt
48
+ - LICENCE
49
+ - README.txt
50
+ - Rakefile
51
+ - TODO.txt
52
+ - debuglog.gemspec
53
+ - doc/debuglog.markdown
54
+ - etc/example.rb
55
+ - lib/debuglog.rb
30
56
  - lib/debuglog/auto.rb
31
57
  - lib/debuglog/manual.rb
32
- - lib/debuglog.rb
33
- - README
58
+ - lib/debuglog/version.rb
34
59
  - test/_setup.rb
35
60
  - test/debuglog-auto.rb
36
61
  - test/debuglog-manual-1.rb
37
62
  - test/debuglog-manual-2.rb
38
- - doc/debuglog.markdown
39
- has_rdoc: true
40
63
  homepage: http://gsinclair.github.com/debuglog.html
41
64
  licenses: []
42
-
43
65
  post_install_message:
44
66
  rdoc_options: []
45
-
46
- require_paths:
67
+ require_paths:
47
68
  - lib
48
- required_ruby_version: !ruby/object:Gem::Requirement
69
+ required_ruby_version: !ruby/object:Gem::Requirement
49
70
  none: false
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- segments:
54
- - 0
55
- version: "0"
56
- required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: 1.8.6
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
76
  none: false
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- segments:
62
- - 0
63
- version: "0"
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
64
81
  requirements: []
65
-
66
- rubyforge_project:
67
- rubygems_version: 1.3.7
82
+ rubyforge_project: ''
83
+ rubygems_version: 1.8.10
68
84
  signing_key:
69
85
  specification_version: 3
70
86
  summary: Zero-conf debug.log file with 'debug', 'trace' and 'time' methods
71
- test_files:
87
+ test_files:
72
88
  - test/_setup.rb
73
89
  - test/debuglog-auto.rb
74
90
  - test/debuglog-manual-1.rb
75
91
  - test/debuglog-manual-2.rb
92
+ has_rdoc: false
data/README DELETED
@@ -1,38 +0,0 @@
1
- debuglog: zero-conf debug.log file for simple and hassle-free debugging
2
-
3
- Synopsis
4
-
5
- Debuglog gives you debug, trace and time methods that write their output to
6
- the file ./debug.log.
7
-
8
- require 'debuglog' # or require 'debuglog/auto'
9
-
10
- debug "Message..."
11
- trace :x, binding
12
- time('Task') { action }
13
-
14
- You can change the names of the methods and the filename.
15
-
16
- require 'debuglog/manual'
17
-
18
- DebugLog.configure(
19
- :debug => :my_debug,
20
- :trace => :my_trace,
21
- :time => :my_time,
22
- :filename => 'log/xyz.log'
23
- )
24
-
25
- my_debug "Message..."
26
- my_trace :x, binding
27
- my_time('Task') { action }
28
-
29
- In either case, the log file will look something like this:
30
-
31
- DebugLog -- 2010-07-25 18:58:22 +1000
32
- -------------------------------------
33
- [00.3] Message...
34
- [00.5] x == 5
35
- [00.6] Task: 1.0831 sec
36
-
37
-
38
- See http://gsinclair.github.com/debuglog.html for full details.