Class: Geostats::Commands::Update
- Inherits:
-
Base
- Object
- Base
- Geostats::Commands::Update
show all
- Defined in:
- lib/geostats/commands/update.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #invoke
Instance Method Details
#after ⇒ Object
21
22
23
|
# File 'lib/geostats/commands/update.rb', line 21
def after
logout
end
|
#before ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/geostats/commands/update.rb', line 13
def before
connect_database
login
@delay = Setting.get(:delay) || 5
@sleep = false
end
|
#parse_args ⇒ Object
9
10
11
|
# File 'lib/geostats/commands/update.rb', line 9
def parse_args
@update_all = (@args.first == "all")
end
|
#run ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/geostats/commands/update.rb', line 25
def run
begin
@logs = Grabber::Logs.new.logs
rescue Net::HTTPExceptions => e
error "Failed to fetch your logs: #{e.message}"
end
@logs.reverse.each do |loginfo|
handle_log(loginfo)
if @sleep
sleep(@delay + rand(@delay))
@sleep = false
end
end
end
|
#usage ⇒ Object
4
5
6
7
|
# File 'lib/geostats/commands/update.rb', line 4
def usage
STDERR.puts "Usage: geostats update"
STDERR.puts " update all"
end
|