relevance-log_buddy 0.0.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/CHANGELOG ADDED
@@ -0,0 +1,21 @@
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
+ v0.0.4. add dev dependencies, remove gem calls from rdoc task
16
+
17
+ v0.0.3. specs and tweaks
18
+
19
+ v0.0.2. rdocs; support for multiple statements in one "d" call separated by semicolons
20
+
21
+ v0.0.1. Initial release to github; Birthday
data/LICENSE ADDED
@@ -0,0 +1,20 @@
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.
data/Manifest ADDED
@@ -0,0 +1,12 @@
1
+ CHANGELOG
2
+ examples.rb
3
+ init.rb
4
+ 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
data/README.rdoc ADDED
@@ -0,0 +1,88 @@
1
+ = LogBuddy
2
+
3
+ == DESCRIPTION:
4
+
5
+ log_buddy is your friendly little log buddy at your side, helping you dev, debug, and test.
6
+
7
+ == SYNOPSIS:
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:
12
+
13
+ LogBuddy.init :default_logger => Logger.new('my_log.log')
14
+
15
+ Now you have your logger available from any object, at the instance level and class level:
16
+
17
+ obj = Object.new
18
+ obj.logger.debug("hi") # logs to 'my_log.log'
19
+ class MyClass; end
20
+ MyClass.logger.info("heya") # also logs to 'my_log.log'
21
+
22
+ 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
+ Its especially useful while using autotest. When you call the "d" method with an inline block, it will log the name of the things
24
+ in the block and the result. Examples:
25
+
26
+ a = "foo"
27
+ @a = "my var"
28
+ @@bar = "class var!"
29
+ def bark
30
+ "woof!"
31
+ end
32
+
33
+ d { a } # logs "a = 'foo'"
34
+ d { @a } # logs "@a = 'my var'"
35
+ d { @@bar } # logs "@@bar = 'class var!'"
36
+ d { bark } # logs "bark = woof!"
37
+
38
+
39
+ See examples.rb for live examples you can run.
40
+
41
+ == REQUIREMENTS:
42
+
43
+ * Ruby 1.8.6 or JRuby (tested with 1.1RC3)
44
+ * untested on Ruby versions before 1.8.6, but should work fine
45
+
46
+ == ISSUES
47
+
48
+ * This is meant for non-production use while developing and testing --> it does stuff that is slow and you probably don't want happening in your production environment.
49
+ * Don't even try using this in irb.
50
+
51
+ == INSTALL:
52
+
53
+ * sudo gem install log_buddy
54
+
55
+ == URLS
56
+
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
59
+ * Git clone Source: git://github.com/relevance/logbuddy.git
60
+ * RDocs: http://thinkrelevance.rubyforge.org/log_buddy
61
+
62
+ == LICENSE:
63
+
64
+ (The MIT License)
65
+
66
+ Copyright (c) 2008 Relevance, Inc. - http://thinkrelevance.com
67
+
68
+ Permission is hereby granted, free of charge, to any person obtaining
69
+ a copy of this software and associated documentation files (the
70
+ 'Software'), to deal in the Software without restriction, including
71
+ without limitation the rights to use, copy, modify, merge, publish,
72
+ distribute, sublicense, and/or sell copies of the Software, and to
73
+ permit persons to whom the Software is furnished to do so, subject to
74
+ the following conditions:
75
+
76
+ The above copyright notice and this permission notice shall be
77
+ included in all copies or substantial portions of the Software.
78
+
79
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
80
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
82
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
83
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
84
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
85
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
86
+
87
+
88
+
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+ gem 'echoe'
3
+ require 'echoe'
4
+ require File.join(File.dirname(__FILE__), *%w[lib log_buddy version])
5
+
6
+ echoe = Echoe.new('log_buddy', LogBuddy::VERSION::STRING) do |p|
7
+ p.rubyforge_name = 'thinkrelevance'
8
+ p.author = 'Rob Sanheim - Relevance'
9
+ p.email = 'opensource@thinkrelevance.com'
10
+ p.summary = 'Log Buddy is your little development buddy.'
11
+ p.description = 'Log statements along with their name easily. Mixin a logger everywhere when you need it.'
12
+ p.url = "http://opensource.thinkrelevance.com/wiki/log_buddy"
13
+ p.rdoc_pattern = /^(lib|bin|ext)|txt|rdoc|CHANGELOG|LICENSE$/
14
+ rdoc_template = `allison --path`.strip << ".rb"
15
+ p.rdoc_template = rdoc_template
16
+ end
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
+ echoe.spec.add_development_dependency "allison"
46
+ echoe.spec.add_development_dependency "markaby"
@@ -0,0 +1,16 @@
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
@@ -0,0 +1,37 @@
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
@@ -0,0 +1,30 @@
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
data/examples.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'lib/log_buddy'
2
+ LogBuddy.init
3
+
4
+ a = "foo"
5
+ @a = "my var"
6
+ @@bar = "class var!"
7
+ def bark
8
+ "woof!"
9
+ end
10
+
11
+ module Foo;
12
+ def self.module_method
13
+ "hi!!"
14
+ end
15
+ end
16
+
17
+
18
+ d "hi" # logs "hi" (regular old logging)
19
+ d { a } # logs "a = 'foo'"
20
+ d { @a } # logs "@a = 'my var'"
21
+ d { @@bar } # logs "@@bar = 'class var!'"
22
+ d { bark } # logs "bark = woof!"
23
+ d { Foo::module_method } # logs Foo::module_method = 'hi!!'
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ require File.join(File.dirname(__FILE__), *%w[lib log_buddy])
2
+ LogBuddy.init unless ENV["SAFE_LOG_BUDDY"]
data/lib/log_buddy.rb ADDED
@@ -0,0 +1,66 @@
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
+ =begin rdoc
6
+ LogBuddy is a developer tool for easy logging while testing, debugging, and inspecting.
7
+
8
+ The log shortcut method to give you easy, concise output of variables with their names and values.
9
+
10
+ Examples:
11
+ a = "foo"
12
+ @a = "my var"
13
+ def bark
14
+ "woof!"
15
+ end
16
+
17
+ d { a } # logs "a = 'foo'"
18
+ d { @a } # logs "@a = 'my var'"
19
+ d { bark } # logs "bark = woof!"
20
+
21
+ =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+).
29
+ def self.init(options = {})
30
+ @logger = options[:logger]
31
+ @log_to_stdout = options.has_key?(:log_to_stdout) ? options[:log_to_stdout] : true
32
+ mixin_to_object
33
+ end
34
+
35
+ # Add the LogBuddy::Mixin to Object instance and class level.
36
+ def self.mixin_to_object
37
+ Object.class_eval {
38
+ include LogBuddy::Mixin
39
+ extend LogBuddy::Mixin
40
+ }
41
+ end
42
+
43
+ class << self
44
+ include LogBuddy::Utils
45
+ def logger
46
+ return @logger if @logger
47
+ @logger = init_default_logger
48
+ end
49
+
50
+ def log_to_stdout?
51
+ @log_to_stdout
52
+ 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
63
+ end
64
+
65
+ end
66
+ end
data/log_buddy.gemspec ADDED
@@ -0,0 +1,43 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{log_buddy}
5
+ s.version = "0.0.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Rob Sanheim - Relevance"]
9
+ s.date = %q{2008-11-26}
10
+ s.description = %q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
11
+ 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"]
14
+ s.has_rdoc = true
15
+ s.homepage = %q{http://opensource.thinkrelevance.com/wiki/log_buddy}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Log_buddy", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{thinkrelevance}
19
+ s.rubygems_version = %q{1.3.1}
20
+ s.summary = %q{Log Buddy is your little development buddy.}
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 2
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ s.add_development_dependency(%q<echoe>, [">= 0"])
28
+ s.add_development_dependency(%q<echoe>, [">= 0"])
29
+ s.add_development_dependency(%q<allison>, [">= 0"])
30
+ s.add_development_dependency(%q<markaby>, [">= 0"])
31
+ else
32
+ s.add_dependency(%q<echoe>, [">= 0"])
33
+ s.add_dependency(%q<echoe>, [">= 0"])
34
+ s.add_dependency(%q<allison>, [">= 0"])
35
+ s.add_dependency(%q<markaby>, [">= 0"])
36
+ end
37
+ else
38
+ s.add_dependency(%q<echoe>, [">= 0"])
39
+ s.add_dependency(%q<echoe>, [">= 0"])
40
+ s.add_dependency(%q<allison>, [">= 0"])
41
+ s.add_dependency(%q<markaby>, [">= 0"])
42
+ end
43
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: relevance-log_buddy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Rob Sanheim - Relevance
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-26 00:00:00 -08:00
13
+ default_executable:
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
+ - !ruby/object:Gem::Dependency
25
+ name: echoe
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ - !ruby/object:Gem::Dependency
34
+ name: allison
35
+ version_requirement:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: "0"
41
+ version:
42
+ - !ruby/object:Gem::Dependency
43
+ name: markaby
44
+ version_requirement:
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ description: Log statements along with their name easily. Mixin a logger everywhere when you need it.
52
+ email: opensource@thinkrelevance.com
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - CHANGELOG
59
+ - lib/log_buddy.rb
60
+ - LICENSE
61
+ - README.rdoc
62
+ files:
63
+ - CHANGELOG
64
+ - examples.rb
65
+ - init.rb
66
+ - lib/log_buddy.rb
67
+ - LICENSE
68
+ - 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
+ has_rdoc: true
76
+ homepage: http://opensource.thinkrelevance.com/wiki/log_buddy
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --line-numbers
80
+ - --inline-source
81
+ - --title
82
+ - Log_buddy
83
+ - --main
84
+ - README.rdoc
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ version:
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: "1.2"
98
+ version:
99
+ requirements: []
100
+
101
+ rubyforge_project: thinkrelevance
102
+ rubygems_version: 1.2.0
103
+ signing_key:
104
+ specification_version: 2
105
+ summary: Log Buddy is your little development buddy.
106
+ test_files: []
107
+