Changeset 35300

Show
Ignore:
Timestamp:
09/10/09 08:02:11 (4 years ago)
Author:
machu
Message:

added Profile::Service::Wassr and added Profile::Service::Hatena

Location:
platform/tdiary
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/plugin/profile.rb

    r35297 r35300  
    145145        size = @options[:size] ? "?s=#{@options[:size]}" : "" 
    146146        "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(@id.downcase)}.jpg#{size}" 
     147      end 
     148    end 
     149 
     150    class Wassr < Base 
     151      property :image, '//statuses/status/user/profile_image_url' 
     152      endpoint {|id| "http://api.wassr.jp/statuses/show.xml?id=#{id}" } 
     153 
     154      def link 
     155        "http://wassr.jp/user/#{id}" 
     156      end 
     157    end 
     158 
     159    class Hatena < Base 
     160      def image 
     161        prefix = id[0..1] 
     162        "http://www.hatena.ne.jp/users/#{prefix}/#{id}/profile.gif" 
     163      end 
     164 
     165      def link 
     166        "http://www.hatena.ne.jp/#{id}/" 
    147167      end 
    148168    end 
  • platform/tdiary/spec/profile_spec.rb

    r35298 r35300  
    5858  end 
    5959 
     60  describe "Wassr" do 
     61    before :all do 
     62      # http://wassr.jp/help/api 
     63      @profile = Profile::Service::Wassr.new("machu") 
     64    end 
     65 
     66    it "should include image property" do 
     67      @profile.image.should == "http://wassr.jp/user/machu/profile_img.png.64.1215127012" 
     68    end 
     69  end 
     70 
     71  describe "Hatena" do 
     72    it "should include image property" do 
     73      profile = Profile::Service::Hatena.new("kmachu") 
     74      profile.image.should == "http://www.hatena.ne.jp/users/km/kmachu/profile.gif" 
     75    end 
     76  end 
     77 
    6078end