debug_log 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in debug_log.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ debug_log (0.0.3)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.2)
10
+ mocha (0.9.9)
11
+ rake
12
+ rake (0.8.7)
13
+ rspec (2.0.0)
14
+ rspec-core (= 2.0.0)
15
+ rspec-expectations (= 2.0.0)
16
+ rspec-mocks (= 2.0.0)
17
+ rspec-core (2.0.0)
18
+ rspec-expectations (2.0.0)
19
+ diff-lcs (>= 1.1.2)
20
+ rspec-mocks (2.0.0)
21
+ rspec-core (= 2.0.0)
22
+ rspec-expectations (= 2.0.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ debug_log!
29
+ mocha (~> 0.9.9)
30
+ rspec (= 2.0.0)
data/Rakefile CHANGED
@@ -1,14 +1,8 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+ Bundler.require
4
4
 
5
- desc 'Default: run unit tests.'
6
- task :default => :test
5
+ require 'rspec/core'
6
+ require 'rspec/core/rake_task'
7
7
 
8
- desc 'Run all tests'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.libs << 'test'
12
- t.pattern = 'test/**/*_test.rb'
13
- t.verbose = true
14
- end
8
+ RSpec::Core::RakeTask.new(:default)
data/debug_log.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "debug_log/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "debug_log"
7
+ s.version = DebugLog::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Peter Marklund"]
10
+ s.email = ["peter@marklunds.com"]
11
+ s.homepage = "http://rubygems.org/gems/debug_log"
12
+ s.summary = %q{A more powerful way to do debug printouts than puts}
13
+ s.description = <<-END
14
+ Allows you to easily and readably printout variable values (or any other Ruby expressions) to stdout
15
+ and/or any number of logger objects of your choice for debugging purposes. The approach to accessing
16
+ the binding object was inspired by the dp gem by Niclas Nilsson.
17
+ END
18
+
19
+ s.rubyforge_project = "debug_log"
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+
26
+ s.add_development_dependency "rspec", "2.0.0"
27
+ s.add_development_dependency "mocha", "~> 0.9.9"
28
+ end
@@ -0,0 +1,3 @@
1
+ module DebugLog
2
+ VERSION = "0.0.3"
3
+ end
data/lib/debug_log.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'active_support'
2
-
3
1
  module Kernel
4
2
  alias_method :debug, :binding
5
3
  end
@@ -11,15 +9,18 @@ class Binding
11
9
  end
12
10
 
13
11
  module DebugLog
14
- mattr_accessor :logger
15
- self.logger = nil
16
-
17
- mattr_accessor :stdout
18
- self.stdout = true
19
-
20
- mattr_accessor :enabled
21
- self.enabled = true
22
-
12
+ @@logger = nil
13
+ def self.logger; @@logger; end
14
+ def self.logger=(logger); @@logger = logger; end
15
+
16
+ @@stdout = true
17
+ def self.stdout; @@stdout; end
18
+ def self.stdout=(stdout); @@stdout = stdout; end
19
+
20
+ @@enabled = true
21
+ def self.enabled; @@enabled; end
22
+ def self.enabled=(enabled); @@enabled = enabled; end
23
+
23
24
  def self.prefix
24
25
  name
25
26
  end
@@ -1,17 +1,17 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require 'spec_helper'
2
2
 
3
- class CoreExtensionsTest < Test::Unit::TestCase
4
- context "Kernel.debug" do
3
+ describe "core extensions" do
4
+ describe "Kernel.debug" do
5
5
  it "should return a Binding object" do
6
- assert debug.is_a?(Binding)
6
+ debug.is_a?(Binding).should be_true
7
7
  end
8
8
 
9
9
  it "should allow evaluation of local variables in the binding" do
10
- assert_equal 5, eval("my_variable", debug_with_my_variable)
10
+ eval("my_variable", debug_with_my_variable).should == 5
11
11
  end
12
12
  end
13
13
 
14
- context "Binding" do
14
+ describe "Binding" do
15
15
  it "should have a log method" do
16
16
  args = ["a debug message", 'var1', 'var2']
17
17
  the_binding = binding
@@ -1,7 +1,8 @@
1
- require File.dirname(__FILE__) + '/test_helper'
1
+ require 'spec_helper'
2
+ require 'logger'
2
3
 
3
- class DebugLogTest < Test::Unit::TestCase
4
- context "log" do
4
+ describe DebugLog do
5
+ describe "log" do
5
6
  before do
6
7
  @comment = "a debug printout"
7
8
  @expression_string = "expression string"
@@ -10,6 +11,14 @@ class DebugLogTest < Test::Unit::TestCase
10
11
  @expected_message = [DebugLog.prefix, @comment, @expression_string, @calling_method].join(DebugLog.separator)
11
12
  DebugLog.stdout = true
12
13
  DebugLog.enabled = true
14
+ @logger_before = DebugLog.logger
15
+ @enabled_before = DebugLog.enabled
16
+ end
17
+
18
+ after do
19
+ # Reset default values
20
+ DebugLog.logger = @logger_before
21
+ DebugLog.enabled = @enabled_before
13
22
  end
14
23
 
15
24
  it "should output a message and a number of variables to stdout" do
@@ -59,34 +68,34 @@ class DebugLogTest < Test::Unit::TestCase
59
68
  end
60
69
  end
61
70
 
62
- context "logger" do
71
+ describe "logger" do
63
72
  it "defaults to nil but can be initialized to a logger object" do
64
- assert_equal nil, DebugLog.logger
73
+ DebugLog.logger.should be_nil
65
74
  logger = Logger.new($stdout)
66
75
  DebugLog.logger = logger
67
- assert_equal logger, DebugLog.logger
76
+ DebugLog.logger.should == logger
68
77
  end
69
78
  end
70
79
 
71
- context "stdout" do
80
+ describe "stdout" do
72
81
  it "is true by default but can be set to false" do
73
- assert_equal true, DebugLog.stdout
82
+ DebugLog.stdout.should be_true
74
83
  DebugLog.stdout = false
75
- assert_equal false, DebugLog.stdout
84
+ DebugLog.stdout.should be_false
76
85
  end
77
86
  end
78
87
 
79
- context "enabled" do
88
+ describe "enabled" do
80
89
  it "is true by default but can be set to false" do
81
- assert_equal true, DebugLog.enabled
90
+ DebugLog.enabled.should be_true
82
91
  DebugLog.enabled = false
83
- assert_equal false, DebugLog.enabled
92
+ DebugLog.enabled.should be_false
84
93
  end
85
94
  end
86
95
 
87
- context "calling_method" do
96
+ describe "calling_method" do
88
97
  it "should get the calling method from the Kernel.caller stack, three steps up" do
89
- assert_match /method_that_invokes_debug_log/, method_that_invokes_debug_log
98
+ method_that_invokes_debug_log.should =~ /method_that_invokes_debug_log/
90
99
  end
91
100
 
92
101
  def method_that_invokes_debug_log
@@ -102,30 +111,30 @@ class DebugLogTest < Test::Unit::TestCase
102
111
  end
103
112
  end
104
113
 
105
- context "format_value" do
114
+ describe "format_value" do
106
115
  it "invokes inspect by default" do
107
116
  the_value = [:foo, :bar]
108
- assert_equal the_value.inspect, DebugLog.format_value(the_value)
117
+ DebugLog.format_value(the_value).should == the_value.inspect
109
118
  end
110
119
  end
111
120
 
112
- context "format_expression" do
121
+ describe "format_expression" do
113
122
  it "evaluates an expression and also prints the class" do
114
123
  the_value = [:foo, :bar]
115
124
  formated_value = "formated value"
116
125
  DebugLog.expects(:format_value).with(the_value).returns(formated_value)
117
126
  expected_format = %Q{the_value="#{formated_value}" (#{the_value.class.name})}
118
- assert_equal expected_format, DebugLog.format_expression(binding, 'the_value')
127
+ DebugLog.format_expression(binding, 'the_value').should == expected_format
119
128
  end
120
129
  end
121
130
 
122
- context "separator" do
131
+ describe "separator" do
123
132
  it "returns pipe by default" do
124
- assert_equal " | ", DebugLog.separator
133
+ DebugLog.separator.should == " | "
125
134
  end
126
135
  end
127
136
 
128
- context "expression_string" do
137
+ describe "expression_string" do
129
138
  it "creates a comma separated key-value string from a number of expressions and a binding object" do
130
139
  my_var = "Peter"
131
140
  the_binding = binding
@@ -134,13 +143,13 @@ class DebugLogTest < Test::Unit::TestCase
134
143
  DebugLog.expects(:format_expression).with(the_binding, 'my_var').returns(formats[0])
135
144
  DebugLog.expects(:format_expression).with(the_binding, 'my_var[0,1]').returns(formats[1])
136
145
  expected_string = formats.join(", ")
137
- assert_equal expected_string, DebugLog.expression_string(the_binding, 'my_var', 'my_var[0,1]')
146
+ DebugLog.expression_string(the_binding, 'my_var', 'my_var[0,1]').should == expected_string
138
147
  end
139
148
  end
140
149
 
141
- context "prefix" do
150
+ describe "prefix" do
142
151
  it "returns class name by default" do
143
- assert_equal "DebugLog", DebugLog.prefix
152
+ DebugLog.prefix.should == "DebugLog"
144
153
  end
145
154
  end
146
155
  end
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+ Bundler.require(:development)
3
+
4
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
5
+ require 'debug_log'
6
+
7
+ RSpec.configure do |config|
8
+ config.mock_with :mocha
9
+ end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debug_log
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 0
9
- - 2
10
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
11
10
  platform: ruby
12
11
  authors:
13
12
  - Peter Marklund
@@ -15,27 +14,42 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-06-17 00:00:00 +02:00
17
+ date: 2010-11-01 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- name: activesupport
23
- prerelease: false
21
+ name: rspec
24
22
  requirement: &id001 !ruby/object:Gem::Requirement
25
23
  none: false
26
24
  requirements:
27
- - - ">="
25
+ - - "="
28
26
  - !ruby/object:Gem::Version
29
- hash: 7
30
27
  segments:
31
28
  - 2
32
- - 3
33
- - 2
34
- version: 2.3.2
35
- type: :runtime
29
+ - 0
30
+ - 0
31
+ version: 2.0.0
32
+ type: :development
33
+ prerelease: false
36
34
  version_requirements: *id001
37
- description: " Allows you to easily and readably printout variable values (or any other Ruby expressions) to stdout\n and/or a log file of your choice for debugging purposes. The approach to accessing\n the binding object was inspired by the dp gem by Niclas Nilsson.\n"
38
- email: peter@marklunds.com
35
+ - !ruby/object:Gem::Dependency
36
+ name: mocha
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 9
45
+ - 9
46
+ version: 0.9.9
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *id002
50
+ description: " Allows you to easily and readably printout variable values (or any other Ruby expressions) to stdout\n and/or any number of logger objects of your choice for debugging purposes. The approach to accessing\n the binding object was inspired by the dp gem by Niclas Nilsson.\n"
51
+ email:
52
+ - peter@marklunds.com
39
53
  executables: []
40
54
 
41
55
  extensions: []
@@ -43,15 +57,18 @@ extensions: []
43
57
  extra_rdoc_files: []
44
58
 
45
59
  files:
46
- - MIT-LICENSE
60
+ - .gitignore
61
+ - Gemfile
62
+ - Gemfile.lock
47
63
  - Rakefile
64
+ - debug_log.gemspec
48
65
  - lib/debug_log.rb
49
- - test/core_extensions_test.rb
50
- - test/debug_log_test.rb
51
- - test/manual.rb
52
- - test/test_helper.rb
66
+ - lib/debug_log/version.rb
67
+ - spec/core_extensions_spec.rb
68
+ - spec/debug_log_spec.rb
69
+ - spec/spec_helper.rb
53
70
  has_rdoc: true
54
- homepage: http://marklunds.com
71
+ homepage: http://rubygems.org/gems/debug_log
55
72
  licenses: []
56
73
 
57
74
  post_install_message:
@@ -64,32 +81,27 @@ required_ruby_version: !ruby/object:Gem::Requirement
64
81
  requirements:
65
82
  - - ">="
66
83
  - !ruby/object:Gem::Version
67
- hash: 57
84
+ hash: -634113617
68
85
  segments:
69
- - 1
70
- - 8
71
- - 7
72
- version: 1.8.7
86
+ - 0
87
+ version: "0"
73
88
  required_rubygems_version: !ruby/object:Gem::Requirement
74
89
  none: false
75
90
  requirements:
76
91
  - - ">="
77
92
  - !ruby/object:Gem::Version
78
- hash: 23
93
+ hash: -634113617
79
94
  segments:
80
- - 1
81
- - 3
82
- - 6
83
- version: 1.3.6
95
+ - 0
96
+ version: "0"
84
97
  requirements: []
85
98
 
86
- rubyforge_project:
99
+ rubyforge_project: debug_log
87
100
  rubygems_version: 1.3.7
88
101
  signing_key:
89
102
  specification_version: 3
90
103
  summary: A more powerful way to do debug printouts than puts
91
104
  test_files:
92
- - test/core_extensions_test.rb
93
- - test/debug_log_test.rb
94
- - test/manual.rb
95
- - test/test_helper.rb
105
+ - spec/core_extensions_spec.rb
106
+ - spec/debug_log_spec.rb
107
+ - spec/spec_helper.rb
data/MIT-LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2010 Peter Marklund
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/test/manual.rb DELETED
@@ -1,10 +0,0 @@
1
- # Manual sanity check test
2
-
3
- require 'rubygems'
4
- require File.join(File.dirname(__FILE__), "..", "lib", "debug_log")
5
-
6
- def hello
7
- foo = "fOOOOOOO"
8
- debug.log("pm debug hello there", 'foo')
9
- end
10
- hello
data/test/test_helper.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- gem 'jeremymcanally-context', '0.5.5'
3
- gem 'mocha', '0.9.8'
4
- require 'context'
5
- require 'mocha'
6
- require File.dirname(__FILE__) + '/../lib/debug_log'