hotdog 0.20.1 → 0.21.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f6979e71063978d355744d1ee83f2f4abd31e87
4
- data.tar.gz: dca259705e279dcc30dd7732df21efec91d89ed5
3
+ metadata.gz: 3b865a57629931368bc2cc6aff14de44286c76f0
4
+ data.tar.gz: b78e6691723f194e974976f62d592b10e01b9b19
5
5
  SHA512:
6
- metadata.gz: ae9cd27a6872df2ccb09f885ccd57b3a98ab510b276d6f0a014021cee303ef83037893c5bc120288d96017cdeed55e6e9216807464a058673ba5775b196762a6
7
- data.tar.gz: fc33569232c83c80ac0c4d48defeaa126adb30961539a2a0ff45ae0cd9fb7d4c9d1dd3954ebbef16eed165c05ac1a0aec951c53d409b2685560c0f59f4347b2d
6
+ metadata.gz: 46feecc3f4b76165991280530fbaefb49265d06b8cbaf1ef3950bfc262f2c704fe058032e7ea8305dbd94835c1a07dec4c79431ca9257ef78cdd917f87172ce2
7
+ data.tar.gz: 6a3b4b5cc69f23aae701709a20ef63141ab90a46273dc22b3c721016f19e7dc049a1d2b9559536af4f18ec4cd1da02c12088369882f42c3324162ff1151ed730
data/.travis.yml CHANGED
@@ -3,6 +3,7 @@ rvm:
3
3
  - 2.1.10
4
4
  - 2.2.6
5
5
  - 2.3.3
6
+ - 2.4.0
6
7
  script:
7
8
  - rspec spec
8
9
  sudo: false
data/hotdog.gemspec CHANGED
@@ -21,7 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "rubocop"
25
24
 
26
25
  spec.add_dependency "dogapi"
27
26
  spec.add_dependency "multi_json"
@@ -12,7 +12,6 @@ require "uri"
12
12
  module Hotdog
13
13
  module Commands
14
14
  class BaseCommand
15
- PERSISTENT_DB = "persistent.db"
16
15
  MASK_DATABASE = 0xffff0000
17
16
  MASK_QUERY = 0x0000ffff
18
17
 
@@ -22,10 +21,12 @@ module Hotdog
22
21
  @options = application.options
23
22
  @dog = nil # lazy initialization
24
23
  @prepared_statements = {}
24
+ @persistent_db_path = File.join(@options.fetch(:confdir, "."), "persistent.db")
25
25
  end
26
26
  attr_reader :application
27
27
  attr_reader :logger
28
28
  attr_reader :options
29
+ attr_reader :persistent_db_path
29
30
 
30
31
  def run(args=[], options={})
31
32
  raise(NotImplementedError)
@@ -223,19 +224,15 @@ module Hotdog
223
224
 
224
225
  def __open_db(options={})
225
226
  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
227
+ db = SQLite3::Database.new(persistent_db_path)
228
+ 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;")
229
+ db
229
230
  rescue SQLite3::BusyException
230
231
  sleep(rand) # FIXME: configurable retry interval
231
232
  retry
232
233
  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
234
+ db.close()
235
+ nil
239
236
  end
240
237
  end
241
238
 
@@ -244,13 +241,17 @@ module Hotdog
244
241
  if open_db(options)
245
242
  @db
246
243
  else
247
- memory_db = create_db(SQLite3::Database.new(":memory:"), options)
248
- # backup in-memory db to file
249
- FileUtils.mkdir_p(File.dirname(persistent_db_path))
250
- persistent_db = SQLite3::Database.new(persistent_db_path)
251
- copy_db(memory_db, persistent_db)
252
- close_db(memory_db)
253
- @db = persistent_db
244
+ if options[:offline]
245
+ abort("could not update database on offline mode")
246
+ else
247
+ memory_db = create_db(SQLite3::Database.new(":memory:"), options)
248
+ # backup in-memory db to file
249
+ FileUtils.mkdir_p(File.dirname(persistent_db_path))
250
+ db = SQLite3::Database.new(persistent_db_path)
251
+ copy_db(memory_db, db)
252
+ close_db(memory_db)
253
+ @db = db
254
+ end
254
255
  end
255
256
  end
256
257
 
@@ -420,10 +421,6 @@ module Hotdog
420
421
  end
421
422
  raise("retry count exceeded")
422
423
  end
423
-
424
- def persistent_db_path()
425
- File.join(options[:confdir], PERSISTENT_DB)
426
- end
427
424
  end
428
425
  end
429
426
  end
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.20.1"
2
+ VERSION = "0.21.0"
3
3
  end
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.1
4
+ version: 0.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yamashita Yuu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-04 00:00:00.000000000 Z
11
+ date: 2017-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: dogapi
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -159,8 +145,6 @@ extensions: []
159
145
  extra_rdoc_files: []
160
146
  files:
161
147
  - ".gitignore"
162
- - ".rubocop.yml"
163
- - ".rubocop_todo.yml"
164
148
  - ".travis.yml"
165
149
  - Gemfile
166
150
  - LICENSE.txt
@@ -237,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
221
  version: '0'
238
222
  requirements: []
239
223
  rubyforge_project:
240
- rubygems_version: 2.5.2
224
+ rubygems_version: 2.6.8
241
225
  signing_key:
242
226
  specification_version: 4
243
227
  summary: Yet another command-line tool for Datadog
data/.rubocop.yml DELETED
@@ -1 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
data/.rubocop_todo.yml DELETED
@@ -1,400 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2016-01-07 02:10:16 +0000 using RuboCop version 0.35.1.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 17
10
- Lint/ShadowingOuterLocalVariable:
11
- Exclude:
12
- - 'lib/hotdog/commands.rb'
13
- - 'lib/hotdog/commands/hosts.rb'
14
- - 'lib/hotdog/commands/search.rb'
15
- - 'lib/hotdog/commands/tags.rb'
16
-
17
- # Offense count: 70
18
- # Cop supports --auto-correct.
19
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
20
- Lint/UnusedMethodArgument:
21
- Exclude:
22
- - 'lib/hotdog/commands.rb'
23
- - 'lib/hotdog/commands/help.rb'
24
- - 'lib/hotdog/commands/hosts.rb'
25
- - 'lib/hotdog/commands/search.rb'
26
- - 'lib/hotdog/commands/ssh.rb'
27
- - 'lib/hotdog/commands/tags.rb'
28
- - 'lib/hotdog/commands/version.rb'
29
- - 'lib/hotdog/formatters.rb'
30
- - 'lib/hotdog/formatters/plain.rb'
31
-
32
- # Offense count: 28
33
- Metrics/AbcSize:
34
- Max: 151
35
-
36
- # Offense count: 8
37
- Metrics/BlockNesting:
38
- Max: 7
39
-
40
- # Offense count: 8
41
- # Configuration parameters: CountComments.
42
- Metrics/ClassLength:
43
- Max: 291
44
-
45
- # Offense count: 15
46
- Metrics/CyclomaticComplexity:
47
- Max: 15
48
-
49
- # Offense count: 276
50
- # Configuration parameters: AllowURI, URISchemes.
51
- Metrics/LineLength:
52
- Max: 215
53
-
54
- # Offense count: 38
55
- # Configuration parameters: CountComments.
56
- Metrics/MethodLength:
57
- Max: 87
58
-
59
- # Offense count: 18
60
- Metrics/PerceivedComplexity:
61
- Max: 18
62
-
63
- # Offense count: 1
64
- Style/AccessorMethodName:
65
- Exclude:
66
- - 'lib/hotdog/commands.rb'
67
-
68
- # Offense count: 52
69
- # Cop supports --auto-correct.
70
- Style/AlignArray:
71
- Exclude:
72
- - 'spec/core/commands_spec.rb'
73
- - 'spec/parser/glob_expression_spec.rb'
74
- - 'spec/parser/regexp_expression_spec.rb'
75
- - 'spec/parser/string_expression_spec.rb'
76
-
77
- # Offense count: 43
78
- # Cop supports --auto-correct.
79
- # Configuration parameters: EnforcedStyle, SupportedStyles.
80
- Style/AndOr:
81
- Exclude:
82
- - 'lib/hotdog/application.rb'
83
- - 'lib/hotdog/commands.rb'
84
- - 'lib/hotdog/commands/search.rb'
85
- - 'lib/hotdog/commands/ssh.rb'
86
- - 'lib/hotdog/commands/tags.rb'
87
- - 'lib/hotdog/commands/up.rb'
88
- - 'lib/hotdog/formatters.rb'
89
- - 'lib/hotdog/formatters/csv.rb'
90
- - 'lib/hotdog/formatters/json.rb'
91
- - 'lib/hotdog/formatters/plain.rb'
92
- - 'lib/hotdog/formatters/tsv.rb'
93
- - 'lib/hotdog/formatters/yaml.rb'
94
-
95
- # Offense count: 123
96
- # Cop supports --auto-correct.
97
- # Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
98
- Style/BlockDelimiters:
99
- Enabled: false
100
-
101
- # Offense count: 77
102
- # Cop supports --auto-correct.
103
- # Configuration parameters: EnforcedStyle, SupportedStyles.
104
- Style/BracesAroundHashParameters:
105
- Exclude:
106
- - 'spec/parser/glob_expression_spec.rb'
107
- - 'spec/parser/parser_spec.rb'
108
- - 'spec/parser/regexp_expression_spec.rb'
109
- - 'spec/parser/string_expression_spec.rb'
110
-
111
- # Offense count: 18
112
- Style/CaseEquality:
113
- Exclude:
114
- - 'lib/hotdog/application.rb'
115
- - 'lib/hotdog/commands/search.rb'
116
-
117
- # Offense count: 15
118
- # Cop supports --auto-correct.
119
- Style/DefWithParentheses:
120
- Exclude:
121
- - 'lib/hotdog/application.rb'
122
- - 'lib/hotdog/commands.rb'
123
- - 'lib/hotdog/commands/help.rb'
124
- - 'lib/hotdog/commands/search.rb'
125
- - 'lib/hotdog/formatters.rb'
126
-
127
- # Offense count: 1
128
- # Cop supports --auto-correct.
129
- Style/DeprecatedHashMethods:
130
- Exclude:
131
- - 'lib/hotdog/application.rb'
132
-
133
- # Offense count: 49
134
- # Configuration parameters: Exclude.
135
- Style/Documentation:
136
- Enabled: false
137
-
138
- # Offense count: 13
139
- # Cop supports --auto-correct.
140
- # Configuration parameters: EnforcedStyle, SupportedStyles.
141
- Style/EmptyElse:
142
- Exclude:
143
- - 'lib/hotdog/application.rb'
144
- - 'lib/hotdog/commands.rb'
145
- - 'lib/hotdog/commands/search.rb'
146
-
147
- # Offense count: 9
148
- # Cop supports --auto-correct.
149
- Style/EmptyLinesAroundAccessModifier:
150
- Exclude:
151
- - 'lib/hotdog/application.rb'
152
- - 'lib/hotdog/commands.rb'
153
- - 'lib/hotdog/commands/help.rb'
154
- - 'lib/hotdog/commands/pssh.rb'
155
- - 'lib/hotdog/commands/search.rb'
156
- - 'lib/hotdog/commands/ssh.rb'
157
- - 'lib/hotdog/formatters.rb'
158
-
159
- # Offense count: 23
160
- # Cop supports --auto-correct.
161
- # Configuration parameters: EnforcedStyle, SupportedStyles.
162
- Style/FirstParameterIndentation:
163
- Exclude:
164
- - 'spec/optparse/down_spec.rb'
165
- - 'spec/optparse/hosts_spec.rb'
166
- - 'spec/optparse/pssh_spec.rb'
167
- - 'spec/optparse/search_spec.rb'
168
- - 'spec/optparse/ssh_spec.rb'
169
- - 'spec/optparse/tags_spec.rb'
170
- - 'spec/optparse/up_spec.rb'
171
-
172
- # Offense count: 20
173
- # Configuration parameters: EnforcedStyle, SupportedStyles.
174
- Style/FormatString:
175
- Exclude:
176
- - 'lib/hotdog/commands.rb'
177
- - 'lib/hotdog/commands/down.rb'
178
- - 'lib/hotdog/commands/hosts.rb'
179
- - 'lib/hotdog/commands/search.rb'
180
- - 'lib/hotdog/commands/ssh.rb'
181
- - 'lib/hotdog/commands/tags.rb'
182
- - 'lib/hotdog/commands/up.rb'
183
-
184
- # Offense count: 3
185
- # Configuration parameters: AllowedVariables.
186
- Style/GlobalVars:
187
- Exclude:
188
- - 'lib/hotdog/commands/search.rb'
189
-
190
- # Offense count: 2
191
- # Configuration parameters: MinBodyLength.
192
- Style/GuardClause:
193
- Exclude:
194
- - 'lib/hotdog/commands/ssh.rb'
195
-
196
- # Offense count: 3
197
- # Cop supports --auto-correct.
198
- # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
199
- Style/HashSyntax:
200
- Enabled: false
201
-
202
- # Offense count: 13
203
- # Cop supports --auto-correct.
204
- # Configuration parameters: MaxLineLength.
205
- Style/IfUnlessModifier:
206
- Exclude:
207
- - 'lib/hotdog/application.rb'
208
- - 'lib/hotdog/commands/down.rb'
209
- - 'lib/hotdog/commands/ssh.rb'
210
- - 'lib/hotdog/commands/up.rb'
211
-
212
- # Offense count: 1
213
- # Cop supports --auto-correct.
214
- Style/Lambda:
215
- Exclude:
216
- - 'lib/hotdog/commands/search.rb'
217
-
218
- # Offense count: 3
219
- # Cop supports --auto-correct.
220
- # Configuration parameters: EnforcedStyle, SupportedStyles.
221
- Style/LambdaCall:
222
- Enabled: false
223
-
224
- # Offense count: 2
225
- # Cop supports --auto-correct.
226
- Style/LeadingCommentSpace:
227
- Exclude:
228
- - 'bin/hotdog'
229
-
230
- # Offense count: 12
231
- # Cop supports --auto-correct.
232
- Style/MethodCallParentheses:
233
- Exclude:
234
- - 'lib/hotdog/commands.rb'
235
- - 'lib/hotdog/commands/search.rb'
236
- - 'lib/hotdog/commands/up.rb'
237
-
238
- # Offense count: 7
239
- Style/MultilineBlockChain:
240
- Exclude:
241
- - 'lib/hotdog/commands.rb'
242
- - 'lib/hotdog/commands/search.rb'
243
- - 'lib/hotdog/commands/ssh.rb'
244
-
245
- # Offense count: 1
246
- # Cop supports --auto-correct.
247
- Style/NegatedIf:
248
- Exclude:
249
- - 'lib/hotdog/commands.rb'
250
-
251
- # Offense count: 1
252
- # Cop supports --auto-correct.
253
- # Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles.
254
- Style/Next:
255
- Exclude:
256
- - 'lib/hotdog/commands/ssh.rb'
257
-
258
- # Offense count: 3
259
- # Cop supports --auto-correct.
260
- Style/Not:
261
- Exclude:
262
- - 'lib/hotdog/commands.rb'
263
- - 'lib/hotdog/commands/search.rb'
264
-
265
- # Offense count: 4
266
- # Cop supports --auto-correct.
267
- Style/NumericLiterals:
268
- MinDigits: 6
269
-
270
- # Offense count: 2
271
- # Cop supports --auto-correct.
272
- # Configuration parameters: PreferredDelimiters.
273
- Style/PercentLiteralDelimiters:
274
- Exclude:
275
- - 'hotdog.gemspec'
276
-
277
- # Offense count: 13
278
- # Configuration parameters: EnforcedStyle, SupportedStyles.
279
- Style/RaiseArgs:
280
- Enabled: false
281
-
282
- # Offense count: 1
283
- # Cop supports --auto-correct.
284
- Style/RedundantBegin:
285
- Exclude:
286
- - 'lib/hotdog/commands.rb'
287
-
288
- # Offense count: 2
289
- # Cop supports --auto-correct.
290
- Style/RedundantSelf:
291
- Exclude:
292
- - 'lib/hotdog/commands/search.rb'
293
-
294
- # Offense count: 1
295
- # Cop supports --auto-correct.
296
- # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
297
- Style/RegexpLiteral:
298
- Exclude:
299
- - 'lib/hotdog/commands/search.rb'
300
-
301
- # Offense count: 17
302
- # Cop supports --auto-correct.
303
- # Configuration parameters: EnforcedStyle, SupportedStyles.
304
- Style/SignalException:
305
- Exclude:
306
- - 'lib/hotdog/application.rb'
307
- - 'lib/hotdog/commands.rb'
308
- - 'lib/hotdog/commands/down.rb'
309
- - 'lib/hotdog/commands/search.rb'
310
- - 'lib/hotdog/commands/ssh.rb'
311
- - 'lib/hotdog/commands/up.rb'
312
- - 'lib/hotdog/formatters.rb'
313
-
314
- # Offense count: 158
315
- # Cop supports --auto-correct.
316
- # Configuration parameters: SupportedStyles.
317
- Style/SpaceAroundEqualsInParameterDefault:
318
- EnforcedStyle: no_space
319
-
320
- # Offense count: 3
321
- # Cop supports --auto-correct.
322
- # Configuration parameters: MultiSpaceAllowedForOperators.
323
- Style/SpaceAroundOperators:
324
- Exclude:
325
- - 'lib/hotdog/commands/down.rb'
326
- - 'lib/hotdog/commands/search.rb'
327
-
328
- # Offense count: 1
329
- # Cop supports --auto-correct.
330
- Style/SpaceInsideBrackets:
331
- Exclude:
332
- - 'lib/hotdog/commands/search.rb'
333
-
334
- # Offense count: 374
335
- # Cop supports --auto-correct.
336
- # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
337
- Style/SpaceInsideHashLiteralBraces:
338
- Enabled: false
339
-
340
- # Offense count: 25
341
- # Cop supports --auto-correct.
342
- Style/SpaceInsideParens:
343
- Exclude:
344
- - 'lib/hotdog/application.rb'
345
- - 'lib/hotdog/commands.rb'
346
- - 'lib/hotdog/commands/search.rb'
347
-
348
- # Offense count: 4
349
- # Cop supports --auto-correct.
350
- Style/SpecialGlobalVars:
351
- Exclude:
352
- - 'lib/hotdog/commands/help.rb'
353
- - 'lib/hotdog/commands/ssh.rb'
354
- - 'lib/hotdog/commands/version.rb'
355
-
356
- # Offense count: 1554
357
- # Cop supports --auto-correct.
358
- # Configuration parameters: EnforcedStyle, SupportedStyles.
359
- Style/StringLiterals:
360
- Enabled: false
361
-
362
- # Offense count: 15
363
- # Cop supports --auto-correct.
364
- # Configuration parameters: EnforcedStyle, SupportedStyles.
365
- Style/StringLiteralsInInterpolation:
366
- Enabled: false
367
-
368
- # Offense count: 16
369
- # Cop supports --auto-correct.
370
- # Configuration parameters: IgnoredMethods.
371
- Style/SymbolProc:
372
- Exclude:
373
- - 'lib/hotdog/application.rb'
374
- - 'lib/hotdog/commands.rb'
375
- - 'lib/hotdog/commands/search.rb'
376
-
377
- # Offense count: 71
378
- # Cop supports --auto-correct.
379
- # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles.
380
- Style/TrailingComma:
381
- Enabled: false
382
-
383
- # Offense count: 6
384
- # Cop supports --auto-correct.
385
- Style/TrailingWhitespace:
386
- Exclude:
387
- - 'spec/formatter/plain_spec.rb'
388
- - 'spec/formatter/text_spec.rb'
389
-
390
- # Offense count: 2
391
- # Cop supports --auto-correct.
392
- Style/UnneededPercentQ:
393
- Exclude:
394
- - 'hotdog.gemspec'
395
-
396
- # Offense count: 66
397
- # Cop supports --auto-correct.
398
- # Configuration parameters: WordRegex.
399
- Style/WordArray:
400
- MinSize: 4