ruby-tumblrãã¤ããã¾ãã
Tumblræ´¾ã®ã¿ãªããããã«ã¡ã¯ã
ä»æ¥ã¯ããã¶ãé¨ã«å å ¥ç³è«è´ãã¾ãããã¯ã¦ãªã®ä»çµã¿ãåãã£ã¦ããªãã®ã§ããã¶ãé¨ããªã«ãªã®ãè¯ãåãããªãã®ã§ããããããããé¡ããã¾ãã
ãã¦æ¬é¡ã§ããruby-tumblrãã¤ããã¾ããï¼プロジェクトページï¼ãversionã0.0.1ã§ãããåºæ¥ç«ã¦ãã¤ãã¤ã§ãããã¹ããããã«ãã¦ãã¾ããã®ã§èª°ããã¡ãªã¨ãããã¿ã¤ãã¦ç´ãã¦ãã£ã¦ä¸ããã¾ãããååãé¡ããã¾ããã¾ããæè¦ãªã©ããã¾ããããæ¯éã³ã¡ã³ããããã¯ã¡ã¼ã«ä¸ããã¾ãã
ã¤ã³ã¹ãã¼ã«ã®ä»æ¹
sudo gem install ruby-tumblr
ãã¦ä¸ãããtzinfoã©ã¤ãã©ãªãå¿ è¦ã§ãããgemãªã®ã§ãã£ã¨ä¸ç·ã«ã¤ã³ã¹ãã¼ã«ãã¦ãããã®ã ããã¨æãã¾ãã
åºæ¥ããã¨
- read
- write
- backup
read
tumblr API ã使ã£ã¦ãã¹ããèªã¿è¾¼ã¿ã¾ããå ·ä½çã«ã¯ä»¥ä¸ã¿ãããªæãã«ãªãã¾ãã
require "tumblr" Tumblr::API.read("tumblr.dynamic-semantics.com") do |pager| data = pager.page(0) p data.tumblelog data.posts.each do |post| p post end end
å¤æ°postã¯Tumblr::Data::Postã®ãµãã¯ã©ã¹ã§ããTumblr::Data::Regularã¨ãTumblr::Data::Photoã®ãªãã¸ã§ã¯ãã«ãªãã¾ãã
write
åæ§ã«tumblr APIã使ã£ã¦ãã¹ããæãã¾ããå ·ä½çã«ã¯ä»¥ä¸ã¿ãããªã
require "tumblr" Tumblr::API.write($email, $password) do regular("test body", "test title") quote("test quote", "test source") link("http://tumblr.dynamic-semantics.com", "test link") end
Tumblr::API.write ã«ãããã¯ãä¸ããã¨ãã®ä¸ã§ regular ãã quote ããã®ãã¹ãç³»ã®é¢æ°ã使ããããã«ãªãã¾ããããã§ãã¹ããã¾ãããããªãã§ããï¼
backup
tumblrã£ã¦ä½ã§å²ãã¦ããã®ãåãããªãã®ã§ãã¡ãã£ã¨ä¸å®ã§ããããããããã¯ã¢ãããã¨ããããªã£ã¦ãã¾ããã以ä¸ã®ããã«ãã¾ãã
require "tumblr" Tumblr::API.read("tumblr.dynamic-semantics.com") do |pager| data = Tumblr::Data.new 0.upto(pager.last_page) do |n| puts "get #{n}/#{pager.last_page}" data << pager.page(n) end data.save("backup.xml") end
ãããããå°ãã¾ã¨ãã«ãã¾ãããã¨ããããããã§ç»å以å¤ã®ããã¯ã¢ããã¯ã¨ãã¾ãããªã tumblr API ã§readããæã«è¿ã£ã¦ãããã®ã«è¿ããã©ã¼ãããã§ä¿åãã¾ãããããã¾ã§ããã®ã¾ã¾ã§ã¯ãªãã®ã§ã注æä¸ãããå¤å°æãå ãã¦ãã¾ããã¾ããã©ã¼ãããã¯ãã°ããè½ã¡çãã¾ã§ã³ãã³ãå¤ãã¦ãã¾ãã¨æãã¾ãã
ææ³
rubyforge便å©ã§ãããgemã£ã¦ãããªã«ç°¡åã«ä½ãããã§ãããããã¯ããrubyforge使ããªãã¨æãªæãï¼
ã¨ããã§ç§ã¯ããã¾ã§ä¸åº¦ãconversationåã§ãã¹ããããã¨ããªãã®ã§æ±ããä¸å®ã§ããã»ã¨ãã©ä½¿ã£ã¦ãã人ãã¿ãªãã®ã§ããããã使ã£ã¦ããæ¹ããããã¾ãããæ¯éã¨ããã¹ãããããããé¡ãè´ãã¾ãã
ã¡ãªã¿ã«ãã®ã©ã¤ãã©ãªãä½ã£ãçç±ã¯ãrubyforgeã§"tumblr"ãæ¤ç´¢ãããããã¸ã§ã¯ããäºã¤ã¿ã¤ãã£ããã©ãã©ã¡ããããæ°ããªãããã ã£ãããã§ãããã£ããä½ã£ãã®ã§ã¨ãããã @nifty Timeline ãããã«ãã¹ãæ°ãè¨é²ãã¦éãã§ã¿ããã¨æãã¾ãã