Class: FakeUpdater

Inherits:
Object
  • Object
show all
Defined in:
bin/finexclub_updater

Instance Method Summary collapse

Constructor Details

#initialize(host, port) ⇒ FakeUpdater

Returns a new instance of FakeUpdater.



121
122
123
124
# File 'bin/finexclub_updater', line 121

def initialize(host, port)
  @host = host
  @port = port 
end

Instance Method Details

#join_params(params) ⇒ Object



139
140
141
# File 'bin/finexclub_updater', line 139

def join_params(params)
  params.map {|k,v| "#{CGI::escape(k)}=#{CGI::escape(v.to_s)}"}.join('&')
end

#send(generator, options = {}) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
# File 'bin/finexclub_updater', line 126

def send(generator, options = {})
  puts "Sending '#{generator.name}' to #{@host}:#{@port}"
  begin
    data = join_params(generator.generate(options))
    http = Net::HTTP.new(@host, @port)
    response = http.post("/#{generator.name}", data)
    puts "Done... #{response.value}"
  rescue Exception => e
    puts "...Failed!"
    puts e.message
  end
end