Class: Geostats::Commands::Push

Inherits:
Base
  • Object
show all
Defined in:
lib/geostats/commands/push.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



17
18
19
# File 'lib/geostats/commands/push.rb', line 17

def after
  logout
end

#beforeObject



12
13
14
15
# File 'lib/geostats/commands/push.rb', line 12

def before
  connect_database
  
end

#parse_argsObject

Raises:



8
9
10
# File 'lib/geostats/commands/push.rb', line 8

def parse_args
  raise UsageError unless @args.length.zero?
end

#runObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/geostats/commands/push.rb', line 21

def run
  log yellow("Generating statistics")
  @html = Generator.generate
  log "\r", green("Successfully generated statistics"), erase, "\n"

  log yellow("Pushing statistics to geocaching.com")

  resp, data = HTTP.post("/account/editprofiledetails.aspx", {
    "ctl00$ContentBody$uxProfileDetails" => @html,
    "ctl00$ContentBody$uxSave" => "Save Changes"
  })

  log "\r",
    green("Successfully pushed statistics to geocaching.com"),
    erase, "\n"
rescue Net::HTTPExceptions => e
  error e.message
end

#usageObject



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

def usage
  STDERR.puts "Usage: geostats push"
end