Class: Geostats::Commands::Update

Inherits:
Base
  • Object
show all
Defined in:
lib/geostats/commands/update.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #invoke

Constructor Details

This class inherits a constructor from Geostats::Commands::Base

Instance Method Details

#afterObject



21
22
23
# File 'lib/geostats/commands/update.rb', line 21

def after
  logout
end

#beforeObject



13
14
15
16
17
18
19
# File 'lib/geostats/commands/update.rb', line 13

def before
  connect_database
  

  @delay = Setting.get(:delay) || 5
  @sleep = false
end

#parse_argsObject



9
10
11
# File 'lib/geostats/commands/update.rb', line 9

def parse_args
  @update_all = (@args.first == "all")
end

#runObject



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

#usageObject



4
5
6
7
# File 'lib/geostats/commands/update.rb', line 4

def usage
  STDERR.puts "Usage: geostats update"
  STDERR.puts "                update all"
end