omg 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/lib/omg.rb +36 -19
  3. data/omg.gemspec +2 -2
  4. metadata +4 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
data/lib/omg.rb CHANGED
@@ -1,26 +1,43 @@
1
+ require 'singleton'
1
2
  module Omg
2
- def self.debug(str)
3
- defined?(Rails) ? Rails.logger.debug(str) : $stdout.puts(str)
4
- end
5
-
6
- def omg!(obj=nil)
7
- Omg.debug('')
8
- Omg.debug('~~~~~~~~~~~~~~~~~~~~~~~~~~~')
9
- Omg.debug "OMG!"
10
- if obj
11
- Omg.debug obj.inspect
3
+ def omg!(*args)
4
+ logger = OmgLogger.instance
5
+ logger.log('')
6
+ logger.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~')
7
+ logger.log "OMG!"
8
+ if args.length > 0
9
+ args.each do |arg|
10
+ logger.log arg.inspect
11
+ end
12
12
  else
13
- Omg.debug "#{omg_method} called!"
13
+ logger.log "#{caller[1][/`([^']*)'/, 1]} called!"
14
14
  end
15
- Omg.debug('~~~~~~~~~~~~~~~~~~~~~~~~~~~')
16
- Omg.debug('')
15
+ logger.log('~~~~~~~~~~~~~~~~~~~~~~~~~~~')
16
+ logger.log('')
17
17
  end
18
+ end
19
+
20
+ Object.send(:include, Omg)
21
+
22
+ class OmgLogger
23
+ include Singleton
18
24
 
19
- private
25
+ def log_with(logger, method)
26
+ @logger = logger
27
+ @method = method
28
+ end
20
29
 
21
- def omg_method
22
- caller[1][/`([^']*)'/, 1]
30
+ def log(str)
31
+ if @logger && @method
32
+ @logger.send(@method.to_sym, str)
33
+ elsif defined?(Rails) && Rails.logger
34
+ if @method
35
+ Rails.logger.send(@method.to_sym, str)
36
+ else
37
+ Rails.logger.debug(str)
38
+ end
39
+ else
40
+ $stdout.puts(str)
41
+ end
23
42
  end
24
- end
25
-
26
- Object.send(:include, Omg)
43
+ end
data/omg.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{omg}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["philnash"]
12
- s.date = %q{2010-10-11}
12
+ s.date = %q{2010-10-21}
13
13
  s.description = %q{OMG debugging!}
14
14
  s.email = %q{philnash@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omg
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - philnash
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-11 00:00:00 +01:00
18
+ date: 2010-10-21 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21