lloydpick-toast 0.0.2 → 0.0.3

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/toast.rb +7 -8
  2. metadata +1 -1
data/lib/toast.rb CHANGED
@@ -63,14 +63,14 @@ module Toast
63
63
  end
64
64
 
65
65
  def toast!
66
- File.delete("toast.db")
66
+ #File.delete("toast.db")
67
67
  db = SQLite3::Database.new("toast.db")
68
68
  db.execute("CREATE TABLE IF NOT EXISTS toasters (
69
69
  id integer PRIMARY KEY,
70
70
  frequency integer,
71
71
  last_check datetime,
72
72
  conditions varchar2(32),
73
- complete boolean
73
+ complete integer
74
74
  );")
75
75
  db.execute("CREATE TABLE IF NOT EXISTS breads (
76
76
  id integer PRIMARY KEY,
@@ -143,7 +143,7 @@ module Toast
143
143
  ",
144
144
  "frequency" => self.timer,
145
145
  "conditions" => butters.join(","),
146
- "complete" => false,
146
+ "complete" => 0,
147
147
  "last_check" => Time.now
148
148
  );
149
149
 
@@ -155,7 +155,7 @@ module Toast
155
155
  db = SQLite3::Database.new("toast.db")
156
156
 
157
157
  db.results_as_hash = true
158
- db.execute("select * from toasters where complete = 'false'") do |row|
158
+ db.execute("select * from toasters where complete = 0") do |row|
159
159
  if ((Time.parse(row["last_check"]) + row["frequency"].to_i) < Time.now)
160
160
  row["conditions"].split(",")
161
161
  row["conditions"].each do |condition|
@@ -166,13 +166,12 @@ module Toast
166
166
  httpauth = Twitter::HTTPAuth.new(twitter["twitter_username"], twitter["twitter_password"])
167
167
  base = Twitter::Base.new(httpauth)
168
168
  base.update(twitter["twitter_message"])
169
- db.execute("update toasters set last_check = :last_check and complete = :outcome where id = :id",
170
- "last_check" => Time.now, "id" => row["id"], "outcome" => true)
169
+ db.execute("update toasters set complete = \"1\" where id = :id;", "id" => row["id"])
171
170
  end
172
171
  else
173
172
  # Did'nt pass the condition, so update the time
174
- db.execute("update toasters set last_check = :last_check where id = :id",
175
- "last_check" => Time.now, "id" => row["id"])
173
+ db.execute("update toasters set last_check = :lastcheck where id = :id",
174
+ "lastcheck" => Time.now, "id" => row["id"])
176
175
  end
177
176
  end
178
177
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lloydpick-toast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lloyd Pick