blooper 1.6 → 1.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -18,7 +18,7 @@ The idea is shamelessly stolen from {logmysqldaemon}[http://sourceforge.net/proj
18
18
  access_log daemon:{adapter:postgres,database:squid,username:squid,password:squid,host:db} squid_log
19
19
  logfile_daemon /usr/local/bin/blooper
20
20
 
21
- 1. The column names are dynamic, here time is a column name, %{%Y-%m-%d_%H:%M:%S%z} is a value that will be written into that column.
21
+ 1. The column names are dynamic, here time is a column name, {%{%Y-%m-%d_%H:%M:%S%z}}[http://www.squid-cache.org/Versions/v3/3.2/cfgman/logformat.html] is a value that will be written into that column.
22
22
 
23
23
  2. The second string contains database access information, the credential depends on {adapter}[http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html], tested only with postgres.
24
24
 
data/lib/blooper.rb CHANGED
@@ -4,7 +4,7 @@ BLOOPER_VERSION = Blooper::VERSION
4
4
  require 'blooper/db.rb'
5
5
  require 'blooper/input.rb'
6
6
  require 'blooper/line.rb'
7
- require 'blooper/rows.rb'
7
+ require 'blooper/tuple.rb'
8
8
 
9
9
  module Blooper
10
10
 
data/lib/blooper/input.rb CHANGED
@@ -8,7 +8,7 @@ module Blooper
8
8
  def each
9
9
  @input.each do |line|
10
10
  line = Line.new(line)
11
- yield Rows.new(line.clean) if line.valid?
11
+ yield Tuple.new(line.clean) if line.valid?
12
12
  end
13
13
  end
14
14
 
@@ -0,0 +1,18 @@
1
+ module Blooper
2
+ class Tuple
3
+
4
+ def initialize(line)
5
+ @line = line
6
+ end
7
+
8
+ def tuples
9
+ h = Hash[*@line.split]
10
+ h.merge(h) {|k,v| v.eql?('-') ? nil : v}
11
+ end
12
+
13
+ def save
14
+ DB.instance.insert(tuples)
15
+ end
16
+
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Blooper
2
- VERSION = "1.6" unless defined?(Blooper::VERSION)
2
+ VERSION = "1.7" unless defined?(Blooper::VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blooper
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.6'
4
+ version: '1.7'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -70,7 +70,7 @@ files:
70
70
  - lib/blooper.rb
71
71
  - lib/blooper/input.rb
72
72
  - lib/blooper/line.rb
73
- - lib/blooper/rows.rb
73
+ - lib/blooper/tuple.rb
74
74
  - lib/blooper/db.rb
75
75
  - lib/blooper/version.rb
76
76
  - COPYING
data/lib/blooper/rows.rb DELETED
@@ -1,17 +0,0 @@
1
- module Blooper
2
- class Rows
3
-
4
- def initialize(line = STDIN)
5
- @line = line
6
- end
7
-
8
- def rows
9
- Hash[*@line.split]
10
- end
11
-
12
- def save
13
- DB.instance.insert(rows)
14
- end
15
-
16
- end
17
- end