TimeLineAPI使ã£ã¦ã¿ã¾ãã / ãã®1 RSpec Formatter
ä»å¹´ã®åæ¬ã«ãªãªã¼ã¹ããã¦ä»¥æ¥ããããããã¼ã¸ã§ã³ã¢ãããéãã¦ãã@nifty TimeLineã§ãããæ¬æ¥ã®ãã¼ã¸ã§ã³ã¢ããã§WebAPIãå ¬éããã¾ããããã§ããã
- ãã¬ã¹ãªãªã¼ã¹(http://www.nifty.co.jp/cs/07kami/detail/070808003265/1.htm)
- @niftyã¦ã§ããµã¼ãã¹ (http://webservice.nifty.com/)
ãããããç¸ãããã¾ãã®ã§*1ãAPIå ¬éè¨å¿µã«ããã¤ãç°¡åã§ããããªã¢ããªã±ã¼ã·ã§ã³ãä½ã£ã¦ã¿ã¾ããã
ã¾ãä¸ã¤ç®ãRSpecã®ã«ã¹ã¿ã ãã©ã¼ããã¿ãä½ã£ã¦ã¿ã¾ããã
http://homepage3.nifty.com/moro/timeline_formatter.rb
ããã¯RSpecãå®è¡ããçµæãã©ãã©ãTimeLineã«ãã¹ããã¦ããã¨ãããã®ã§ãããã¹ãã®å®è¡æéãTimeLineä¸ã§ã®æå»ã¨ãã¦ããããããã¾ãã縦軸ã¯ãã¹ãæåæ° / å ¨ãã¹ã件æ°ã«ãªãã¾ãã
ä»åã®ä»¶ã§RSpecã®ã«ã¹ã¿ã ãã©ã¼ããã¿ã®æ¸ãæ¹ãããããã£ãã®ã§ããã¨ã§ãã®ãã©ã¼ããã¿ãä¾ã«ãã¦è§£èª¬è¨äºã§ãæ¸ãããã¨æãã¾ããã¨ãããã使ã£ã¦ã¿ã¦ãã ããã¾ãã
ä¸æºå
ã¾ããã¹ãçµæãããããããããã®TimeLineãä½æãã¾ããhttp://timeline.nifty.com/ã«ãã°ã¤ã³ããããã§ããã£ã¨ä½ã£ã¡ãã£ã¦ãã ããããªãããã©ã¤ãã¼ããªããã¸ã§ã¯ãã®å ´åã¯é²è¦§ã§ãã人ãå¶éããã»ããããããããã¾ãããTimeLineä½æç»é¢ã®ä¸é¨ãããã®è¾ºã®è¨å®ãåºæ¥ã¾ãã®ã§ãããã¸ã§ã¯ãã¡ã³ãã¼ã ããé²è¦§å¯è½ããªã©ã¨ããè¨å®ããã¡ãã£ã¦ãã ãããã¾ããTimeLineã表示ãããURLãããã®ã¿ã¤ã ã©ã¤ã³ã®IDãå²ãåºãã¾ããRailsãªäººã«ã¯èªæã§ãããããhttp://timeline.nifty.com/portal/show/2083ã®"2083"ãIDã«ãªãã¾ãã
ç¶ãã¦ãAPIã使ç¨ããããã®ãã¼(Timeline key)ãåå¾ãã¾ããTimeLineã«ãã°ã¤ã³ããç¶æ ã§/my_pageããåå¾ã§ãã¾ãã
ããã§TimeLineå´ã®æºåã¯å®äºã§ãã本体をダウンロードãã¦ãã ããããã¡ã¤ã«ã®å é ä»è¿ã«ãtimeline_keyã¨timeline_idãè¨å®ããç®æãããã¾ãã®ã§ãããæ¸ãæãã¦ãã ããã
$config = { :timeline_key => "your timeline - key", :timeline_id => Integer(timeline_id), }
ãããããªæãã§ã
$config = { :timeline_key => "abcdefghijkelmnopqrstuvwxyz", :timeline_id => 2083, }
å®è¡ãã
specã³ãã³ã(script/specå«ã)ããå®è¡ããå ´åã¨RSpec on Railsãä½µç¨ãã¦Rakeããå®è¡ããå ´åã®äºç¨®é¡ãããã¾ããã©ã¡ããåºæ¬ã¯å¤ãããã
1. ãã®ãã©ã¼ããã¿ãrequireãã
2. ãã©ã¼ããã¿ã®ã¯ã©ã¹åãæå®ãã
ã¨ããæµãã«ãªãã¾ãã
specã³ãã³ãããå®è¡ããå ´åã¯ä»¥ä¸ã®ãããªã³ãã³ãã«ãªãã¾ãã
spec -r timeline_formatter -f SpecDocWithTimeLine --color spec/models/**/*
ãã®å ´åã¯SpecDocWithTimeLineã¨ãããã©ã¼ããã¿ãå©ç¨ãã¦ãã¦ãããã¯SpecDocãã©ã¼ããã¿(-fsã§åºãã¤ã)ãå®è¡ãã¤ã¤ããã¹ãçµæãTimeLineã«ãã¹ããã¦ãã¾ãã
Rakeããå®è¡ãããå ´åã¯spec/spec.optsã以ä¸ã®ããã«ä¿®æ£ãã¦ãã ãã
--require timeline_formatter --colour --format ProgressWithTimeLine --loadby mtime --reverse
ãããåè¡ã«ä¸ã¤ãã¤ãspecã³ãã³ãã¸ã®ãªãã·ã§ã³ã渡ãã¦ãã¾ããtimeline_formatterãrequireããformatãªãã·ã§ã³ã§ProgressWithTimeLineãã©ã¼ããã¿ãæå®ãã¦ãã¾ãããã®ProgressWithTimeLineã¯specããå®è¡ããã¨ãã«åºããè²ä»ã"."ã表示ãã¦ããã¤ãã§ãã"."ã表示ãã¤ã¤ãè£å´ã§TimeLineã«ãã¹ããã¾ãã
ãã®ããã§ãrake specã¨ããããã¨ããã¹ããå®è¡ããçµæãTimeLineã«ãã¹ãããã¾ãã
ãã®ä»
ãã¨ãä»åã®ä»¶ã§RSpecã®ã«ã¹ã¿ã ãã©ã¼ããã¿ã®æ¸ãæ¹ãããããã£ãã®ã§ããã®ã³ã¼ãã追ããªãã解説è¨äºãæ¸ãã¾ããã¡ãã£ã¨æ¥ããããã
*1:ç¥ã£ã¦ãã人ã«ã¯ããã¨ãããããww