2018-02-01ãã1ã¶æéã®è¨äºä¸è¦§
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ Rubyæè¡è èªå®è©¦é¨ãGoldã模æ¬åé¡ã解ãã¦ã¿ã (4) ~ Q15. Numeric ã¯ã©ã¹ã®ãªãã¸ã§ã¯ãæ¼ç® ã¸ã§ã®ã³ã° é¦æ¤æµ x 2 å¨ ãæ¼ä¼ã¿ãå©ç¨ã㦠å¯ããã, æããã, ã¨ã¦ãèµ°ããããã£ã æ¥èª² (è ç«ã¦ x 50 + è ¹ç x â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ Rubyæè¡è èªå®è©¦é¨ãGoldã模æ¬åé¡ã解ãã¦ã¿ã (3) ~ Q11. ã¯ã©ã¹ã¡ã½ãã Q12. self ãã¼ã¯ã¼ã Q13. private ã¡ã½ãã Q14. Enumerable#inject Q15. Object#freeze ã¸ã§ã®ã³ã° ãä¼ã¿ åæ¥ã«ã ãªããæããã£ãã®â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ Rubyæè¡è èªå®è©¦é¨ãGoldã模æ¬åé¡ã解ãã¦ã¿ã (2) ~ Q6. ä¾å¤ (1) Q7. ä¾å¤ (2) Q8. å®æ° Q9. ã¯ã©ã¹å®ç¾© Q10. protected ã¡ã½ãã ä¾å¤ã³ã¬ã¯ã·ã§ã³ begin ~ rescue ~ else ~ ensure ~ end TypeError ã¸ã§ã®ã³ã° â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ Rubyæè¡è èªå®è©¦é¨ãGoldã模æ¬åé¡ã解ãã¦ã¿ã (1) ~ Q1. private ã¡ã½ãã Q2. self ãã¼ã¯ã¼ã Q3. super ãã¼ã¯ã¼ã Q4. å¤æ°å±é Q5. å®æ°ã¸ã®ã¢ã¯ã»ã¹ ã¸ã§ã®ã³ã° é¦æ¤æµ x 3 å¨ ãã³ã°æµããã·ã¥ x 3 æ¥èª² (è â¦
ã¸ã§ã®ã³ã° æ¥èª² ã¯ãã¯ãã¯ãã¶ã¯ã㯠AWS ã¡ã¢ ä»æ¥ã®ãã³ã ~ ã¡ã½ããæ¢ç´¢ã¨ã (2) ~ Mod1 ã prepend 㧠Mix-in (2) ã¸ã§ã®ã³ã° é¦æ¤æµ x 2 å¨ ã¢ãã£ãã¹ã®ãã©ã½ã³ã·ã¥ã¼ãºã§èµ°ã£ã¦ã¿ããã©, ãã£ã±ãã¢ãã£ãã¹ã®é´ã®æ¹ããã£ã¦ããããããªã æ¥èª² â¦
ã¸ã§ã®ã³ã° æ¥èª² 奥ãã Ruby 25 å¨å¹´ ã½ããã¦ã§ã¢å·¥å¦ ä»æ¥ã®ãã³ã ~ ã¡ã½ããæ¢ç´¢ã¨ã (1) ~ åºæ¬ãã¿ã¼ã³ Mod1 ã include 㧠Mix-in Mod1 ã prepend 㧠Mix-in ã¸ã§ã®ã³ã° ç©æ¥µçã«ä¼ã æ¥èª² (è ç«ã¦ x 50 + è ¹ç x 30) x 3 奥ãã å¼ãç¶ã, ä½èª¿ãâ¦
ã¸ã§ã®ã³ã° 奥ãã TDD åå¼·ä¼ ä»æ¥ã®ãã³ã ã¸ã§ã®ã³ã° é¦æ¤æµ x 2 å¨ èµ°ãçµãã£ãå¾ã®çèçã¨ãå端ãªã...ãã¼ã...å°ã£ã 奥ãã ãä¼ã¿ ç é¢ã«è¡ã£ãå¾ãå°ãé¡è²ããããªã£ã¦å®å¿ãã TDD åå¼·ä¼ ãã¼ã£ã¨, ã¡ããã¨å¦ã³ããã¨æã£ã¦ãã TDD. ä¹å·â¦
ã¸ã§ã®ã³ã° æ¥èª² 奥ãã ä»æ¥ã®ãã³ã ~ ãã©ã³ã¯ã¹ã¬ã¼ã ~ ãã©ã³ã¯ã¹ã¬ã¼ã BasicObject ä¾ æ¥µç«¯ãª method_missing 㨠BasicObject ãªä¾ ã¸ã§ã®ã³ã° é¦æ¤æµ x 2 ã©ããèµ°ããã®ã¯ã·ã£ã¯ãã¦ãã¦, ãã£ã 2 å¨ãããã¦ããªãã®ã«, 足ã®ç²å´æãå端ãªã æ¥â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ awspec ã® issue ã«æã (2) ~ ã©ã㪠issue ã ã£ãã [åæ²] ãªãã§ãããªäºãèµ·ããã®ã ãã«ãªã¯ã¨ã¹ã ã¨ãããã¨ã§ ã¸ã§ã®ã³ã° é¦æ¤æµ x 2 å¨ ãã¼, ãªãã ããªã¼ã£ã¦æã æ¥èª² (è ç«ã¦ x 50 + è ¹ç x 30) x 3 å¤â¦
ã¯ããã« ããã§, assert æãå©ç¨ãããã¨ã«ãã å©ç¨ä¾ å©ç¨ä¾ã®ç°å¢ è¨å®ãã¡ã¤ã« ã³ãã³ãã®åºåçµæ ã¨ãããã¨ã§ ã¯ããã« æé æ¸ãæ¸ãæã«ãxxx ã®åºåçµæã xxx ã§ãããã¨ãç®è¦ã§ç¢ºèªãã.ãã¨æ¸ãã¦ãã¦, èªåã§èªåã«ä»¥ä¸ã®ãããªããã³ããå ¥â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ Refinement (2) ~ Refinement ã®ä¸ã§åºæ¥ãã㨠Refinement ãæå¹ã«ãªã£ã¦ããã³ã¼ãã®åªå 度 Refinement ã®æãé åè ã¸ã§ã®ã³ã° é¦æ¤æµ x 5 æ°åçã«èµ°ããããã£ãã®ã§, 5 å¨é å¼µã£ã¦ã¿ã å¾åã¯èªåãæã£ã¦ããâ¦
ã¸ã§ã®ã³ã° æ¥èª² ãã£ã®ã¥ã¢ã¹ã±ã¼ã è¤äºäºæ®µ å¤é£¯ ä»æ¥ã®ãã³ã 2018/02/17 ~ Refinement ~ ãªã¼ãã³ã¯ã©ã¹ã®æ¸å¿µç¹ Refinement Refinements ã®é©ç¨ç¯å² åè ã¸ã§ã®ã³ã° é¦æ¤æµ x 3 å¨ å¤©æ°ãè¯ãã¦èµ°ããããã£ã æ¥èª² (è ç«ã¦ x 50 + è ¹ç x 30) x 3 ãâ¦
ã¸ã§ã®ã³ã° æ¥èª² æ±äº¬æ¥å¸°ãåºå¼µ 2018/02/16 ~ ã¡ã½ããæ¢ç´¢è²ã ~ åºæ¬ã®å Cls1 ãç¶æ¿ã®å Module1 ã include ã®å(1) Module1 ã include ã®å(2) Module1 ã include ã®å(3) Module1 ã include ã®å(4) ã¸ã§ã®ã³ã° ä¼ã¿ èµ°ãã®ã¯ä¼ãã ãã©, æ±äº¬ãâ¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ yield 㨠Proc (3) ~ Proc.new 㨠lambda Proc.new 㨠lambda ~ å¼æ°ã®æ±ã ~ Proc.new 㨠lambda ~ return 㨠break ã®æå ~ ã¸ã§ã®ã³ã° ãæ¼ä¼ã¿ã«é¦æ¤æµ x 2 å¨ æ¥èª² ãä¼ã¿ å¤é£¯ é ã¾ã, åºæ±ã«ãã ãã£ã ä»æ¥ã®â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ãã¬ã³ã¿ã¤ã³ ä»æ¥ã®ãã³ã ~ yield 㨠Proc (2) ~ ãããã¯ãå¼æ°ã¨ãã¦åãåã Proc ãªãã¸ã§ã¯ã Proc ãªãã¸ã§ã¯ãããããã¯ã®ä»£ããã«æ¸¡ã ã¯ãã¼ã¸ã£ ã¸ã§ã®ã³ã° ãæ¼ä¼ã¿ãå©ç¨ãã¦é¦æ¤æµ x 2 å¨ èä¸ãçãã¦å¼å¸ãã¨ã¦ãã¤â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ awspec ã® issue ã«æã (1) ~ issue method_missing åä½ç¢ºèª ã§, ã©ããããã... ã¸ã§ã®ã³ã° ãä¼ã¿ æãèµ·ããå¾ã®ä½èª¿ãæªããã æ¥èª² ãä¼ã¿ å¤é£¯ é çæ ç²ãã¾ã¶ãã¦ç¼ããæç¾½ä¸ã¨ããã¼ãã¿ãã§åºæ±ãåã£ãâ¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ å¹³æãªãªã³ãã㯠ä»æ¥ã®ãã³ã ~ yield 㨠Proc ~ yield ã¸ã§ã®ã³ã° é¦æ¤æµ 2 å¨ çµå§æ¯è¦ããã¦è¾ãã£ã æ¥èª² (è ç«ã¦ x 50) x 3 è °çãé·å¼ãã¦ãã å¤é£¯ 奥ããã®å¾ææçã®ä¸ã¤ã§ãããã¼ãã·ãã¥ã¼ å æ¥é ãã赤ã¯ã¤ã³ãå°ãå ¥ãâ¦
åå å®è£ ã¡ã¢ ãã¹ã pycodestyle invoke ä»¥ä¸ åå inokara.hateblo.jp ãã®è¨äºã§ä½ã£ããµã³ãã«ã¨ãã Github ã«ä¸ãã. github.com 詳細ã¯ååã®è¨äºã¨ãè¦ã. å®è£ ã¡ã¢ ãã¹ã ãã¼ã«ã«ãã¹ãã« MySQL ãåãã¦ãããã¨ãåæã ãã©, ãã¹ãç¨ã®ãã¼ã¿â¦
tl;dr ãããªãã¼ãã«ããã£ãã¨ãã å®è£ ä¾ ç°å¢ 1 件åå¾ãã å ¨ä»¶ãåå¾ãã æå®ããæ¡ä»¶ã®ã¬ã³ã¼ããåå¾ ä»¥ä¸ tl;dr SELECT * FROM table WHERE id = N ã®çµæã JSON ã§åå¾ããã. ãã , ããã ã. ãããªãã¼ãã«ããã£ãã¨ãã mysql> SELECT * FRâ¦
ä½ä¸ä¿ã«ã¦ æ´è» éªãããã ä»æ¥ã®ãã³ã ~ Active Record ã«è奮ãã ~ åè ãµã³ãã« Active Record ã®è¦ç´ ä½ä¸ä¿ã«ã¦ 奥ããã®å®å®¶ã®ãå¢åã, ãã¡ããã¡ãå¯ãã£ããã©, ãå¢ã§æãåããããä¸æè°ã¨æ¸©ããæ°æã¡ã«ãªã£ã ãæ¼ãã¯ãã¾ã§ã馳走ã«ãªâ¦
ã¸ã§ã®ã³ã° æ¥èª² ä½ä¸ä¿ã®ãã¼ã¡ãã ä»æ¥ã®ãã³ã ~ minitest ~ ã¸ã§ã®ã³ã° æããé¨ã¨ããã®ã¨ãè °çãã¸ã¯ãªã¨ããã®ã§ãä¼ã¿ æ¥èª² ãä¼ã¿ ä½ä¸ä¿ã®ãã¼ã¡ãã ä½ä¸ä¿ã«ä½ãã§ãã奥ããã®ããããå® ã«è¨ªåããã¼ãã«ä¸æ¯ã«ä¸¦ã¹ãããææçã¨å°½ããªã話â¦
ã¯ããã« ä½ã£ããã® ãªãã§ä½ã£ãã®ã å®è£ ã¡ã¢ ActiveRecord ããããªã Minitest ã® setup 㨠teardown ããã ãã£ã¨... é å¼µã£ãã¨ãã ã¯ããã« ä½ã£ããã® github.com ãªãã§ä½ã£ãã®ã ãã¼ã¿ãã¼ã¹ã®æ¤è¨¼ã«ããã, å®éã®ã¢ããªã±ã¼ã·ã§ã³ãããã¼â¦
ã¸ã§ã®ã³ã° æ¥èª² ä»å¤ã ä»æ¥ã®ãã³ã ~ ã¡ã½ããã®å ¬éã¬ãã«ã«ã¤ã㦠(4) + minitest ~ ãµã³ãã«ã³ã¼ã ãã¹ãã³ã¼ã ã¸ã§ã®ã³ã° æ¼ä¼ã¿ãå©ç¨ãã¦é¦æ¤æµ 2 å¨ ããªããããã£ãããè °ãã¤ãã¤ã æ¥èª² è ç«ã¦ãå§ãã段éã§è °ã«çã¿ãåºãã®ã§æ¢ãã ä»å¤â¦
ã¯ããã« Minitest ã¬ãã Minitest ãµã³ãã«ã³ã¼ã ãã¹ãã³ã¼ã ãµã³ãã«ã³ã¼ãã¨ãã¹ãã³ã¼ã ãã¹ãã³ã¼ã (1) ãã¹ãã³ã¼ã (2) ãã¹ãã³ã¼ã (3) ãã¹ãã³ã¼ã (æçµå½¢æ ) ä»¥ä¸ ã¯ããã« ãã®è¨äºã¯, ãããç®æã人ã®ããã®Rubyå ¥é è¨èªä»æ§ãããã¹â¦
ã¸ã§ã®ã³ã° æ¥èª² æ´ãã¦ãããã© ä»æ¥ã®ãã³ã ~ ã¡ã½ããã®å ¬éã¬ãã«ã«ã¤ã㦠(3) ~ protected ã¡ã½ãã ã¸ã§ã®ã³ã° ä»æ¥ããä¼ã¿ è °ã¯ã ãã¶ã復æ§ãã¦ãã¦ãããã©...ã£ã¦æã æ¥èª² ãã¡ããä¼ã¿ ããããåéããã æ´ãã¦ãããã© åºå·ããé¡èãªä¸æ¥â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ ã¡ã½ããã®å ¬éã¬ãã«ã«ã¤ã㦠(2) ~ ã¯ã©ã¹ã¡ã½ããã private ã«ããã ã¸ã§ã®ã³ã° å¼ãç¶ããä¼ã¿ ã§ããä»æã¯é¦æ¤æµã¾ã§æ£æ©åºæ¥ã æ¥èª² ãä¼ã¿ å¤é£¯ ä¹ ãã¶ãã«ãã¤ã¬ãã¯ã¹ã«ãè²·ãç©ã«è¡ãã ã¨ãããã¨ã§ãé â¦
ã¸ã§ã®ã³ã° æ¥èª² ä¸é¢ã®éä¸ç ä»æ¥ã®ãã³ã ~ ã¡ã½ããã®å ¬éã¬ãã«ã«ã¤ã㦠~ public ã¡ã½ãã private ã¡ã½ãã ã¸ã§ã®ã³ã° å¼ãç¶ããä¼ã¿ è °ã®èª¿åã¯ã ãã¶ãè¯ããªã£ã¦ãã æ¥èª² åããã¦ä¼ã¿ ä¸é¢ã®éä¸ç æç®è¦ããããæ¬å½ã«ä¸é¢ã®éä¸çã ã£ã ä»â¦
ã¸ã§ã®ã³ã° æ¥èª² å¤é£¯ ä»æ¥ã®ãã³ã ~ ã¡ã½ããåã®è¡¨è¨æ³ ~ ã¸ã§ã®ã³ã° ç®ãè¦ããã, èµ·ãä¸ãããªããããã®è °çã§ä»æ¥ããä¼ã¿ ã¨ã«ãã温ãã ä»äºãè °ã«è² æ ããããªããããªã¹ã¿ã¤ã«ã模索 æ¥èª² ã¸ã§ã®ã³ã°åæ§ã« å¤é£¯ ãµããã®ã好ã¿ç¼ãããã¤ã¯ã¢â¦
ã¸ã§ã®ã³ã° æ¥èª² è °ç ä»æ¥ã®ãã³ã ~ ã¯ã©ã¹ã¡ã½ãã = ç¹å®ã¯ã©ã¹ã®ç¹ç°ã¡ã½ããã§ãã件ã«ã¤ã㦠~ ã¸ã§ã®ã³ã° è °çãæªå¤©ã®çºããä¼ã¿ æ¥èª² ãä¼ã¿ è °ç å¯ããåããã£ã¦, ã ãã¶ãé ·ã ä»æ¥ã®ãã³ã ~ ã¯ã©ã¹ã¡ã½ãã = ç¹å®ã¯ã©ã¹ã®ç¹ç°ã¡ã½ããã§ãâ¦
ã¯ããã« ä»å㯠Node.js 㧠ç°å¢ JavaScript ã§ãã¹ããæ¸ãããã«å¿ è¦ãªè«¸ã ä»å㯠Mocha + power-assert 㧠å®è·µ sls create ã§ã·ã³ãã«ãªã¢ããªã±ã¼ã·ã§ã³ã handler.js ãä¿®æ£ ãã¹ããæ¸ã ãã¹ããå®è¡ãã ã¡ãã£ã¨ Fail ãä½é¨ãã ä»¥ä¸ Lambda ã§â¦