log_buddy 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/LICENSE +20 -0
- data/Manifest +8 -4
- data/README.rdoc +9 -4
- data/Rakefile +7 -0
- data/examples.rb +1 -0
- data/init.rb +2 -1
- data/lib/log_buddy.rb +1 -1
- data/log_buddy.gemspec +8 -7
- data/spec/helper.rb +14 -0
- data/spec/log_buddy_init_spec.rb +27 -0
- data/{test/test_log_buddy.rb → spec/log_buddy_spec.rb} +2 -13
- metadata +14 -10
data/CHANGELOG
CHANGED
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
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
CHANGELOG
|
2
|
-
Manifest
|
3
|
-
README.rdoc
|
4
|
-
Rakefile
|
5
2
|
examples.rb
|
6
3
|
init.rb
|
7
4
|
lib/log_buddy.rb
|
8
|
-
|
5
|
+
LICENSE
|
6
|
+
log_buddy.gemspec
|
7
|
+
Manifest
|
8
|
+
Rakefile
|
9
|
+
README.rdoc
|
10
|
+
spec/helper.rb
|
11
|
+
spec/log_buddy_init_spec.rb
|
12
|
+
spec/log_buddy_spec.rb
|
data/README.rdoc
CHANGED
@@ -6,16 +6,18 @@ log_buddy is your friendly little log buddy at your side, helping you dev, debug
|
|
6
6
|
|
7
7
|
== SYNOPSIS:
|
8
8
|
|
9
|
-
|
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:
|
10
12
|
|
11
13
|
LogBuddy.init :default_logger => Logger.new('my_log.log')
|
12
14
|
|
13
15
|
Now you have your logger available from any object, at the instance level and class level:
|
14
16
|
|
15
17
|
obj = Object.new
|
16
|
-
obj.logger.debug("hi")
|
18
|
+
obj.logger.debug("hi") # logs to 'my_log.log'
|
17
19
|
class MyClass; end
|
18
|
-
MyClass.logger.info("heya")
|
20
|
+
MyClass.logger.info("heya") # also logs to 'my_log.log'
|
19
21
|
|
20
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.
|
21
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
|
@@ -39,7 +41,7 @@ See examples.rb for live examples you can run.
|
|
39
41
|
== REQUIREMENTS:
|
40
42
|
|
41
43
|
* Ruby 1.8.6 or JRuby (tested with 1.1RC3)
|
42
|
-
* untested on Ruby
|
44
|
+
* untested on Ruby versions before 1.8.6, but should work fine
|
43
45
|
|
44
46
|
== ISSUES
|
45
47
|
|
@@ -81,3 +83,6 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
81
83
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
82
84
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
83
85
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
86
|
+
|
87
|
+
|
88
|
+
|
data/Rakefile
CHANGED
@@ -22,5 +22,12 @@ echoe = Echoe.new('log_buddy', LogBuddy::VERSION) do |p|
|
|
22
22
|
p.rdoc_template = rdoc_template
|
23
23
|
end
|
24
24
|
|
25
|
+
desc 'Test LogBuddy.'
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.pattern = 'spec/**/*_spec.rb'
|
29
|
+
t.verbose = true
|
30
|
+
end
|
31
|
+
|
25
32
|
echoe.spec.add_development_dependency "allison"
|
26
33
|
echoe.spec.add_development_dependency "markaby"
|
data/examples.rb
CHANGED
data/init.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require 'log_buddy'
|
1
|
+
require 'log_buddy'
|
2
|
+
LogBuddy.init unless ENV["SAFE_LOG_BUDDY"]
|
data/lib/log_buddy.rb
CHANGED
data/log_buddy.gemspec
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = %q{log_buddy}
|
3
|
-
s.version = "0.0
|
5
|
+
s.version = "0.1.0"
|
4
6
|
|
5
7
|
s.required_rubygems_version = Gem::Requirement.new("= 1.2") if s.respond_to? :required_rubygems_version=
|
6
8
|
s.authors = ["Rob Sanheim - Relevance"]
|
7
|
-
s.date = %q{2008-
|
9
|
+
s.date = %q{2008-10-30}
|
8
10
|
s.description = %q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
|
9
11
|
s.email = %q{opensource@thinkrelevance.com}
|
10
|
-
s.extra_rdoc_files = ["CHANGELOG", "
|
11
|
-
s.files = ["CHANGELOG", "
|
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", "spec/helper.rb", "spec/log_buddy_init_spec.rb", "spec/log_buddy_spec.rb"]
|
12
14
|
s.has_rdoc = true
|
13
15
|
s.homepage = %q{http://opensource.thinkrelevance.com/wiki/log_buddy}
|
14
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Log_buddy", "--main", "README.rdoc"]
|
15
17
|
s.require_paths = ["lib"]
|
16
18
|
s.rubyforge_project = %q{thinkrelevance}
|
17
|
-
s.rubygems_version = %q{1.
|
19
|
+
s.rubygems_version = %q{1.3.0}
|
18
20
|
s.summary = %q{Log Buddy is your little development buddy.}
|
19
|
-
s.test_files = ["test/test_log_buddy.rb"]
|
20
21
|
|
21
22
|
if s.respond_to? :specification_version then
|
22
23
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
24
|
s.specification_version = 2
|
24
25
|
|
25
|
-
if
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
27
|
s.add_development_dependency(%q<echoe>, [">= 0"])
|
27
28
|
s.add_development_dependency(%q<allison>, [">= 0"])
|
28
29
|
s.add_development_dependency(%q<markaby>, [">= 0"])
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require "test/unit"
|
3
|
+
require "test/spec"
|
4
|
+
require "test/spec/should-output"
|
5
|
+
require "mocha"
|
6
|
+
require "redgreen" rescue nil
|
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
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), *%w[helper]))
|
2
|
+
|
3
|
+
describe "LogBuddy init" do
|
4
|
+
after { reset_safe_log_buddy_mode }
|
5
|
+
|
6
|
+
it "doesnt mixin to object if SAFE_LOG_BUDDY is true" do
|
7
|
+
LogBuddy.expects(:init).never
|
8
|
+
ENV["SAFE_LOG_BUDDY"] = "true"
|
9
|
+
load_init
|
10
|
+
end
|
11
|
+
|
12
|
+
it "mixin to object if SAFE_LOG_BUDDY is true" do
|
13
|
+
LogBuddy.expects(:init).once
|
14
|
+
load_init
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_init
|
18
|
+
silence_warnings do
|
19
|
+
load File.join(File.dirname(__FILE__), *%w[.. init.rb])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def reset_safe_log_buddy_mode
|
24
|
+
ENV["SAFE_LOG_BUDDY"] = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -1,10 +1,4 @@
|
|
1
|
-
require
|
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"))
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), *%w[helper]))
|
8
2
|
|
9
3
|
module SomeModule
|
10
4
|
def self.say_something(name)
|
@@ -17,13 +11,8 @@ module SomeModule
|
|
17
11
|
end
|
18
12
|
|
19
13
|
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
14
|
describe "object extensions" do
|
26
|
-
it "mixes itself into Object
|
15
|
+
it "mixes itself into Object instance and class level by default" do
|
27
16
|
Object.expects(:include).with(LogBuddy::Mixin)
|
28
17
|
Object.expects(:extend).with(LogBuddy::Mixin)
|
29
18
|
LogBuddy.init
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: log_buddy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Sanheim - Relevance
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-30 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,18 +50,22 @@ extensions: []
|
|
50
50
|
|
51
51
|
extra_rdoc_files:
|
52
52
|
- CHANGELOG
|
53
|
-
- README.rdoc
|
54
53
|
- lib/log_buddy.rb
|
54
|
+
- LICENSE
|
55
|
+
- README.rdoc
|
55
56
|
files:
|
56
57
|
- CHANGELOG
|
57
|
-
- Manifest
|
58
|
-
- README.rdoc
|
59
|
-
- Rakefile
|
60
58
|
- examples.rb
|
61
59
|
- init.rb
|
62
60
|
- lib/log_buddy.rb
|
63
|
-
-
|
61
|
+
- LICENSE
|
64
62
|
- log_buddy.gemspec
|
63
|
+
- Manifest
|
64
|
+
- Rakefile
|
65
|
+
- README.rdoc
|
66
|
+
- spec/helper.rb
|
67
|
+
- spec/log_buddy_init_spec.rb
|
68
|
+
- spec/log_buddy_spec.rb
|
65
69
|
has_rdoc: true
|
66
70
|
homepage: http://opensource.thinkrelevance.com/wiki/log_buddy
|
67
71
|
post_install_message:
|
@@ -89,9 +93,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
93
|
requirements: []
|
90
94
|
|
91
95
|
rubyforge_project: thinkrelevance
|
92
|
-
rubygems_version: 1.
|
96
|
+
rubygems_version: 1.3.0
|
93
97
|
signing_key:
|
94
98
|
specification_version: 2
|
95
99
|
summary: Log Buddy is your little development buddy.
|
96
|
-
test_files:
|
97
|
-
|
100
|
+
test_files: []
|
101
|
+
|