lib/device_cloud/configuration.rb in device_cloud-0.2.3 vs lib/device_cloud/configuration.rb in device_cloud-0.2.4
- old
+ new
@@ -1,13 +1,10 @@
require 'logger'
module DeviceCloud
module Configuration
- # DeviceCloud account root_url
- attr_writer :root_url
-
# DeviceCloud account username
attr_writer :username
# DeviceCloud account password
attr_writer :password
@@ -51,22 +48,24 @@
# Yield self to be able to configure ActivityFeed with
# block-style configuration.
#
# Example:
#
- # ActivityFeed.configure do |configuration|
+ # DeviceCloud.configure do |configuration|
# configuration.root_url = 'https://example.com'
# end
def configure
yield self
+ config
end
def config
{
username: username,
password: password,
root_url: root_url,
+ host: host,
alert_notification_handler: @alert_notification_handler,
empty_alert_notification_handler: @empty_alert_notification_handler,
data_notification_handler: @data_notification_handler,
empty_data_notification_handler: @empty_data_notification_handler,
event_notification_handler: @event_notification_handler,
@@ -75,34 +74,41 @@
}.freeze
end
# DeviceCloud url
#
- # @return the DeviceCloud url or the default of 'https://my.idigi.com' if not set.
+ # @return the DeviceCloud url - 'https://my.idigi.com'
def root_url
- @root_url ||= 'https://my.idigi.com'
+ 'https://my.idigi.com'
end
+ # DeviceCloud url
+ #
+ # @return the DeviceCloud host - 'my.idigi.com'
+ def host
+ 'my.idigi.com'
+ end
+
# DeviceCloud username
#
# @return the DeviceCloud username or raises an error
def username
- raise 'DeviceCloud username is blank' if @username.blank?
+ raise 'DeviceCloud username is blank' if @username.nil? || @password == ''
@username
end
# DeviceCloud password
#
# @return the DeviceCloud password or raises an error
def password
- raise 'DeviceCloud password is blank' if @password.blank?
+ raise 'DeviceCloud password is blank' if @password.nil? || @password == ''
@password
end
# DeviceCloud logger
#
# @return the DeviceCloud logger or set the default to stdout
def logger
@logger ||= Logger.new(STDOUT)
end
end
-end
\ No newline at end of file
+end