log_buddy 0.4.12 → 0.5.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/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+
2
+ v0.x.x. Overall cleanup and making things safer:
3
+ - move to Rspec2
4
+ - move Version into the code base as a constant and out of yml
5
+ - remove GemLoger
6
+ - don't mixin in a logger method to Object, ever -- too dangerous.
7
+ - fix issue where logged line goes away and raises exception (GH-2)
8
+
1
9
  v0.4.10 Switch to jeweler; remove dependencies that were superfluous
2
10
 
3
11
  v0.4.9 Added gem logging for debugging help when tracking down Gem activation errors
data/README.markdown CHANGED
@@ -1,10 +1,10 @@
1
1
  # LogBuddy
2
2
 
3
- ## DESCRIPTION:
3
+ ## DESCRIPTION
4
4
 
5
5
  log_buddy is your friendly little log buddy at your side, helping you dev, debug, and test.
6
6
 
7
- ## SYNOPSIS:
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
10
 
@@ -42,7 +42,7 @@ When you occasionally want to disable LogBuddy (but you don't want to have to re
42
42
 
43
43
  LogBuddy.init :disabled => true
44
44
 
45
- ## REQUIREMENTS:
45
+ ## REQUIREMENTS
46
46
 
47
47
  * Ruby 1.8.6 or JRuby (tested with 1.1RC3)
48
48
  * untested on Ruby versions before 1.8.6, but should work fine
@@ -52,7 +52,7 @@ When you occasionally want to disable LogBuddy (but you don't want to have to re
52
52
  * 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.
53
53
  * Don't even try using this in irb.
54
54
 
55
- ## INSTALL:
55
+ ## INSTALL
56
56
 
57
57
  sudo gem install log_buddy
58
58
 
@@ -61,10 +61,9 @@ When you occasionally want to disable LogBuddy (but you don't want to have to re
61
61
  * Log bugs, issues, and suggestions at Lighthouse: http://relevance.lighthouseapp.com/projects/19074-log-buddy/overview
62
62
  * View Source: http://github.com/relevance/log_buddy
63
63
  * Git clone Source: git://github.com/relevance/log_buddy.git
64
- * Continuous Integration: http://runcoderun.com/relevance/log_buddy
65
64
  * RDocs: http://thinkrelevance.rubyforge.org/log_buddy
66
65
 
67
- ## LICENSE:
66
+ ## LICENSE
68
67
 
69
68
  (The MIT License)
70
69
 
data/Rakefile CHANGED
@@ -1,51 +1,67 @@
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+
1
3
  begin
2
4
  require 'jeweler'
5
+ require 'log_buddy/version'
3
6
  Jeweler::Tasks.new do |gem|
4
7
  gem.name = "log_buddy"
8
+ gem.version = LogBuddy::Version::STRING
5
9
  gem.summary = %Q{Log Buddy is your little development buddy.}
6
10
  gem.description = %Q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
7
11
  gem.email = "rsanheim@gmail.com"
8
12
  gem.homepage = "http://github.com/relevance/log_buddy"
9
13
  gem.authors = ["Rob Sanheim"]
10
- gem.add_development_dependency "micronaut", ">= 0.3.0"
11
- gem.add_development_dependency "mocha", ">= 0.3.0"
14
+ gem.add_development_dependency "rspec", "~> 2.0.0.beta.8"
15
+ gem.add_development_dependency "mocha", "~> 0.9.0"
12
16
  end
13
17
  Jeweler::GemcutterTasks.new
14
18
  rescue LoadError
15
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
19
+ puts "Jeweler not available. Install it with: gem install jeweler"
16
20
  end
17
21
 
18
22
  begin
19
- require 'micronaut/rake_task'
23
+ require 'rspec/core/rake_task'
24
+
25
+ RSpec::Core::RakeTask.new(:spec)
20
26
 
21
- Micronaut::RakeTask.new(:examples) do |examples|
22
- examples.pattern = 'examples/**/*_example.rb'
23
- examples.ruby_opts << '-Ilib -Iexamples'
27
+ RSpec::Core::RakeTask.new(:coverage) do |spec|
28
+ spec.pattern = 'spec/**/*_spec.rb'
29
+ spec.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,/Library/Ruby/*,config/*" --text-summary --sort coverage]
30
+ spec.rcov = true
24
31
  end
25
-
26
- Micronaut::RakeTask.new(:rcov) do |examples|
27
- examples.pattern = 'examples/**/*_example.rb'
28
- examples.rcov_opts = %[-Ilib -Iexamples --exclude "gems/*,/Library/Ruby/*,config/*" --text-summary --sort coverage]
29
- examples.rcov = true
32
+
33
+ RubyVersions = %w[1.8.7 1.9.1 1.9.2]
34
+
35
+ desc "Run Rspec against multiple Rubies: #{RubyVersions.join(", ")}"
36
+ task :spec_all do
37
+ cmd = %[bash -c 'source ~/.rvm/scripts/rvm; rvm #{RubyVersions.join(",")} rake spec']
38
+ puts cmd
39
+ system %[bash -c 'source ~/.rvm/scripts/rvm; rvm #{RubyVersions.join(",")} rake spec']
30
40
  end
41
+
31
42
 
32
- task :default => [:check_dependencies, :rcov]
43
+ if RUBY_VERSION <= "1.8.7"
44
+ task :default => [:check_dependencies, :coverage]
45
+ else
46
+ task :default => [:check_dependencies, :spec]
47
+ end
33
48
  rescue LoadError => e
34
- puts "Micronaut not available to run tests. Install it with: sudo gem install spicycode-micronaut -s http://gems.github.com"
49
+ puts "Rspec not available to run tests. Install it with: gem install rspec --pre"
35
50
  puts e
36
51
  puts e.backtrace
37
52
  end
38
53
 
54
+ begin
55
+ %w{sdoc sdoc-helpers rdiscount}.each { |name| gem name }
56
+ require 'sdoc_helpers'
57
+ rescue LoadError => ex
58
+ puts "sdoc support not enabled:"
59
+ puts ex.inspect
60
+ end
61
+
39
62
  require 'rake/rdoctask'
40
63
  Rake::RDocTask.new do |rdoc|
41
- if File.exist?('VERSION.yml')
42
- require 'yaml'
43
- config = YAML.load(File.read('VERSION.yml'))
44
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
45
- else
46
- version = ""
47
- end
48
-
64
+ version = LogBuddy::Version::STRING
49
65
  rdoc.rdoc_dir = 'rdoc'
50
66
  rdoc.title = "log_buddy #{version}"
51
67
  rdoc.rdoc_files.include('README*')
@@ -19,13 +19,9 @@ module LogBuddy
19
19
  arguments.each do |arg|
20
20
  LogBuddy.arg_and_blk_debug(arg, blk)
21
21
  end
22
- rescue RuntimeError => e
22
+ rescue => e
23
23
  LogBuddy.debug "LogBuddy caught an exception: #{e.message}"
24
24
  end
25
25
  end
26
-
27
- def logger
28
- LogBuddy.logger
29
- end
30
26
  end
31
27
  end
@@ -1,8 +1,8 @@
1
1
  module LogBuddy
2
- module VERSION #:nodoc:
2
+ module Version #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 4
5
- TINY = 9
4
+ MINOR = 5
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/lib/log_buddy.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require File.join(File.dirname(__FILE__), *%w[log_buddy utils])
2
2
  require File.join(File.dirname(__FILE__), *%w[log_buddy mixin])
3
- require File.join(File.dirname(__FILE__), *%w[log_buddy gem_logger])
4
3
  require File.join(File.dirname(__FILE__), *%w[log_buddy version])
5
4
 
6
5
  =begin rdoc
@@ -28,14 +27,11 @@ module LogBuddy
28
27
  # tries to default to RAILS_DEFAULT_LOGGER, and then to a STDOUT logger).
29
28
  # * <tt):log_to_stdout</tt> - whether LogBuddy should _also_ log to STDOUT, very helpful for Autotest (default is +true+).
30
29
  # * <tt>:disabled</tt> - when true, LogBuddy will not produce any output
31
- # * <tt>:log_gems</tt> - log Gem activation process - useful for tracking down Gem activation errors (default is +false+)
32
30
  def self.init(options = {})
33
31
  @logger = options[:logger]
34
32
  @log_to_stdout = options.has_key?(:log_to_stdout) ? options[:log_to_stdout] : true
35
- @log_gems = options[:log_gems]
36
33
  @disabled = (options[:disabled] == true)
37
34
  mixin_to_object
38
- GemLogger.log_gems! if @log_gems
39
35
  end
40
36
 
41
37
  # Add the LogBuddy::Mixin to Object instance and class level.
data/log_buddy.gemspec CHANGED
@@ -1,12 +1,15 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{log_buddy}
5
- s.version = "0.4.12"
8
+ s.version = "0.5.0"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Rob Sanheim"]
9
- s.date = %q{2009-05-22}
12
+ s.date = %q{2010-05-28}
10
13
  s.description = %q{Log statements along with their name easily. Mixin a logger everywhere when you need it.}
11
14
  s.email = %q{rsanheim@gmail.com}
12
15
  s.extra_rdoc_files = [
@@ -20,45 +23,44 @@ Gem::Specification.new do |s|
20
23
  "LICENSE",
21
24
  "README.markdown",
22
25
  "Rakefile",
23
- "VERSION.yml",
24
26
  "examples.rb",
25
- "examples/log_buddy/example_helper.rb",
26
- "examples/log_buddy/gem_logger_example.rb",
27
- "examples/log_buddy/log_buddy_example.rb",
28
- "examples/log_buddy/log_buddy_init_example.rb",
29
- "examples/log_buddy/log_example.rb",
30
27
  "init.rb",
31
28
  "lib/log_buddy.rb",
32
- "lib/log_buddy/gem_logger.rb",
33
29
  "lib/log_buddy/mixin.rb",
34
30
  "lib/log_buddy/utils.rb",
35
31
  "lib/log_buddy/version.rb",
36
- "log_buddy.gemspec"
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
39
  s.rdoc_options = ["--charset=UTF-8"]
40
40
  s.require_paths = ["lib"]
41
- s.rubyforge_project = %q{thinkrelevance}
42
- s.rubygems_version = %q{1.3.3}
41
+ s.rubygems_version = %q{1.3.7}
43
42
  s.summary = %q{Log Buddy is your little development buddy.}
44
43
  s.test_files = [
45
- "examples/log_buddy/example_helper.rb",
46
- "examples/log_buddy/gem_logger_example.rb",
47
- "examples/log_buddy/log_buddy_example.rb",
48
- "examples/log_buddy/log_buddy_init_example.rb",
49
- "examples/log_buddy/log_example.rb"
44
+ "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"
50
48
  ]
51
49
 
52
50
  if s.respond_to? :specification_version then
53
51
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
54
52
  s.specification_version = 3
55
53
 
56
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
57
- s.add_development_dependency(%q<spicycode-micronaut>, [">= 0"])
54
+ 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"])
58
57
  else
59
- s.add_dependency(%q<spicycode-micronaut>, [">= 0"])
58
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
59
+ s.add_dependency(%q<mocha>, ["~> 0.9.0"])
60
60
  end
61
61
  else
62
- s.add_dependency(%q<spicycode-micronaut>, [">= 0"])
62
+ s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.8"])
63
+ s.add_dependency(%q<mocha>, ["~> 0.9.0"])
63
64
  end
64
65
  end
66
+
@@ -1,14 +1,9 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), *%w[spec_helper]))
2
2
 
3
3
  describe LogBuddy do
4
4
  describe "init" do
5
5
  after { reset_safe_log_buddy_mode }
6
6
 
7
- it "should call log_gems! if log_gems is true" do
8
- LogBuddy::GemLogger.expects(:log_gems!)
9
- LogBuddy.init :log_gems => true
10
- end
11
-
12
7
  it "doesnt mixin to object if SAFE_LOG_BUDDY is true" do
13
8
  LogBuddy.expects(:init).never
14
9
  ENV["SAFE_LOG_BUDDY"] = "true"
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), *%w[spec_helper]))
2
2
 
3
3
  describe LogBuddy do
4
4
 
@@ -9,20 +9,14 @@ describe LogBuddy do
9
9
  it "has stdout config option" do
10
10
  LogBuddy.should respond_to(:log_to_stdout?)
11
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
12
 
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
-
13
+ it "can override the default logger" do
14
+ file_logger = Logger.new "test.log"
15
+ LogBuddy.init :logger => file_logger
16
+ LogBuddy.logger.should == file_logger
17
+ end
18
+
19
+ describe "init" do
26
20
  it "defaults to log to stdout (as well as logger)" do
27
21
  LogBuddy.init
28
22
  LogBuddy.log_to_stdout?.should == true
@@ -33,5 +27,5 @@ describe LogBuddy do
33
27
  LogBuddy.log_to_stdout?.should == true
34
28
  end
35
29
  end
36
-
30
+
37
31
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), *%w[spec_helper]))
2
2
 
3
3
  module SomeModule
4
4
  def self.say_something(name)
@@ -20,23 +20,12 @@ describe LogBuddy::Mixin, " behavior" do
20
20
  begin
21
21
  Object.const_set "RAILS_DEFAULT_LOGGER", stub_everything
22
22
  LogBuddy.init
23
- Object.logger.should == RAILS_DEFAULT_LOGGER
23
+ LogBuddy.logger.should == RAILS_DEFAULT_LOGGER
24
24
  ensure
25
25
  Object.send :remove_const, "RAILS_DEFAULT_LOGGER"
26
26
  end
27
27
  end
28
28
 
29
- it "uses a plain STDOUT Ruby logger if there is no RAILS_DEFAULT_LOGGER" do
30
- LogBuddy.init
31
- Object.logger.should == LogBuddy.logger
32
- end
33
-
34
- it "can override the default logger" do
35
- file_logger = Logger.new "test.log"
36
- LogBuddy.init :logger => file_logger
37
- Object.logger.should == file_logger
38
- end
39
-
40
29
  describe "outputting the code being logged and its result" do
41
30
  before { LogBuddy.init :log_to_stdout => false }
42
31
  it "should log to default logger" do
@@ -101,11 +90,6 @@ describe LogBuddy::Mixin, " behavior" do
101
90
  d { local1; local2; @ivar1 }
102
91
  end
103
92
 
104
- it "should gracefully handle runtimer errors" do
105
- LogBuddy.expects(:debug).with('LogBuddy caught an exception: RuntimeError')
106
- d { SomeModule.raise_runtime_error }
107
- end
108
-
109
93
  it "logs things okay with inline rdoc" do
110
94
  LogBuddy.stubs(:debug)
111
95
  hsh = {:foo=>"bar", "key"=>"value"}
@@ -122,6 +106,22 @@ describe LogBuddy::Mixin, " behavior" do
122
106
  d { hsh }
123
107
  end
124
108
 
109
+ describe "error cases" do
110
+
111
+ it "should gracefully handle runtimer errors" do
112
+ LogBuddy.expects(:debug).with('LogBuddy caught an exception: RuntimeError')
113
+ d { SomeModule.raise_runtime_error }
114
+ end
115
+
116
+ it "gracefully handles case where the line of code is empty" do
117
+ LogBuddy.expects(:read_line).returns("")
118
+ lambda {
119
+ d { SomeModule.raise_runtime_error }
120
+ }.should_not raise_error
121
+ end
122
+ end
123
+
124
+
125
125
  end
126
126
 
127
127
  describe "obj_to_string" do
@@ -1,6 +1,6 @@
1
- require 'logger'
1
+ require "logger"
2
2
  require "mocha"
3
- require 'micronaut'
3
+ require "rspec"
4
4
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "log_buddy"))
5
5
 
6
6
  def silence_warnings
@@ -10,10 +10,11 @@ ensure
10
10
  $VERBOSE = old_verbose
11
11
  end
12
12
 
13
- Micronaut.configure do |config|
13
+ Rspec.configure do |config|
14
14
  config.mock_with :mocha
15
15
  config.formatter = :documentation
16
16
  config.color_enabled = true
17
17
  config.alias_example_to :fit, :focused => true
18
18
  config.filter_run :options => { :focused => true }
19
+ config.run_all_when_everything_filtered = true
19
20
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_buddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.12
4
+ hash: 11
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Rob Sanheim
@@ -9,19 +15,43 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-05-22 00:00:00 -04:00
18
+ date: 2010-05-28 00:00:00 -04:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
- name: spicycode-micronaut
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 62196467
30
+ segments:
31
+ - 2
32
+ - 0
33
+ - 0
34
+ - beta
35
+ - 8
36
+ version: 2.0.0.beta.8
17
37
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: mocha
41
+ prerelease: false
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ none: false
20
44
  requirements:
21
- - - ">="
45
+ - - ~>
22
46
  - !ruby/object:Gem::Version
23
- version: "0"
24
- version:
47
+ hash: 59
48
+ segments:
49
+ - 0
50
+ - 9
51
+ - 0
52
+ version: 0.9.0
53
+ type: :development
54
+ version_requirements: *id002
25
55
  description: Log statements along with their name easily. Mixin a logger everywhere when you need it.
26
56
  email: rsanheim@gmail.com
27
57
  executables: []
@@ -38,20 +68,17 @@ files:
38
68
  - LICENSE
39
69
  - README.markdown
40
70
  - Rakefile
41
- - VERSION.yml
42
71
  - examples.rb
43
- - examples/log_buddy/example_helper.rb
44
- - examples/log_buddy/gem_logger_example.rb
45
- - examples/log_buddy/log_buddy_example.rb
46
- - examples/log_buddy/log_buddy_init_example.rb
47
- - examples/log_buddy/log_example.rb
48
72
  - init.rb
49
73
  - lib/log_buddy.rb
50
- - lib/log_buddy/gem_logger.rb
51
74
  - lib/log_buddy/mixin.rb
52
75
  - lib/log_buddy/utils.rb
53
76
  - lib/log_buddy/version.rb
54
77
  - log_buddy.gemspec
78
+ - spec/log_buddy/log_buddy_init_spec.rb
79
+ - spec/log_buddy/log_buddy_spec.rb
80
+ - spec/log_buddy/log_spec.rb
81
+ - spec/log_buddy/spec_helper.rb
55
82
  has_rdoc: true
56
83
  homepage: http://github.com/relevance/log_buddy
57
84
  licenses: []
@@ -62,27 +89,32 @@ rdoc_options:
62
89
  require_paths:
63
90
  - lib
64
91
  required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
65
93
  requirements:
66
94
  - - ">="
67
95
  - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
68
99
  version: "0"
69
- version:
70
100
  required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
71
102
  requirements:
72
103
  - - ">="
73
104
  - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
74
108
  version: "0"
75
- version:
76
109
  requirements: []
77
110
 
78
- rubyforge_project: thinkrelevance
79
- rubygems_version: 1.3.5
111
+ rubyforge_project:
112
+ rubygems_version: 1.3.7
80
113
  signing_key:
81
114
  specification_version: 3
82
115
  summary: Log Buddy is your little development buddy.
83
116
  test_files:
84
- - examples/log_buddy/example_helper.rb
85
- - examples/log_buddy/gem_logger_example.rb
86
- - examples/log_buddy/log_buddy_example.rb
87
- - examples/log_buddy/log_buddy_init_example.rb
88
- - examples/log_buddy/log_example.rb
117
+ - spec/log_buddy/log_buddy_init_spec.rb
118
+ - spec/log_buddy/log_buddy_spec.rb
119
+ - spec/log_buddy/log_spec.rb
120
+ - spec/log_buddy/spec_helper.rb
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 4
4
- :patch: 12
@@ -1,49 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), *%w[example_helper]))
2
-
3
- describe LogBuddy::GemLogger do
4
-
5
- describe "starting Gem logging" do
6
-
7
- it "includes GemLogger into Gem when #log_gems! is called" do
8
- Gem.expects(:include).with(LogBuddy::GemLogger)
9
- LogBuddy::GemLogger.log_gems!
10
- end
11
-
12
- end
13
-
14
- if RUBY_VERSION != '1.9.1'
15
-
16
- describe "Gem#activation monkey patching for logging" do
17
-
18
- before do
19
- LogBuddy.init
20
- LogBuddy::GemLogger.log_gems!
21
- end
22
-
23
- it "should log the gem name and version and where it was called from" do
24
- Gem.stubs(:activate_without_logging)
25
-
26
- LogBuddy.expects(:debug).with do |msg|
27
- msg.should include(%[Gem activation for gem: 'gem-name' version: '0.5' called from:\n])
28
- gem_calling_line = __LINE__ + 3
29
- msg.should include(%[examples/log_buddy/gem_logger_example.rb:#{gem_calling_line}])
30
- end
31
- gem "gem-name", "0.5"
32
- end
33
-
34
- it "should do the original gem activation call" do
35
- LogBuddy.stubs(:debug)
36
- Gem.expects(:activate_without_logging).with('gem-name', ">= 1.0.0")
37
- gem "gem-name", ">= 1.0.0"
38
- end
39
-
40
- it "should add alias gem_without_logging" do
41
- Gem.should respond_to(:activate)
42
- Gem.should respond_to(:activate_without_logging)
43
- end
44
-
45
- end
46
-
47
- end
48
-
49
- end
@@ -1,24 +0,0 @@
1
- module LogBuddy
2
- module GemLogger
3
-
4
- BACKTRACE_SIZE = 0..5
5
-
6
- def self.log_gems!
7
- ::Gem.send :include, LogBuddy::GemLogger
8
- end
9
-
10
- def self.included(mod)
11
-
12
- class << mod
13
- def activate_with_logging(gem, *version_requirements)
14
- d %[Gem activation for gem: '#{gem}' version: '#{version_requirements}' called from:\n#{caller[BACKTRACE_SIZE].join("\n")}]
15
- activate_without_logging(gem, *version_requirements)
16
- end
17
-
18
- alias_method :activate_without_logging, :activate
19
- alias_method :activate, :activate_with_logging
20
- end
21
-
22
- end
23
- end
24
- end