Permalink
Browse files

Fixing library to support custom domain names.

  • Loading branch information...
1 parent 0c9dabc commit 44621096851be84b1981002b0ad050496cd29ee4 Miha Rebernik committed Mar 4, 2010
Showing with 8 additions and 2 deletions.
  1. +7 −1 lib/tumblr.rb
  2. +1 −1 lib/tumblr/request.rb
View
8 lib/tumblr.rb
@@ -7,7 +7,13 @@
require 'tumblr/post'
class Tumblr
- class << self; attr_accessor :blog end
+ class << self
+ attr_reader :blog
+
+ def blog=(_blog)
+ @blog = (_blog =~ /\./) ? _blog : "#{_blog}.tumblr.com"
+ end
+ end
# tumblr errors
class TumblrError < StandardError; end
View
2 lib/tumblr/request.rb
@@ -3,7 +3,7 @@ class Request
# a GET request to http://[YOURUSERNAME].tumblr.com/api/read
def self.read(options = {})
- response = HTTParty.get("http://#{Tumblr::blog ||= 'staff'}.tumblr.com/api/read", options)
+ response = HTTParty.get("http://#{Tumblr::blog}/api/read", options)
return response unless raise_errors(response)
end

0 comments on commit 4462109

Please sign in to comment.