FreedomCoder-esearchy 0.0.11 → 0.0.12

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.
Files changed (2) hide show
  1. data/lib/esearchy/logger.rb +31 -0
  2. metadata +2 -1
@@ -0,0 +1,31 @@
1
+ class Logger
2
+
3
+ def initialize(level, output)
4
+ @level = level
5
+ if output.class == IO
6
+ @device = output
7
+ else
8
+ @device = File.new(output, "a")
9
+ end
10
+ @device.sync = true
11
+ end
12
+ attr_accessor :level, :device
13
+
14
+ def puts(msg)
15
+ if @level > 1
16
+ begin
17
+ @device.puts clean(msg) + "\n"
18
+ rescue
19
+ Raise "Something went Wrong writing to [file|IO]"
20
+ end
21
+ end
22
+ end
23
+
24
+ def clean(msg)
25
+ msg.match(/\n|\r/) != nil ? msg.strip! : msg
26
+ end
27
+
28
+ def close
29
+ @device.close if @open
30
+ end
31
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: FreedomCoder-esearchy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias P. Brutti
@@ -71,6 +71,7 @@ files:
71
71
  - lib/esearchy/yahoo.rb
72
72
  - lib/esearchy/wcol.rb
73
73
  - lib/esearchy/useragent.rb
74
+ - lib/esearchy/logger.rb
74
75
  - README.rdoc
75
76
  has_rdoc: true
76
77
  homepage: http://freedomcoder.com.ar/esearchy