Skip to content

Commit

Permalink
Minor cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
JEG2 committed Nov 20, 2015
1 parent 8fb5fb9 commit 6622bcc
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions lib/haunted_house.rb
Expand Up @@ -4,33 +4,30 @@


require "haunted_house/device" require "haunted_house/device"


# FIXME: this is dangerous
OpenSSL::SSL.send(:remove_const, :VERIFY_PEER)
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE

class HauntedHouse class HauntedHouse
def initialize(address, user, password) def initialize(address, user, password)
@address = address @address = address
@user = user @user = user
@password = password @password = password
@devices = [ ] @devices = [ ]

lookup_devices lookup_devices
end end

def request(url) def request(url)
open( "#{@address}/rest/#{url}", open( "#{@address}/rest/#{url}",
:http_basic_authentication => [@user, @password] ) do |data| :http_basic_authentication => [@user, @password],
:ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE ) do |data|
yield data if block_given? yield data if block_given?
end end
end end

def device(name) def device(name)
@devices.find { |device| device.name == name } @devices.find { |device| device.name == name }
end end

private private

def lookup_devices def lookup_devices
request("nodes") do |data| request("nodes") do |data|
xml = REXML::Document.new(data) xml = REXML::Document.new(data)
Expand Down

0 comments on commit 6622bcc

Please sign in to comment.