log_buddy 0.5.0 → 0.6.0

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/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use ruby-1.9.2-p0
data/CHANGELOG CHANGED
@@ -1,5 +1,8 @@
1
+ v0.6.0 Use Rails.logger if available - avoid deprecation warnings in Rails 3+
1
2
 
2
- v0.x.x. Overall cleanup and making things safer:
3
+ v0.5.1 init automatically unless SAFE_LOG_BUDDY (in ENV) is set
4
+
5
+ v0.5.0 Overall cleanup and making things safer:
3
6
  - move to Rspec2
4
7
  - move Version into the code base as a constant and out of yml
5
8
  - remove GemLoger
data/Rakefile CHANGED
@@ -11,8 +11,8 @@ begin
11
11
  gem.email = "rsanheim@gmail.com"
12
12
  gem.homepage = "http://github.com/relevance/log_buddy"
13
13
  gem.authors = ["Rob Sanheim"]
14
- gem.add_development_dependency "rspec", "~> 2.0.0.beta.8"
15
- gem.add_development_dependency "mocha", "~> 0.9.0"
14
+ gem.add_development_dependency "rspec", "~> 2.2"
15
+ gem.add_development_dependency "mocha", "~> 0.9"
16
16
  end
17
17
  Jeweler::GemcutterTasks.new
18
18
  rescue LoadError
@@ -5,7 +5,10 @@ require File.join(File.dirname(__FILE__), *%w[log_buddy version])
5
5
  =begin rdoc
6
6
  LogBuddy is a developer tool for easy logging while testing, debugging, and inspecting.
7
7
 
8
- The log shortcut method to give you easy, concise output of variables with their names and values.
8
+ The <tt>d</tt> log method to give you easy, concise output of variables with their names and values.
9
+
10
+ Requiring 'log_buddy' will _automatically_ mixin the <tt>d</tt> method into Object. You can avoid this
11
+ behavior by setting SAFE_LOG_BUDDY to true in your environment before requiring LogBuddy.
9
12
 
10
13
  Examples:
11
14
  a = "foo"
@@ -55,14 +58,24 @@ module LogBuddy
55
58
 
56
59
  private
57
60
 
61
+ # First try Rails.logger, then RAILS_DEFAULT_LOGGER (for older
62
+ # versions of Rails), then just use a STDOUT Logger
58
63
  def init_default_logger
59
- if Object.const_defined?("RAILS_DEFAULT_LOGGER")
60
- @logger = Object.const_get("RAILS_DEFAULT_LOGGER")
64
+ @logger = if rails_environment && rails_environment.respond_to?(:logger)
65
+ rails_environment.logger
66
+ elsif Object.const_defined?("RAILS_DEFAULT_LOGGER")
67
+ Object.const_get("RAILS_DEFAULT_LOGGER")
61
68
  else
62
69
  require 'logger'
63
- @logger = Logger.new(STDOUT)
70
+ Logger.new(STDOUT)
64
71
  end
65
72
  end
66
73
 
74
+ def rails_environment
75
+ Object.const_defined?("Rails") && Object.const_get("Rails")
76
+ end
77
+
67
78
  end
79
+
80
+ init unless ENV["SAFE_LOG_BUDDY"]
68
81
  end
@@ -1,7 +1,7 @@
1
1
  module LogBuddy
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 5
4
+ MINOR = 6
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -1,50 +1,49 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{log_buddy}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Rob Sanheim"]
12
- s.date = %q{2010-05-28}
12
+ s.date = %q{2010-12-06}
13
13
  s.description = %q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
14
14
  s.email = %q{rsanheim@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.markdown"
17
+ "README.markdown"
18
18
  ]
19
19
  s.files = [
20
- ".gitignore",
21
- ".treasure_map.rb",
22
- "CHANGELOG",
23
- "LICENSE",
24
- "README.markdown",
25
- "Rakefile",
26
- "examples.rb",
27
- "init.rb",
28
- "lib/log_buddy.rb",
29
- "lib/log_buddy/mixin.rb",
30
- "lib/log_buddy/utils.rb",
31
- "lib/log_buddy/version.rb",
32
- "log_buddy.gemspec",
33
- "spec/log_buddy/log_buddy_init_spec.rb",
34
- "spec/log_buddy/log_buddy_spec.rb",
35
- "spec/log_buddy/log_spec.rb",
36
- "spec/log_buddy/spec_helper.rb"
20
+ ".rvmrc",
21
+ ".treasure_map.rb",
22
+ "CHANGELOG",
23
+ "LICENSE",
24
+ "README.markdown",
25
+ "Rakefile",
26
+ "examples.rb",
27
+ "init.rb",
28
+ "lib/log_buddy.rb",
29
+ "lib/log_buddy/mixin.rb",
30
+ "lib/log_buddy/utils.rb",
31
+ "lib/log_buddy/version.rb",
32
+ "log_buddy.gemspec",
33
+ "spec/log_buddy/log_buddy_init_spec.rb",
34
+ "spec/log_buddy/log_buddy_spec.rb",
35
+ "spec/log_buddy/log_spec.rb",
36
+ "spec/log_buddy/spec_helper.rb"
37
37
  ]
38
38
  s.homepage = %q{http://github.com/relevance/log_buddy}
39
- s.rdoc_options = ["--charset=UTF-8"]
40
39
  s.require_paths = ["lib"]
41
40
  s.rubygems_version = %q{1.3.7}
42
41
  s.summary = %q{Log Buddy is your little development buddy.}
43
42
  s.test_files = [
44
43
  "spec/log_buddy/log_buddy_init_spec.rb",
45
- "spec/log_buddy/log_buddy_spec.rb",
46
- "spec/log_buddy/log_spec.rb",
47
- "spec/log_buddy/spec_helper.rb"
44
+ "spec/log_buddy/log_buddy_spec.rb",
45
+ "spec/log_buddy/log_spec.rb",
46
+ "spec/log_buddy/spec_helper.rb"
48
47
  ]
49
48
 
50
49
  if s.respond_to? :specification_version then
@@ -52,15 +51,15 @@ Gem::Specification.new do |s|
52
51
  s.specification_version = 3
53
52
 
54
53
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
56
- s.add_development_dependency(%q<mocha>, ["~> 0.9.0"])
54
+ s.add_development_dependency(%q<rspec>, ["~> 2.2"])
55
+ s.add_development_dependency(%q<mocha>, ["~> 0.9"])
57
56
  else
58
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
59
- s.add_dependency(%q<mocha>, ["~> 0.9.0"])
57
+ s.add_dependency(%q<rspec>, ["~> 2.2"])
58
+ s.add_dependency(%q<mocha>, ["~> 0.9"])
60
59
  end
61
60
  else
62
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
63
- s.add_dependency(%q<mocha>, ["~> 0.9.0"])
61
+ s.add_dependency(%q<rspec>, ["~> 2.2"])
62
+ s.add_dependency(%q<mocha>, ["~> 0.9"])
64
63
  end
65
64
  end
66
65
 
@@ -17,7 +17,7 @@ describe LogBuddy do
17
17
 
18
18
  def load_init
19
19
  silence_warnings do
20
- load File.join(File.dirname(__FILE__), *%w[.. .. init.rb])
20
+ load File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. init.rb]))
21
21
  end
22
22
  end
23
23
 
@@ -15,14 +15,35 @@ module SomeModule
15
15
  end
16
16
 
17
17
  describe LogBuddy::Mixin, " behavior" do
18
-
19
- it "uses RAILS_DEFAULT_LOGGER if its defined" do
20
- begin
21
- Object.const_set "RAILS_DEFAULT_LOGGER", stub_everything
22
- LogBuddy.init
23
- LogBuddy.logger.should == RAILS_DEFAULT_LOGGER
24
- ensure
25
- Object.send :remove_const, "RAILS_DEFAULT_LOGGER"
18
+
19
+ describe "init" do
20
+ context "Rails environment" do
21
+ it "uses Rails.logger first" do
22
+ begin
23
+ rails_logger = stub_everything
24
+ rails_const = mock("Rails const with logger", :logger => rails_logger)
25
+ Object.const_set "Rails", rails_const
26
+ LogBuddy.init
27
+ LogBuddy.logger.should == rails_logger
28
+ ensure
29
+ Object.send :remove_const, "Rails"
30
+ end
31
+ end
32
+
33
+ it "falls back to RAILS_DEFAULT_LOGGER if necessary" do
34
+ begin
35
+ rails_default_logger = stub_everything
36
+ rails_const = stub("Rails const without logger")
37
+ Object.const_set "Rails", rails_const
38
+ Object.const_set "RAILS_DEFAULT_LOGGER", rails_default_logger
39
+
40
+ LogBuddy.init
41
+ LogBuddy.logger.should == rails_default_logger
42
+ ensure
43
+ Object.send :remove_const, "Rails"
44
+ Object.send :remove_const, "RAILS_DEFAULT_LOGGER"
45
+ end
46
+ end
26
47
  end
27
48
  end
28
49
 
@@ -1,6 +1,6 @@
1
1
  require "logger"
2
- require "mocha"
3
2
  require "rspec"
3
+ require "mocha"
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "log_buddy"))
5
5
 
6
6
  def silence_warnings
@@ -11,10 +11,10 @@ ensure
11
11
  end
12
12
 
13
13
  Rspec.configure do |config|
14
- config.mock_with :mocha
15
- config.formatter = :documentation
14
+ config.filter_run :focused => true
15
+ config.run_all_when_everything_filtered = true
16
16
  config.color_enabled = true
17
17
  config.alias_example_to :fit, :focused => true
18
- config.filter_run :options => { :focused => true }
19
- config.run_all_when_everything_filtered = true
18
+ config.formatter = :documentation
19
+ config.mock_with :mocha
20
20
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_buddy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 5
7
+ - 6
9
8
  - 0
10
- version: 0.5.0
9
+ version: 0.6.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Rob Sanheim
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-05-28 00:00:00 -04:00
17
+ date: 2010-12-06 00:00:00 -06:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,14 +25,10 @@ dependencies:
26
25
  requirements:
27
26
  - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 62196467
30
28
  segments:
31
29
  - 2
32
- - 0
33
- - 0
34
- - beta
35
- - 8
36
- version: 2.0.0.beta.8
30
+ - 2
31
+ version: "2.2"
37
32
  type: :development
38
33
  version_requirements: *id001
39
34
  - !ruby/object:Gem::Dependency
@@ -44,12 +39,10 @@ dependencies:
44
39
  requirements:
45
40
  - - ~>
46
41
  - !ruby/object:Gem::Version
47
- hash: 59
48
42
  segments:
49
43
  - 0
50
44
  - 9
51
- - 0
52
- version: 0.9.0
45
+ version: "0.9"
53
46
  type: :development
54
47
  version_requirements: *id002
55
48
  description: Log statements along with their name easily. Mixin a logger everywhere when you need it.
@@ -62,7 +55,7 @@ extra_rdoc_files:
62
55
  - LICENSE
63
56
  - README.markdown
64
57
  files:
65
- - .gitignore
58
+ - .rvmrc
66
59
  - .treasure_map.rb
67
60
  - CHANGELOG
68
61
  - LICENSE
@@ -84,8 +77,8 @@ homepage: http://github.com/relevance/log_buddy
84
77
  licenses: []
85
78
 
86
79
  post_install_message:
87
- rdoc_options:
88
- - --charset=UTF-8
80
+ rdoc_options: []
81
+
89
82
  require_paths:
90
83
  - lib
91
84
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -93,7 +86,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
86
  requirements:
94
87
  - - ">="
95
88
  - !ruby/object:Gem::Version
96
- hash: 3
97
89
  segments:
98
90
  - 0
99
91
  version: "0"
@@ -102,7 +94,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
94
  requirements:
103
95
  - - ">="
104
96
  - !ruby/object:Gem::Version
105
- hash: 3
106
97
  segments:
107
98
  - 0
108
99
  version: "0"
data/.gitignore DELETED
@@ -1,7 +0,0 @@
1
- .tm_last_run_ruby
2
- *.log
3
- doc/*
4
- pkg/*
5
- coverage
6
- TAGS
7
- coverage/