lib/mite-rb.rb in mite-rb-0.4.2 vs lib/mite-rb.rb in mite-rb-0.4.3

- old
+ new

@@ -6,17 +6,17 @@ # a sleek time tracking webapp. module Mite class << self - attr_accessor :email, :password, :host_format, :domain_format, :protocol, :port, :user_agent - attr_reader :account, :key + attr_accessor :email, :password, :host_format, :domain_format, :port, :user_agent + attr_reader :account, :key, :protocol # Sets the account name, and updates all resources with the new domain. def account=(name) resources.each do |klass| - klass.site = klass.site_format % (host_format % [protocol, domain_format % name, ":#{port}"]) + klass.site = klass.site_format % (host_format % ['https', domain_format % name, ":#{port}"]) end @account = name end # Sets up basic authentication credentials for all resources. @@ -43,10 +43,14 @@ resources.each do |klass| klass.headers['User-Agent'] = user_agent end @user_agent = user_agent end + + def protocol=(protocol) + $stderr.puts "WARNING: mite.api can only be accessed over HTTPS." unless protocol == 'https' + end def resources @resources ||= [] end @@ -67,10 +71,9 @@ end end self.host_format = '%s://%s%s' self.domain_format = '%s.mite.yo.lk' - self.protocol = 'https' self.port = '' self.user_agent = "mite-rb/#{Mite::VERSION}" class MethodNotAvaible < StandardError; end