lib/senec/state.rb in senec-0.7.2 vs lib/senec/state.rb in senec-0.8.0
- old
+ new
@@ -1,14 +1,15 @@
require 'httparty'
module Senec
class State
- def initialize(host:)
+ def initialize(host:, schema: 'http')
@host = host
+ @schema = schema
end
- attr_reader :host
+ attr_reader :host, :schema
# Extract state names from JavaScript file, which is formatted like this:
#
# var system_state_name = {
# 0: "FIRST STATE",
@@ -29,18 +30,18 @@
FILE_REGEX = /var system_state_name = \{(.*?)\};/m
LINE_REGEX = /(\d+)\s*:\s*"(.*)"/
def response
@response ||= begin
- res = HTTParty.get url
+ res = HTTParty.get url, verify: false
raise Senec::Error, res.message unless res.success?
res.body
end
end
# Use the JavaScript file with German names from the SENEC web interface
def url
- "http://#{host}/js/DE-de.js"
+ "#{schema}://#{host}/js/DE-de.js"
end
end
end