osp 0.3.0.pre.dev.1 → 0.3.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: 29a7260e8467924c0cfb61511807d2562a1dc102
4
- data.tar.gz: 8d47df4ac02c3a0be9c129a370c415c85e2e9b7a
3
+ metadata.gz: a4c1c9cfa0c03b3bf0b9d49993c599d977ca17fb
4
+ data.tar.gz: 71bddbe633aedc04160f3743a10841ce3b2b1e6b
5
5
  SHA512:
6
- metadata.gz: 831f2ae320e236c5f01e74076b5a1aa76aa289aee68109cd501e2da58864cd51a3563692b9c775668dce9c9339c53bc5869fba377c83fab7ffe05bec7bae13a4
7
- data.tar.gz: d855ad637941341b19425b6b9c5dd7d2f33e4df9e1c6438b97c544ccb95d6ab073b60921d68ab1510e0ef9dd42fb1bdbdb26c3d0084ee1d7948fcacd7c5f5bf0
6
+ metadata.gz: 56dcef1066c82389ec100152a834c79bb16351731e1871d298a7407da1669be36a001a3ec1b97b222e526f68185b9702f272bc82f6c5032bbb38b856829ece08
7
+ data.tar.gz: 325c774f4eb87ec8c955a3a1ba45797c8fcd44375ac1fa2fbebd474ecbcc0052ef2eb87f048284cedbad3d89acbf95f5928914f0561f537a1e19432bef7ff0d0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- osp (0.3.0.pre.dev.1)
4
+ osp (0.3.0)
5
5
  highline (~> 1.7)
6
6
  msgpack (~> 0.7)
7
7
  thefox-ext (~> 1.2)
data/bin/osp CHANGED
@@ -60,7 +60,7 @@ puts 'Password: *****'
60
60
  puts
61
61
 
62
62
  @osp_class = TheFox::OSP::OSP
63
- @osp_class = TheFox::OSP::OSPDev
63
+ #@osp_class = TheFox::OSP::OSPDev
64
64
 
65
65
  printf "Calculating base hash: #{@osp_class::HASHES_N} (#{@osp_class::HASHES_EXP}-bit) - please wait ..."
66
66
  @osp = @osp_class.new(email, password)
@@ -212,22 +212,25 @@ while true
212
212
  index = 1
213
213
  if found_hosts.count > 1
214
214
  index = @cli.ask('Show host, select by number: ', Integer){ |q|
215
- q.character = true if found_hosts.count < 10
216
- q.in = 1..(found_hosts.count) }.to_i
215
+ q.character = true if found_hosts.count < 10 }.to_i
217
216
  puts
218
217
  end
219
218
 
220
- puts "Host ##{index} selected:"
221
- index -= 1
222
- selected_host = nil
223
- begin
224
- selected_host = found_hosts.values[index]
225
- rescue Exception => e
226
- puts "ERROR: #{e}"
227
- end
228
-
229
- if !selected_host.nil?
230
- host_show(selected_host)
219
+ if index >= 1 && index <= found_hosts.count
220
+ puts "Host ##{index} selected:"
221
+ index -= 1
222
+ selected_host = nil
223
+ begin
224
+ selected_host = found_hosts.values[index]
225
+ rescue Exception => e
226
+ puts "ERROR: #{e}"
227
+ end
228
+
229
+ if !selected_host.nil?
230
+ host_show(selected_host)
231
+ end
232
+ else
233
+ puts 'Abort.'
231
234
  end
232
235
  else
233
236
  puts 'No hosts found.'
@@ -238,25 +241,28 @@ while true
238
241
  index = 1
239
242
  if found_hosts.count > 1
240
243
  index = @cli.ask('Edit, select host by number: ', Integer){ |q|
241
- q.character = true if found_hosts.count < 10
242
- q.in = 1..(found_hosts.count) }.to_i
244
+ q.character = true if found_hosts.count < 10 }.to_i
243
245
  puts
244
246
  end
245
247
 
246
- puts "Host ##{index} selected:"
247
- index -= 1
248
- selected_host = nil
249
- begin
250
- selected_host = found_hosts.values[index].clone
251
- rescue Exception => e
252
- puts "ERROR: #{e}"
253
- end
254
-
255
- if !selected_host.nil?
256
- host_edit(selected_host)
257
- host_show(selected_host, true)
248
+ if index >= 1 && index <= found_hosts.count
249
+ puts "Host ##{index} selected:"
250
+ index -= 1
251
+ selected_host = nil
252
+ begin
253
+ selected_host = found_hosts.values[index].clone
254
+ rescue Exception => e
255
+ puts "ERROR: #{e}"
256
+ end
258
257
 
259
- @database.add_host(selected_host)
258
+ if !selected_host.nil?
259
+ host_edit(selected_host)
260
+ host_show(selected_host, true)
261
+
262
+ @database.add_host(selected_host)
263
+ end
264
+ else
265
+ puts 'Abort.'
260
266
  end
261
267
  else
262
268
  puts 'No hosts found.'
@@ -267,22 +273,30 @@ while true
267
273
  index = 1
268
274
  if found_hosts.count > 1
269
275
  index = @cli.ask('Delete, select host by number: ', Integer){ |q|
270
- q.character = true if found_hosts.count < 10
271
- q.in = 1..(found_hosts.count) }.to_i
276
+ q.character = true if found_hosts.count < 10 }.to_i
272
277
  puts
273
278
  end
274
279
 
275
- puts "Delete host ##{index}."
276
- index -= 1
277
- selected_host = nil
278
- begin
279
- selected_host = found_hosts.values[index]
280
- rescue Exception => e
281
- puts "ERROR: #{e}"
282
- end
283
-
284
- if !selected_host.nil?
285
- @database.remove_host(selected_host)
280
+ if index >= 1 && index <= found_hosts.count
281
+ puts "Delete host ##{index}."
282
+ index -= 1
283
+ selected_host = nil
284
+ begin
285
+ selected_host = found_hosts.values[index]
286
+ rescue Exception => e
287
+ puts "ERROR: #{e}"
288
+ end
289
+
290
+ if !selected_host.nil?
291
+ if @database.remove_host(selected_host)
292
+ found_hosts.delete(selected_host.name)
293
+ puts "Host '#{selected_host.name}' deleted."
294
+ else
295
+ puts "ERROR: Can't delete host '#{selected_host.name}'."
296
+ end
297
+ end
298
+ else
299
+ puts 'Abort.'
286
300
  end
287
301
  else
288
302
  puts 'No hosts found.'
@@ -296,7 +310,7 @@ while true
296
310
  puts "\tl - List found hosts."
297
311
  puts "\ti - Print informations about a host found by a search."
298
312
  puts "\te - Edit a host found by search."
299
- # puts "\td - Delete a host found by search."
313
+ puts "\td - Delete a host found by search."
300
314
  puts "\tq - Quit search."
301
315
  puts "\t? - Print help."
302
316
  else
@@ -306,7 +320,7 @@ while true
306
320
  next if search_actions.count > 0
307
321
 
308
322
  puts
309
- search_actions << @cli.ask('[slieq?] >> '){ |q| q.character = true }.downcase
323
+ search_actions << @cli.ask('[sliedq?] >> '){ |q| q.character = true }.downcase
310
324
  end
311
325
  when 'x'
312
326
  actions << 'q'
@@ -326,12 +340,14 @@ while true
326
340
  actions << 'x'
327
341
  else
328
342
  really = @cli.ask('Really? [yN] ', String){ |q| q.character = true }.strip.downcase
329
- really = 'y' if really == ''
343
+ really = 'n' if really == ''
330
344
  puts "Answer: '#{really}'"
331
345
 
332
346
  if really == 'y'
333
347
  @database.has_changed = false
334
348
  actions << 'q'
349
+ else
350
+ puts 'Qutting aborted.'
335
351
  end
336
352
  end
337
353
  else
data/lib/osp/database.rb CHANGED
@@ -160,6 +160,17 @@ module TheFox
160
160
  @has_changed = true
161
161
  end
162
162
 
163
+ def remove_host(host)
164
+ if @data['hosts'].has_key?(host.name)
165
+ @data['hosts'].delete(host.name)
166
+ update
167
+ @has_changed = true
168
+ true
169
+ else
170
+ false
171
+ end
172
+ end
173
+
163
174
  end
164
175
 
165
176
  end
data/lib/osp/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  module TheFox
3
3
  module OSP
4
4
  RELEASE_ID = 0
5
- VERSION = '0.3.0-dev.1'
5
+ VERSION = '0.3.0'
6
6
  DATE = '2015-12-20'
7
7
  HOMEPAGE = 'https://github.com/TheFox/osp'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: osp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.dev.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Mayer
@@ -123,9 +123,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  version: 2.1.0
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ">"
126
+ - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: 1.3.1
128
+ version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
131
  rubygems_version: 2.4.7