relevance-log_buddy 0.0.2 → 0.0.3

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/CHANGELOG CHANGED
@@ -1,17 +1,3 @@
1
- v0.1.4 Micronauts Unite! Test Suite now runs via Micronaut - http://github.com/spicycode/micronaut/
2
-
3
- v0.1.3 Use plain old echoe; really fix rubygems errors (I hope)
4
-
5
- v0.1.2 Attempting to fix rubygems errors
6
-
7
- v0.1.1. Handle exceptions from within the block
8
-
9
- v0.1.0. Specify, clean up
10
-
11
- v0.0.6. changed to mixing to Object by default - set ENV["SAFE_LOG_BUDDY"] = true to override
12
-
13
- v0.0.5. update echoe dependency to work with github
14
-
15
1
  v0.0.4. add dev dependencies, remove gem calls from rdoc task
16
2
 
17
3
  v0.0.3. specs and tweaks
data/Manifest CHANGED
@@ -1,12 +1,8 @@
1
1
  CHANGELOG
2
+ Manifest
3
+ README.rdoc
4
+ Rakefile
2
5
  examples.rb
3
6
  init.rb
4
7
  lib/log_buddy.rb
5
- LICENSE
6
- log_buddy.gemspec
7
- Manifest
8
- Rakefile
9
- README.rdoc
10
- examples/example_helper.rb
11
- examples/log_buddy_init_example.rb
12
- examples/log_buddy_example.rb
8
+ test/test_log_buddy.rb
data/README.rdoc CHANGED
@@ -6,18 +6,16 @@ log_buddy is your friendly little log buddy at your side, helping you dev, debug
6
6
 
7
7
  == SYNOPSIS:
8
8
 
9
- Require the init.rb file to use log_buddy. By default, it will add two methods to every object at the instance and class level: "d" and "logger". To use log_buddy without the automatic object intrusion, set ENV["SAFE_LOG_BUDDY"] = true before requiring the init.rb.
10
-
11
- You can use your own logger with Logbuddy by passing it into init's options hash:
9
+ Call LogBuddy.init to use log_buddy. It will add two methods to object instance and class level: "d" and "logger". You can use your own logger with Logbuddy by passing it into init's options hash:
12
10
 
13
11
  LogBuddy.init :default_logger => Logger.new('my_log.log')
14
12
 
15
13
  Now you have your logger available from any object, at the instance level and class level:
16
14
 
17
15
  obj = Object.new
18
- obj.logger.debug("hi") # logs to 'my_log.log'
16
+ obj.logger.debug("hi")
19
17
  class MyClass; end
20
- MyClass.logger.info("heya") # also logs to 'my_log.log'
18
+ MyClass.logger.info("heya")
21
19
 
22
20
  You also have a method called "d" (for "debug") on any object, which is used for quick debugging and logging of things while you are developing.
23
21
  Its especially useful while using autotest. When you call the "d" method with an inline block, it will log the name of the things
@@ -41,7 +39,7 @@ See examples.rb for live examples you can run.
41
39
  == REQUIREMENTS:
42
40
 
43
41
  * Ruby 1.8.6 or JRuby (tested with 1.1RC3)
44
- * untested on Ruby versions before 1.8.6, but should work fine
42
+ * untested on Ruby < 1.8.6, but probably works
45
43
 
46
44
  == ISSUES
47
45
 
@@ -54,10 +52,10 @@ See examples.rb for live examples you can run.
54
52
 
55
53
  == URLS
56
54
 
57
- * Log bugs, issues, and suggestions at Lighthouse: http://relevance.lighthouseapp.com/projects/19074-log-buddy/overview
58
- * View Source: http://github.com/relevance/logbuddy
55
+ * Log bugs, issues, and suggestions on Trac: http://opensource.thinkrelevance.com/wiki/log_buddy
56
+ * View Source: http://github.com/relevance/logbuddy/tree/master
59
57
  * Git clone Source: git://github.com/relevance/logbuddy.git
60
- * RDocs: http://thinkrelevance.rubyforge.org/log_buddy
58
+ * RDocs: http://thinkrelevance.rubyforge.org/log_buddy/
61
59
 
62
60
  == LICENSE:
63
61
 
@@ -83,6 +81,3 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
83
81
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
84
82
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
85
83
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86
-
87
-
88
-
data/Rakefile CHANGED
@@ -1,9 +1,8 @@
1
1
  require 'rubygems'
2
- gem 'echoe'
3
2
  require 'echoe'
4
- require File.join(File.dirname(__FILE__), *%w[lib log_buddy version])
3
+ require './lib/log_buddy.rb'
5
4
 
6
- echoe = Echoe.new('log_buddy', LogBuddy::VERSION::STRING) do |p|
5
+ echoe = Echoe.new('log_buddy', LogBuddy::VERSION) do |p|
7
6
  p.rubyforge_name = 'thinkrelevance'
8
7
  p.author = 'Rob Sanheim - Relevance'
9
8
  p.email = 'opensource@thinkrelevance.com'
@@ -13,34 +12,8 @@ echoe = Echoe.new('log_buddy', LogBuddy::VERSION::STRING) do |p|
13
12
  p.rdoc_pattern = /^(lib|bin|ext)|txt|rdoc|CHANGELOG|LICENSE$/
14
13
  rdoc_template = `allison --path`.strip << ".rb"
15
14
  p.rdoc_template = rdoc_template
15
+ p.yaml_gemspec = false
16
16
  end
17
17
 
18
- Rake.application.instance_variable_get(:@tasks).delete("default")
19
- Rake.application.instance_variable_get(:@tasks).delete("test")
20
-
21
- namespace :micronaut do
22
-
23
- desc 'Run all examples'
24
- task :examples do
25
- examples = Dir["examples/**/*_example.rb"].map { |g| Dir.glob(g) }.flatten
26
- examples.map! {|f| %Q(require "#{f}")}
27
- command = "-e '#{examples.join("; ")}'"
28
- ruby command
29
- end
30
-
31
- desc "Run all examples using rcov"
32
- task :coverage do
33
- examples = Dir["examples/**/*_example.rb"].map { |g| Dir.glob(g) }.flatten
34
- system "rcov --exclude \"examples/*,gems/*,db/*,/Library/Ruby/*,config/*\" --text-report --sort coverage --no-validator-links #{examples.join(' ')}"
35
- end
36
-
37
- end
38
-
39
- task :default => 'micronaut:coverage'
40
-
41
- # The below results in 'input stream exhausted' - dunno why?
42
- # task :release => [:test, :publish_docs, :announce]
43
-
44
- echoe.spec.add_development_dependency "echoe"
45
18
  echoe.spec.add_development_dependency "allison"
46
19
  echoe.spec.add_development_dependency "markaby"
data/examples.rb CHANGED
@@ -15,7 +15,6 @@ module Foo;
15
15
  end
16
16
 
17
17
 
18
- d "hi" # logs "hi" (regular old logging)
19
18
  d { a } # logs "a = 'foo'"
20
19
  d { @a } # logs "@a = 'my var'"
21
20
  d { @@bar } # logs "@@bar = 'class var!'"
data/init.rb CHANGED
@@ -1,2 +1 @@
1
- require File.join(File.dirname(__FILE__), *%w[lib log_buddy])
2
- LogBuddy.init unless ENV["SAFE_LOG_BUDDY"]
1
+ require 'log_buddy'
data/lib/log_buddy.rb CHANGED
@@ -1,11 +1,7 @@
1
- require File.join(File.dirname(__FILE__), *%w[log_buddy utils])
2
- require File.join(File.dirname(__FILE__), *%w[log_buddy mixin])
3
- require File.join(File.dirname(__FILE__), *%w[log_buddy version])
4
-
5
1
  =begin rdoc
6
2
  LogBuddy is a developer tool for easy logging while testing, debugging, and inspecting.
7
3
 
8
- The log shortcut method to give you easy, concise output of variables with their names and values.
4
+ Log shortcut method to give you easy, concise output of variables with their names and values.
9
5
 
10
6
  Examples:
11
7
  a = "foo"
@@ -19,19 +15,15 @@ Examples:
19
15
  d { bark } # logs "bark = woof!"
20
16
 
21
17
  =end
22
- module LogBuddy
23
- # Configure and include LogBuddy into Object.
24
- # You can pass in any of the following configuration options:
25
- #
26
- # * <tt>:logger</tt> - the logger instance that LogBuddy should use (if not provided,
27
- # tries to default to RAILS_DEFAULT_LOGGER, and then to a STDOUT logger).
28
- # * <tt):log_to_stdout</tt> - whether LogBuddy should _also_ log to STDOUT, very helpful for Autotest (default is +true+).
18
+ class LogBuddy
19
+ VERSION = '0.0.3'
20
+
21
+ # Use LogBuddy!
29
22
  def self.init(options = {})
30
- @logger = options[:logger]
31
- @log_to_stdout = options.has_key?(:log_to_stdout) ? options[:log_to_stdout] : true
23
+ @logger = options[:default_logger]
32
24
  mixin_to_object
33
25
  end
34
-
26
+
35
27
  # Add the LogBuddy::Mixin to Object instance and class level.
36
28
  def self.mixin_to_object
37
29
  Object.class_eval {
@@ -39,28 +31,73 @@ module LogBuddy
39
31
  extend LogBuddy::Mixin
40
32
  }
41
33
  end
34
+
35
+ # The main Mixin that gets added on the #init call
36
+ module Mixin
37
+ # This is where the magic happens. This method can take a plain old string, and it will log
38
+ # it like any call to Logger#debug. To get the name of the thing you are logging and its value,
39
+ # use the block form:
40
+ # d { @a }
41
+ #
42
+ # Seperate with semicolons for multiple things - pretty much any valid ruby will work.
43
+ # d { @@foo; MY_CONST }
44
+ # d { @person; @@place; object.method() }
45
+ #
46
+ def d(msg = nil, &blk)
47
+ LogBuddy.debug(msg) if msg
48
+ return unless block_given?
49
+ logged_line = LogBuddy.read_line(caller[0])
50
+ arguments = LogBuddy.parse_args(logged_line)
51
+ arguments.each do |arg|
52
+ result = eval(arg, blk.binding)
53
+ LogBuddy.debug(%[#{arg} = '#{result}'\n])
54
+ end
55
+ end
42
56
 
43
- class << self
44
- include LogBuddy::Utils
57
+ # Add a default logger to everything, everywhere.
45
58
  def logger
46
- return @logger if @logger
47
- @logger = init_default_logger
48
- end
49
-
50
- def log_to_stdout?
51
- @log_to_stdout
59
+ LogBuddy.default_logger
52
60
  end
53
-
54
- private
55
-
56
- def init_default_logger
57
- if Object.const_defined?("RAILS_DEFAULT_LOGGER")
58
- @logger = Object.const_get("RAILS_DEFAULT_LOGGER")
59
- else
60
- require 'logger'
61
- @logger = Logger.new(STDOUT)
62
- end
61
+ end
62
+
63
+ private
64
+
65
+ # Default logger LogBuddy will use
66
+ def self.default_logger
67
+ return @logger if @logger
68
+ @logger = init_default_logger
69
+ end
70
+
71
+ # Attempt to establish a default logger - first try RAILS_DEFAULT_LOGGER,
72
+ # then fallback to default.
73
+ def self.init_default_logger
74
+ if Object.const_defined?("RAILS_DEFAULT_LOGGER")
75
+ @logger = Object.const_get("RAILS_DEFAULT_LOGGER")
76
+ else
77
+ require 'logger'
78
+ @logger = Logger.new(STDOUT)
63
79
  end
80
+ end
81
+
82
+ # Just debug it
83
+ def self.debug(str)
84
+ default_logger.debug(str)
85
+ end
86
+
87
+ # Returns array of arguments in the block
88
+ # You must ues the brace form (ie d { "hi" }) and not do...end
89
+ def self.parse_args(logged_line)
90
+ block_contents = logged_line[/\{(.*)\}/, 1]
91
+ args = block_contents.split(";").map {|arg| arg.strip }
92
+ end
93
+
94
+ # Return the calling line
95
+ def self.read_line(frame)
96
+ file, line_number = frame.split(/:/, 2)
97
+ line_number = line_number.to_i
98
+ lines = File.readlines(file)
64
99
 
100
+ lines[line_number - 1]
65
101
  end
102
+
66
103
  end
data/log_buddy.gemspec CHANGED
@@ -1,41 +1,37 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
1
  Gem::Specification.new do |s|
4
2
  s.name = %q{log_buddy}
5
- s.version = "0.0.2"
3
+ s.version = "0.0.3"
6
4
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
5
+ s.required_rubygems_version = Gem::Requirement.new("= 1.2") if s.respond_to? :required_rubygems_version=
8
6
  s.authors = ["Rob Sanheim - Relevance"]
9
- s.date = %q{2008-11-26}
7
+ s.date = %q{2008-07-01}
10
8
  s.description = %q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
11
9
  s.email = %q{opensource@thinkrelevance.com}
12
- s.extra_rdoc_files = ["CHANGELOG", "lib/log_buddy.rb", "LICENSE", "README.rdoc"]
13
- s.files = ["CHANGELOG", "examples.rb", "init.rb", "lib/log_buddy.rb", "LICENSE", "log_buddy.gemspec", "Manifest", "Rakefile", "README.rdoc", "examples/example_helper.rb", "examples/log_buddy_init_example.rb", "examples/log_buddy_example.rb"]
10
+ s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/log_buddy.rb"]
11
+ s.files = ["CHANGELOG", "Manifest", "README.rdoc", "Rakefile", "examples.rb", "init.rb", "lib/log_buddy.rb", "test/test_log_buddy.rb", "log_buddy.gemspec"]
14
12
  s.has_rdoc = true
15
13
  s.homepage = %q{http://opensource.thinkrelevance.com/wiki/log_buddy}
16
14
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Log_buddy", "--main", "README.rdoc"]
17
15
  s.require_paths = ["lib"]
18
16
  s.rubyforge_project = %q{thinkrelevance}
19
- s.rubygems_version = %q{1.3.1}
17
+ s.rubygems_version = %q{1.2.0}
20
18
  s.summary = %q{Log Buddy is your little development buddy.}
19
+ s.test_files = ["test/test_log_buddy.rb"]
21
20
 
22
21
  if s.respond_to? :specification_version then
23
22
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
23
  s.specification_version = 2
25
24
 
26
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
- s.add_development_dependency(%q<echoe>, [">= 0"])
25
+ if current_version >= 3 then
28
26
  s.add_development_dependency(%q<echoe>, [">= 0"])
29
27
  s.add_development_dependency(%q<allison>, [">= 0"])
30
28
  s.add_development_dependency(%q<markaby>, [">= 0"])
31
29
  else
32
- s.add_dependency(%q<echoe>, [">= 0"])
33
30
  s.add_dependency(%q<echoe>, [">= 0"])
34
31
  s.add_dependency(%q<allison>, [">= 0"])
35
32
  s.add_dependency(%q<markaby>, [">= 0"])
36
33
  end
37
34
  else
38
- s.add_dependency(%q<echoe>, [">= 0"])
39
35
  s.add_dependency(%q<echoe>, [">= 0"])
40
36
  s.add_dependency(%q<allison>, [">= 0"])
41
37
  s.add_dependency(%q<markaby>, [">= 0"])
@@ -0,0 +1,124 @@
1
+ require 'rubygems'
2
+ require "test/unit"
3
+ require "test/spec"
4
+ require "test/spec/should-output"
5
+ require 'mocha'
6
+ require 'logger'
7
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "log_buddy"))
8
+
9
+ module SomeModule
10
+ def self.say_something(name)
11
+ "#{message} #{name}"
12
+ end
13
+
14
+ def self.message
15
+ "hello"
16
+ end
17
+ end
18
+
19
+ describe "LogBuddy" do
20
+
21
+ describe "raise no method error if init isn't called" do
22
+ lambda { Object.new.d }.should.raise NoMethodError
23
+ end
24
+
25
+ describe "object extensions" do
26
+ it "mixes itself into Object intance and class level by default" do
27
+ Object.expects(:include).with(LogBuddy::Mixin)
28
+ Object.expects(:extend).with(LogBuddy::Mixin)
29
+ LogBuddy.init
30
+ end
31
+
32
+ it "adds logger method to Object instance and class" do
33
+ LogBuddy.init
34
+ Object.new.should.respond_to :logger
35
+ Object.should.respond_to :logger
36
+ end
37
+
38
+ it "uses RAILS_DEFAULT_LOGGER if its defined" do
39
+ begin
40
+ Object.const_set "RAILS_DEFAULT_LOGGER", stub_everything
41
+ LogBuddy.init
42
+ Object.logger.should == RAILS_DEFAULT_LOGGER
43
+ ensure
44
+ Object.send :remove_const, "RAILS_DEFAULT_LOGGER"
45
+ end
46
+ end
47
+
48
+ it "uses a plain STDOUT Ruby logger if there is no RAILS_DEFAULT_LOGGER" do
49
+ LogBuddy.init
50
+ Object.logger.should == LogBuddy.default_logger
51
+ end
52
+
53
+ it "can override the default logger" do
54
+ file_logger = Logger.new "test.log"
55
+ LogBuddy.init :default_logger => file_logger
56
+ Object.logger.should == file_logger
57
+ end
58
+ end
59
+
60
+ describe "outputting the code being logged and its result" do
61
+ before { LogBuddy.init }
62
+ it "should log to default logger" do
63
+ LogBuddy.expects(:default_logger).returns(logger = mock)
64
+ logger.expects(:debug).with(anything)
65
+ d {'hi'}
66
+ end
67
+
68
+ it "should log a plain arg" do
69
+ LogBuddy.expects(:debug).with('hi')
70
+ d 'hi'
71
+ end
72
+
73
+ it "logs both if given an arg and a block" do
74
+ LogBuddy.expects(:debug).with('hi mom')
75
+ LogBuddy.expects(:debug).with(%[foo = 'foo'\n])
76
+ foo = "foo"
77
+ d("hi mom") { foo }
78
+ end
79
+
80
+ it "does nothing without a block" do
81
+ should.not.raise { d }
82
+ end
83
+
84
+ it "should output only local vars in the block" do
85
+ LogBuddy.expects(:debug).with(%[a = 'foo'\n])
86
+ b = "bad"
87
+ a = "foo"
88
+ d { a }
89
+ end
90
+
91
+ it "should output instance vars" do
92
+ LogBuddy.expects(:debug).with(%[@a = 'foo'\n])
93
+ @a = "foo"
94
+ d { @a }
95
+ end
96
+
97
+ it "should output constants" do
98
+ FOO_CONST = "yo!"
99
+ LogBuddy.expects(:debug).with(%[FOO_CONST = 'yo!'\n])
100
+ d { FOO_CONST }
101
+ end
102
+
103
+ it "should output class vars" do
104
+ LogBuddy.expects(:debug).with(%[@@class_var = 'hi'\n])
105
+ @@class_var = "hi"
106
+ d { @@class_var }
107
+ end
108
+
109
+ it "should output method calls" do
110
+ LogBuddy.expects(:debug).with(%[SomeModule.say_something("dude!!!!") = 'hello dude!!!!'\n])
111
+ d { SomeModule.say_something("dude!!!!") }
112
+ end
113
+
114
+ it "should output multiple things with each having their own log calls" do
115
+ local1 = '1'
116
+ local2 = '2'
117
+ @ivar1 = '1'
118
+ LogBuddy.expects(:debug).with(%[local1 = '1'\n])
119
+ LogBuddy.expects(:debug).with(%[local2 = '2'\n])
120
+ LogBuddy.expects(:debug).with(%[@ivar1 = '1'\n])
121
+ d { local1; local2; @ivar1 }
122
+ end
123
+ end
124
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relevance-log_buddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Sanheim - Relevance
@@ -9,18 +9,9 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-26 00:00:00 -08:00
12
+ date: 2008-07-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: echoe
17
- version_requirement:
18
- version_requirements: !ruby/object:Gem::Requirement
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
23
- version:
24
15
  - !ruby/object:Gem::Dependency
25
16
  name: echoe
26
17
  version_requirement:
@@ -56,22 +47,18 @@ extensions: []
56
47
 
57
48
  extra_rdoc_files:
58
49
  - CHANGELOG
59
- - lib/log_buddy.rb
60
- - LICENSE
61
50
  - README.rdoc
51
+ - lib/log_buddy.rb
62
52
  files:
63
53
  - CHANGELOG
54
+ - Manifest
55
+ - README.rdoc
56
+ - Rakefile
64
57
  - examples.rb
65
58
  - init.rb
66
59
  - lib/log_buddy.rb
67
- - LICENSE
60
+ - test/test_log_buddy.rb
68
61
  - log_buddy.gemspec
69
- - Manifest
70
- - Rakefile
71
- - README.rdoc
72
- - examples/example_helper.rb
73
- - examples/log_buddy_init_example.rb
74
- - examples/log_buddy_example.rb
75
62
  has_rdoc: true
76
63
  homepage: http://opensource.thinkrelevance.com/wiki/log_buddy
77
64
  post_install_message:
@@ -92,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
79
  version:
93
80
  required_rubygems_version: !ruby/object:Gem::Requirement
94
81
  requirements:
95
- - - ">="
82
+ - - "="
96
83
  - !ruby/object:Gem::Version
97
84
  version: "1.2"
98
85
  version:
@@ -103,5 +90,5 @@ rubygems_version: 1.2.0
103
90
  signing_key:
104
91
  specification_version: 2
105
92
  summary: Log Buddy is your little development buddy.
106
- test_files: []
107
-
93
+ test_files:
94
+ - test/test_log_buddy.rb
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 Relevance, Inc. - http://thinkrelevance.com
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 NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,16 +0,0 @@
1
- require 'logger'
2
- require 'rubygems'
3
- gem 'spicycode-micronaut', "= 0.0.4"
4
- gem 'mocha'
5
- require "mocha"
6
- require 'micronaut'
7
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "log_buddy"))
8
-
9
- def silence_warnings
10
- old_verbose, $VERBOSE = $VERBOSE, nil
11
- yield
12
- ensure
13
- $VERBOSE = old_verbose
14
- end
15
-
16
- Micronaut::Runner.autorun
@@ -1,37 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
2
-
3
- describe LogBuddy do
4
-
5
- it "has logger" do
6
- LogBuddy.should respond_to(:logger)
7
- end
8
-
9
- it "has stdout config option" do
10
- LogBuddy.should respond_to(:log_to_stdout?)
11
- end
12
-
13
- describe "init" do
14
- it "mixes itself into Object instance and class level by default" do
15
- Object.expects(:include).with(LogBuddy::Mixin)
16
- Object.expects(:extend).with(LogBuddy::Mixin)
17
- LogBuddy.init
18
- end
19
-
20
- it "adds logger method to Object instance and class" do
21
- LogBuddy.init
22
- Object.new.should respond_to(:logger)
23
- Object.should respond_to(:logger)
24
- end
25
-
26
- it "defaults to log to stdout (as well as logger)" do
27
- LogBuddy.init
28
- LogBuddy.log_to_stdout?.should == true
29
- end
30
-
31
- it "can be configured to log to stdout" do
32
- LogBuddy.init :stdout => false
33
- LogBuddy.log_to_stdout?.should == true
34
- end
35
- end
36
-
37
- end
@@ -1,30 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
2
-
3
- describe LogBuddy do
4
- describe "init" do
5
- after { reset_safe_log_buddy_mode }
6
-
7
- it "doesnt mixin to object if SAFE_LOG_BUDDY is true" do
8
- LogBuddy.expects(:init).never
9
- ENV["SAFE_LOG_BUDDY"] = "true"
10
- load_init
11
- end
12
-
13
- it "mixin to object if SAFE_LOG_BUDDY is true" do
14
- LogBuddy.expects(:init).once
15
- load_init
16
- end
17
-
18
- def load_init
19
- silence_warnings do
20
- load File.join(File.dirname(__FILE__), *%w[.. init.rb])
21
- end
22
- end
23
-
24
- def reset_safe_log_buddy_mode
25
- ENV["SAFE_LOG_BUDDY"] = nil
26
- end
27
-
28
- end
29
-
30
- end