lib/paperclip/storage/imgur.rb in paperclip-imgur-0.1.1 vs lib/paperclip/storage/imgur.rb in paperclip-imgur-0.1.2

- old
+ new

@@ -1,8 +1,8 @@ require 'yaml' require 'erb' -require 'imgur' +require 'imgurapi' module Paperclip module Storage module Imgur @@ -62,11 +62,11 @@ def url(size = default_style) image_id = instance.send("#{name}_#{:file_name}") return @url_generator.for(size, {}) if image_id.nil? || image_id.empty? # Show Paperclip's default missing image path - ::Imgur::Image.new(id: image_id).url(size) + ::Imgurapi::Image.new(id: image_id).url(size) end # Returns the path of the attachment. # It's exactly the Imgur hash. def path(style_name = default_style) @@ -81,11 +81,11 @@ end private def imgur_session - @imgur_session ||= ::Imgur::Session.instance(@imgur_credentials) + @imgur_session ||= ::Imgurapi::Session.instance(@imgur_credentials) end def parse_credentials(credentials = nil) if credentials.nil? && defined?(Rails) credentials = "#{Rails.root}/config/imgur.yml" @@ -94,9 +94,11 @@ credentials = case credentials when File YAML.load(ERB.new(File.read(credentials.path)).result) when String, Pathname YAML.load(ERB.new(File.read(credentials)).result) + else + credentials end return credentials.stringify_keys if credentials.respond_to? :stringify_keys raise ArgumentError, 'Please specify Imgur credentials via a file, string or hash.'