lib/evernote/user_store.rb in evernote-0.9.0 vs lib/evernote/user_store.rb in evernote-1.0.0
- old
+ new
@@ -3,16 +3,19 @@
VersionOutOfDate = Class.new(StandardError)
class UserStore
AuthenticationFailure = Class.new(StandardError)
- def initialize(uri, auth_file, auth_env, thrift_client_options = {})
- credentials = YAML.load_file(auth_file)[auth_env.to_s]
+ def initialize(uri, credentials, thrift_client_options = {})
- @consumer_key = credentials["consumer_key"]
- @consumer_secret = credentials["consumer_secret"]
- @username = credentials["username"]
- @password = credentials["password"]
+ raise ArgumentError, "credentials must be passed in as a hash" unless credentials.class == Hash
+
+ credentials=credentials.inject({}) { |h,(k,v)| h[k.to_sym] = v; h } # convert any stringifyed hash keys into symbols
+
+ @consumer_key = credentials[:consumer_key]
+ @consumer_secret = credentials[:consumer_secret]
+ @username = credentials[:username]
+ @password = credentials[:password]
unless @consumer_key && @consumer_secret && @username && @password
raise ArgumentError, "'consumer_key', 'consumer_secret', 'username' and 'password' are required"
end