sparrow 0.4 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ module Sparrow
8
8
  class SparrowError < StandardError #:nodoc:
9
9
  end
10
10
 
11
- VERSION = '0.4'
11
+ VERSION = '0.4.1'
12
12
 
13
13
  @@options = {}
14
14
 
@@ -37,9 +37,7 @@ module Sparrow
37
37
 
38
38
  def to_disk!
39
39
  copy = self.queue_data.dup
40
- copy.each do |value|
41
- self.sqlite.push(value)
42
- end
40
+ self.sqlite.insert(copy)
43
41
  self.queue_data = self.queue_data - copy
44
42
  end
45
43
 
@@ -49,9 +47,8 @@ module Sparrow
49
47
 
50
48
  def recover!
51
49
  logger.debug "Recovering queue"
52
- while msg = self.sqlite.pop
53
- self.push(msg)
54
- end
50
+ self.queue_data.concat(self.sqlite.all)
51
+ self.sqlite.clear!
55
52
  end
56
53
 
57
54
  def sqlite
@@ -49,6 +49,18 @@ module Sparrow
49
49
  db.execute("DELETE FROM queues")
50
50
  end
51
51
 
52
+ def all
53
+ db.execute("SELECT * FROM queues").collect {|v| v[1] }
54
+ end
55
+
56
+ def insert(values)
57
+ db.transaction do |d|
58
+ values.each do |v|
59
+ db.execute("INSERT INTO queues (data) VALUES (?)", v)
60
+ end
61
+ end
62
+ end
63
+
52
64
  private
53
65
 
54
66
  def db_path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparrow
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.4"
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex MacCAw