hotdog 0.20.0 → 0.20.1
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.
- checksums.yaml +4 -4
- data/lib/hotdog/commands.rb +28 -14
- data/lib/hotdog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f6979e71063978d355744d1ee83f2f4abd31e87
|
4
|
+
data.tar.gz: dca259705e279dcc30dd7732df21efec91d89ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae9cd27a6872df2ccb09f885ccd57b3a98ab510b276d6f0a014021cee303ef83037893c5bc120288d96017cdeed55e6e9216807464a058673ba5775b196762a6
|
7
|
+
data.tar.gz: fc33569232c83c80ac0c4d48defeaa126adb30961539a2a0ff45ae0cd9fb7d4c9d1dd3954ebbef16eed165c05ac1a0aec951c53d409b2685560c0f59f4347b2d
|
data/lib/hotdog/commands.rb
CHANGED
@@ -204,24 +204,38 @@ module Hotdog
|
|
204
204
|
if @db
|
205
205
|
@db
|
206
206
|
else
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
rescue SQLite3::SQLException
|
217
|
-
if options[:offline]
|
218
|
-
raise(RuntimeError.new("no database available on offline mode"))
|
207
|
+
if options[:force]
|
208
|
+
@db = nil
|
209
|
+
else
|
210
|
+
if options[:offline]
|
211
|
+
@db = __open_db(options)
|
212
|
+
else
|
213
|
+
FileUtils.mkdir_p(File.dirname(persistent_db_path))
|
214
|
+
if File.exist?(persistent_db_path) and Time.new <= (File.mtime(persistent_db_path) + options[:expiry])
|
215
|
+
@db = __open_db(options)
|
219
216
|
else
|
220
|
-
|
217
|
+
@db = nil
|
221
218
|
end
|
222
219
|
end
|
223
220
|
end
|
224
|
-
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def __open_db(options={})
|
225
|
+
begin
|
226
|
+
persistent_db = SQLite3::Database.new(persistent_db_path)
|
227
|
+
persistent_db.execute("SELECT hosts_tags.host_id FROM hosts_tags INNER JOIN hosts ON hosts_tags.host_id = hosts.id INNER JOIN tags ON hosts_tags.tag_id = tags.id LIMIT 1;")
|
228
|
+
persistent_db
|
229
|
+
rescue SQLite3::BusyException
|
230
|
+
sleep(rand) # FIXME: configurable retry interval
|
231
|
+
retry
|
232
|
+
rescue SQLite3::SQLException
|
233
|
+
if options[:offline]
|
234
|
+
raise(RuntimeError.new("no database available on offline mode"))
|
235
|
+
else
|
236
|
+
persistent_db.close()
|
237
|
+
nil
|
238
|
+
end
|
225
239
|
end
|
226
240
|
end
|
227
241
|
|
data/lib/hotdog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotdog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|