<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/log_buddy/log.rb</filename>
    </added>
    <added>
      <filename>lib/log_buddy/version.rb</filename>
    </added>
    <added>
      <filename>spec/log_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,10 @@
 require 'rubygems'
 gem 'echoe'
 require 'echoe'
-require './lib/log_buddy.rb'
 require 'spec/rake/spectask'
+require File.join(File.dirname(__FILE__), *%w[lib log_buddy version])
 
-echoe = Echoe.new('log_buddy', LogBuddy::VERSION) do |p|
+echoe = Echoe.new('log_buddy', LogBuddy::VERSION::STRING) do |p|
   p.rubyforge_name = 'thinkrelevance'
   p.author = 'Rob Sanheim - Relevance'
   p.email = 'opensource@thinkrelevance.com'
@@ -20,9 +20,7 @@ Rake.application.instance_variable_get(:@tasks).delete(&quot;default&quot;)
 Rake.application.instance_variable_get(:@tasks).delete(&quot;test&quot;)
 
 desc &quot;Run examples&quot;
-Spec::Rake::SpecTask.new(&quot;spec&quot;) do |t|
-    t.spec_files = FileList['spec/**/*_spec.rb']
-end
+Spec::Rake::SpecTask.new
 
 task :default =&gt; :spec
 </diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,2 @@
-require 'log_buddy'
+require File.join(File.dirname(__FILE__), *%w[lib log_buddy])
 LogBuddy.init unless ENV[&quot;SAFE_LOG_BUDDY&quot;]
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,29 +1,16 @@
-=begin rdoc
-LogBuddy is a developer tool for easy logging while testing, debugging, and inspecting.
-  
-Log shortcut method to give you easy, concise output of variables with their names and values.
-
-Examples:
-    a = &quot;foo&quot;
-    @a = &quot;my var&quot;
-    def bark
-     &quot;woof!&quot;
-    end
-
-    d { a }      # logs &quot;a = 'foo'&quot;
-    d { @a }     # logs &quot;@a = 'my var'&quot;
-    d { bark }   # logs &quot;bark = woof!&quot;
-    
-=end
-class LogBuddy
-  VERSION = '0.1.3'
-
-  # Use LogBuddy!
+module LogBuddy
+  # Configure and include LogBuddy into Object.
+  # You can pass in any of the following configuration options:
+  # 
+  # * &lt;tt&gt;:logger&lt;/tt&gt; - the logger instance that LogBuddy should use (if not provided, 
+  #   tries to default to RAILS_DEFAULT_LOGGER, and then to a STDOUT logger).
+  # * &lt;tt):stdout&lt;/tt&gt; - whether LogBuddy should _also_ log to STDOUT, very helpful for Autotest (default is +true+).
   def self.init(options = {})
-    @logger = options[:default_logger]
+    @logger = options[:logger]
+    @log_to_stdout = options.has_key?(:log_to_stdout) ? options[:log_to_stdout] : true
     mixin_to_object
   end
-  
+
   # Add the LogBuddy::Mixin to Object instance and class level.
   def self.mixin_to_object
     Object.class_eval { 
@@ -31,82 +18,30 @@ class LogBuddy
       extend LogBuddy::Mixin
     }
   end
-  
-  # The main Mixin that gets added on the #init call
-  module Mixin
-    # This is where the magic happens.  This method can take a plain old string, and it will log 
-    # it like any call to Logger#debug.  To get the name of the thing you are logging and its value,
-    # use the block form:
-    #    d { @a }
-    #
-    # Seperate with semicolons for multiple things - pretty much any valid ruby will work.
-    #    d { @@foo; MY_CONST }
-    #    d { @person; @@place; object.method() }
-    #
-    def d(msg = nil, &amp;blk)
-      LogBuddy.debug(msg) if msg
-      return unless block_given?
-      begin
-        logged_line = LogBuddy.read_line(caller[0])
-        arguments = LogBuddy.parse_args(logged_line)
-        arguments.each do |arg|
-          result = eval(arg, blk.binding)
-          LogBuddy.debug(%[#{arg} = '#{result}'\n])
-        end
-      rescue RuntimeError =&gt; e
-        LogBuddy.debug &quot;LogBuddy caught an exception: #{e.message}&quot;
-      end
-    end
 
-    # Add a default logger to everything, everywhere.
+  class &lt;&lt; self
     def logger
-      LogBuddy.default_logger
+      return @logger if @logger
+      @logger = init_default_logger
     end
-  end
-  
-  private
-  
-  # Default logger LogBuddy will use
-  def self.default_logger
-    return @logger if @logger
-    @logger = init_default_logger
-  end
-  
-  # Attempt to establish a default logger - first try RAILS_DEFAULT_LOGGER,
-  # then fallback to default.
-  def self.init_default_logger
-    if Object.const_defined?(&quot;RAILS_DEFAULT_LOGGER&quot;)
-      @logger = Object.const_get(&quot;RAILS_DEFAULT_LOGGER&quot;)
-    else
-      require 'logger'
-      @logger = Logger.new(STDOUT)
+    
+    def log_to_stdout?
+      @log_to_stdout
+    end
+    
+    private
+    
+    def init_default_logger
+      if Object.const_defined?(&quot;RAILS_DEFAULT_LOGGER&quot;)
+        @logger = Object.const_get(&quot;RAILS_DEFAULT_LOGGER&quot;)
+      else
+        require 'logger'
+        @logger = Logger.new(STDOUT)
+      end
     end
-  end
-  
-  # Just debug it
-  def self.debug(str)
-    stdout_puts(str)
-    default_logger.debug(str)
-  end
-  
-  def self.stdout_puts(str)
-    puts str
-  end
-  
-  # Returns array of arguments in the block
-  # You must ues the brace form (ie d { &quot;hi&quot; }) and not do...end
-  def self.parse_args(logged_line)
-    block_contents = logged_line[/\{(.*)\}/, 1]
-    args = block_contents.split(&quot;;&quot;).map {|arg| arg.strip }
-  end
-  
-  # Return the calling line
-  def self.read_line(frame)
-    file, line_number = frame.split(/:/, 2)
-    line_number = line_number.to_i
-    lines = File.readlines(file)
     
-    lines[line_number - 1]
   end
-  
 end
+
+require File.join(File.dirname(__FILE__), *%w[log_buddy log])
+require File.join(File.dirname(__FILE__), *%w[log_buddy version])</diff>
      <filename>lib/log_buddy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,4 @@
+require 'logger'
 require 'rubygems'
 gem 'rspec'
 gem 'mocha'</diff>
      <filename>spec/helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,128 +1,37 @@
 require File.expand_path(File.join(File.dirname(__FILE__), *%w[helper]))
 
-module SomeModule
-  def self.say_something(name)
-    &quot;#{message} #{name}&quot;
-  end
+describe LogBuddy do
   
-  def self.message
-    &quot;hello&quot;
+  it &quot;has logger&quot; do
+    LogBuddy.should respond_to :logger
   end
   
-  def self.raise_runtime_error
-    raise RuntimeError
+  it &quot;has stdout config option&quot; do
+    LogBuddy.should respond_to :log_to_stdout?
   end
-end
-
-describe LogBuddy, &quot; contract&quot; do
-  describe &quot;object extensions&quot; do
+  
+  describe &quot;init&quot; do
     it &quot;mixes itself into Object instance and class level by default&quot; do
       Object.expects(:include).with(LogBuddy::Mixin)
       Object.expects(:extend).with(LogBuddy::Mixin)
       LogBuddy.init
     end
-    
+
     it &quot;adds logger method to Object instance and class&quot; do
       LogBuddy.init
       Object.new.should respond_to :logger
       Object.should respond_to :logger
     end
     
-    it &quot;uses RAILS_DEFAULT_LOGGER if its defined&quot; do
-      begin
-        Object.const_set &quot;RAILS_DEFAULT_LOGGER&quot;, stub_everything
-        LogBuddy.init
-        Object.logger.should == RAILS_DEFAULT_LOGGER
-      ensure 
-        Object.send :remove_const, &quot;RAILS_DEFAULT_LOGGER&quot;
-      end
-    end
-    
-    it &quot;uses a plain STDOUT Ruby logger if there is no RAILS_DEFAULT_LOGGER&quot; do
+    it &quot;defaults to log to stdout (as well as logger)&quot; do
       LogBuddy.init
-      Object.logger.should == LogBuddy.default_logger
-    end
-    
-    it &quot;can override the default logger&quot; do
-      file_logger = Logger.new &quot;test.log&quot;
-      LogBuddy.init :default_logger =&gt; file_logger
-      Object.logger.should == file_logger
-    end
-  end
-  
-  describe &quot;outputting the code being logged and its result&quot; do
-    before { LogBuddy.init }
-    it &quot;should log to default logger&quot; do
-      LogBuddy.expects(:default_logger).returns(logger = mock)
-      logger.expects(:debug).with(anything)
-      d {'hi'}
-    end
-    
-    it &quot;should log a plain arg&quot; do
-      LogBuddy.expects(:debug).with('hi')
-      d 'hi'
-    end
-    
-    it &quot;logs both if given an arg and a block&quot; do
-      LogBuddy.expects(:debug).with('hi mom')
-      LogBuddy.expects(:debug).with(%[foo = 'foo'\n])
-      foo = &quot;foo&quot;
-      d(&quot;hi mom&quot;) { foo }
-    end
-    
-    it &quot;does nothing without a block&quot; do
-      lambda { d }.should_not raise_error
-    end
-    
-    it &quot;should output only local vars in the block&quot; do
-      LogBuddy.expects(:debug).with(%[a = 'foo'\n])
-      b = &quot;bad&quot;
-      a = &quot;foo&quot;
-      d { a }
-    end
-  
-    it &quot;should output instance vars&quot; do
-      LogBuddy.expects(:debug).with(%[@a = 'foo'\n])
-      @a = &quot;foo&quot;
-      d { @a }
-    end
-    
-    it &quot;should output constants&quot; do
-      FOO_CONST = &quot;yo!&quot;
-      LogBuddy.expects(:debug).with(%[FOO_CONST = 'yo!'\n])
-      d { FOO_CONST }
-    end
-  
-    it &quot;should output class vars&quot; do
-      LogBuddy.expects(:debug).with(%[@@class_var = 'hi'\n])
-      @@class_var = &quot;hi&quot;
-      d { @@class_var }
+      LogBuddy.log_to_stdout?.should == true
     end
-  
-    it &quot;should output method calls&quot; do
-      LogBuddy.expects(:debug).with(%[SomeModule.say_something(&quot;dude!!!!&quot;) = 'hello dude!!!!'\n])
-      d { SomeModule.say_something(&quot;dude!!!!&quot;) }
-    end 
-    
-    it &quot;should output multiple things with each having their own log calls&quot; do
-      local1 = '1'
-      local2 = '2'
-      @ivar1 = '1'
-      LogBuddy.expects(:debug).with(%[local1 = '1'\n])
-      LogBuddy.expects(:debug).with(%[local2 = '2'\n])
-      LogBuddy.expects(:debug).with(%[@ivar1 = '1'\n])
-      d { local1; local2; @ivar1 }
-    end
-    
-    it &quot;should gracefully handle runtimer errors&quot; do
-      LogBuddy.expects(:debug).with('LogBuddy caught an exception: RuntimeError')
-      d { SomeModule.raise_runtime_error }
-    end
-    
-    it &quot;logs to stdout as well as the default logger&quot; do
-      pending(&quot;failing in rspec for some reason - no idea why&quot;)
-      LogBuddy.expects(:stdout_puts).with(anything) #.with(%[&quot;foo&quot; = 'foo'\n])
-      d { &quot;foo&quot; }
+
+    it &quot;can be configured to log to stdout&quot; do
+      LogBuddy.init :stdout =&gt; false
+      LogBuddy.log_to_stdout?.should == true
     end
   end
+
 end
\ No newline at end of file</diff>
      <filename>spec/log_buddy_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>14c9683874301660b4560be78cd74ad8277fb59a</id>
    </parent>
  </parents>
  <author>
    <name>Rob Sanheim</name>
    <email>rsanheim@gmail.com</email>
  </author>
  <url>http://github.com/relevance/log_buddy/commit/23f0057579da55eb56108259967981eaddcf0585</url>
  <id>23f0057579da55eb56108259967981eaddcf0585</id>
  <committed-date>2008-11-15T19:36:05-08:00</committed-date>
  <authored-date>2008-11-15T19:36:05-08:00</authored-date>
  <message>massive reorg...specs are green but still a WIP</message>
  <tree>c9f84ae92e2b050f015c21c0e7b2dce52ba738a5</tree>
  <committer>
    <name>Rob Sanheim</name>
    <email>rsanheim@gmail.com</email>
  </committer>
</commit>
