Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Rails講義 第26回 コードを書くための道具箱

Kuniaki IGARASHI
December 18, 2012
490k

Rails講義 第26回 コードを書くための道具箱

バージョン管理システムGit
RSpec
Twitter Bootstrap

Kuniaki IGARASHI

December 18, 2012
Tweet

Transcript

  1. HJUॳظԽ ࢼ͠ʹɺ৽͍͠ϑΥϧμΛ࡞ͬͯͦ͜ΛHJUͰόʔδϣϯ ؅ཧͯ͠Έ·͠ΐ͏ɻ NLEJSϑΥϧμ໊ DEϑΥϧμ໊ લ४උ ϑΥϧμΛ৽ن࡞੒͠·͢ɻ ࡞ͬͨϑΥϧμ΁Ҡಈ͠·͢ɻ HJU͸ϑΥϧμ୯ҐͰཤྺʢόʔδϣϯʣΛ؅ཧ͠·͢ɻ HJUॳظԽ

    HJUJOJU HJUJOJU͢ΔͱɺͦͷϑΥϧμΛόʔδϣϯ؅ཧͰ͖ΔΑ͏ʹͳΓ·͢ɻ Initialized empty Git repository in ϑΥϧμ໊ ˞౾஌ࣝɿόʔδϣϯ؅ཧ͞Ε͍ͯΔ৔ॴΛʮϦϙδτϦʯͱݺͼ·͢ɻ
  2. ίϛοτͷํ๏ ΤσΟλͰϑΝΠϧΛ࡞ͬͯɺHJUJOJUͨ͠ϑΥϧμ΁อଘ͠·͠ΐ͏ɻ લ४උ ίϛοτͯ͠Έ·͠ΐ͏ɻ HJUίϛοτ HJUBEEIFMMPSC HJUDPNNJUNIFMMPSCΛ௥Ճ ίϛοτ͢Δʹ͸ɺHJUBEEͨ͠ޙͰɺHJUDPNNJU͠·͢ɻ [master (root-commit)

    ebeb9df] hello.rb Λ௥Ճ 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 hello.rb QVUT)FMMPXPSME IFMMPSC ϑΝΠϧ໊΋ϑΝΠϧͷ಺༰΋ ࣗ༝Ͱ͔·͍·ͤΜɻ 3VCZͷίʔυͰͳͯ͘΋0,Ͱ͢ɻ IFMMPSCͷ෦෼͸ϑΝΠϧ໊ IFMMPSCΛ௥Ճͷ෦෼͸ ίϝϯτͰ͢ɻࣗ༝ʹॻ͚·͢ɻ
  3. commit ebeb9df1625ef74856a2724cca54e87abf72dfbc Author: Kuniaki IGARASHI <[email protected]> Date: Sat Dec 15

    21:44:22 2012 +0900 hello.rb Λ௥Ճ ཤྺͷݟํ HJUMPH ‏ίϛοτϋογϡ ‏ίϛοτͨ͠ਓ ‏ίϛοτͨ͠೔࣌ ‏ίϛοτϝοηʔδ ֤छ৘ใ͕ه࿥͞Ε͍ͯ·͢ɻ ίϛοτϋογϡͱ͸φχϞϊͰ͠ΐ͏͔ʁ ίϛοτϋογϡ͸ͦͷίϛοτΛҰҙʹࣔ͢ӳ਺ࣈͰ͢ɻ ͜ͷίϛοτͷ໊લͱݴͬͯ΋͍͍Ͱ͠ΐ͏ɻ ͜ͷίϛοτΛࢦ͢ͱ͖͸FCFCEͱࢦఆ͠·͢ɻ
  4. ཤྺΛ֬ೝͯ͠Έ·͠ΐ͏ HJUMPH commit 6ba048b2967d1c04f271e12988e43f19f3f65def Author: Kuniaki IGARASHI <[email protected]> Date: Sun

    Dec 16 09:56:42 2012 +0900 putsจΛมߋ commit ebeb9df1625ef74856a2724cca54e87abf72dfbc Author: Kuniaki IGARASHI <[email protected]> Date: Sat Dec 15 21:44:22 2012 +0900 hello.rb Λ௥Ճ ‏৽͍͠ίϛοτ ͕૿͑·ͨ͠ ͜ͷΑ͏ʹίϛοτ͕ੵΈ্͕͍͖ͬͯ·͢ɻ มߋͷ಺༰Λ΋͏গ͠ৄ͘͠ݟΔʹ͸Ͳ͏͢Ε͹͍͍Ͱ͠ΐ͏͔ɻʢͭͮ͘ʣ
  5. commit 6ba048b2967d1c04f271e12988e43f19f3f65def Author: Kuniaki IGARASHI <[email protected]> Date: Sun Dec 16

    09:56:42 2012 +0900 putsจΛมߋ diff --git a/hello.rb b/hello.rb index 08b85bf..a32c710 100644 --- a/hello.rb +++ b/hello.rb @@ -1 +1 @@ -puts "Hello world!" +puts "foo" commit ebeb9df1625ef74856a2724cca54e87abf72dfbc Author: Kuniaki IGARASHI <[email protected]> Date: Sat Dec 15 21:44:22 2012 +0900 hello.rb Λ௥Ճ diff --git a/hello.rb b/hello.rb new file mode 100644 ཤྺΛৄ͘͠ݟͯΈ·͠ΐ͏ HJUMPHQ ‏IFMMPSC͕มߋ͞Εͨ ‏͔Β࢝·Δߦ͸࡟আ͞Εͨ͜ͱΛҙຯ͠·͢ɻ ‏ ͔Β࢝·Δߦ͸௥Ճ͞Εͨ͜ͱΛҙຯ͠·͢ɻ ίϛοτͰมΘͬͨࠩ෼ EJGG ͕දࣔ͞Ε·͢ɻԿΛม͔͑ͨௐ΂͍ͨͱ͖ʹศརͰ͢ɻ ·ͨɺҎԼͷઃఆจΛଧͭͱ݁Ռ͕Χϥʔʹͳͬͯݟқ͍Ͱ͢ɻ ճ͚ͩଧͯ͹ͣͬͱ༗ޮ HJUDPOpHHMPCBMDPMPSVJUSVF
  6. HJUͷݱࡏঢ়ଶΛ֬ೝ͢Δ HJUঢ়ଶ֬ೝ HJUTUBUVT ϑΝΠϧʹมߋ͕ͳ͍ͱ͖ # On branch master nothing to

    commit (working directory clean) ϑΝΠϧ͕มߋ͞Ε͍ͯΔͱ͖ # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: hello.rb # no changes added to commit (use "git add" and/or "git commit - a") ‏มߋ͞Ε͍ͯΔϑΝΠϧ໊ ͭͮ͘
  7. HJUͷݱࡏঢ়ଶΛ֬ೝ͢Δ ͖ͭͮ HJUঢ়ଶ֬ೝ HJUTUBUVT աڈʹίϛοτͯ͠ͳ͍ϑΝΠϧ͕ଘࡏ͢Δͱ͖ # On branch master #

    Untracked files: # (use "git add <file>..." to include in what will be committed) # # iga.rb nothing added to commit but untracked files present (use "git add" to track) ‏աڈʹίϛοτ͞Ε͍ͯͳ͍͚Ͳଘࡏͯ͠ΔϑΝΠϧ໊
  8. ྺ࢙Λר͖໭͢ աڈͷίϛοτ·Ͱ໭ͯ͠Έ·͠ΐ͏ɻ ྫʣ HJUDIFDLPVU<ίϛοτϋογϡ> IFMMPSCΛΤσΟλͰ։͘ͱɺFCFCE࣌఺ͷঢ়ଶʹ໭ͬͯΔ͜ͱ͕෼͔Γ·͢ɻ Note: checking out 'ebeb9d'. You

    are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b new_branch_name HEAD is now at ebeb9df... hello.rb Λ௥Ճ ίϛοτϋογϡ͸ HJUMPHͰௐ΂͓͖ͯ·͢ɻ ίϛοτϋογϡ͸શ෦ଧͨͳͯ͘΋ Ұҙʹܾ·Δ௕͞Ͱେৎ෉Ͱ͢ɻ HJUDIFDLPVUFCFCE QVUT)FMMPXPSME
  9. 34QFDϓϩμΫτίʔυ࣮૷ ͨͱ͑͹#PPLϞσϧ͕ҎԼͷΑ͏ʹͳ͍ͬͯͯɺEFDP@UJUMFͱ͍ ͏λΠτϧΛσίΔૉఢͳϝιουΛ࣮૷͍ͯͨ͠ͱ͠·͠ΐ͏ɻ DMBTT#PPL"DUJWF3FDPSE#BTF BUUS@BDDFTTJCMFNFNP UJUMF EFGEFDP@UJUMF   UJUMF

      FOE FOE ͨͱ͑͹ɺCPPL#PPLOFX UJUMF݄ͷϥΠΦϯ ͷͱ͖ CPPLEFDP@UJUMFͱ࣮ߦͯ͠ ݄ͷϥΠΦϯ Λಘ͍ͨΘ͚Ͱ͢ɻ ςετͳͩ͠ͱ͏·͘ಈ͔͘ෆ҆Ͱ໷΋຾Ε·ͤΜɻ ςετίʔυΛॻ͍ͯΈ·͠ΐ͏ʂ ˞͜ͷ#PPLΫϥεͷΑ͏ʹɺΞϓϦͰ࣮ࡍͷಈ࡞ʹ࢖ΘΕΔίʔυΛϓϩμΫ τίʔυͱಡΜͩΓ΋͠·͢ɻࢲ͸ຊ൪ίʔυͱಡΜ͡Ό͏͜ͱ͕ଟ͍Ͱ͢ɻ BQQNPEFMTCPPLSC
  10. 34QFDςετίʔυ࣮૷ ςετίʔυ͸ҎԼͷΑ͏ʹॻ͚·͢ɻ  DPEJOHVUG  SFRVJSFTQFD@IFMQFS EFTDSJCF#PPLEP EFTDSJCFEFDP@UJUMFEP JU 

    Ͱғ·ΕͨλΠτϧΛฦ͢EP CPPL#PPLOFX UJUMF݄ͷϥΠΦϯ CPPLEFDP@UJUMFTIPVME ݄ͷϥΠΦϯ  FOE FOE FOE TQFDCPPL@TQFDSC ‏#PPLΫϥεͷ ‏EFDP@UJUMFϝιουʹ͍ͭͯ ͸Πϯελϯεϝιουͷҙ ‏͜͏ಈ࡞͢΂͖ ‏લ४උ ‏ςετίʔυɹίΞ෦෼ CPPLEFDP@UJUMFTIPVME ݄ͷϥΠΦϯ  ϙΠϯτ͸͜ͷίʔυͰ͢ɻTIPVME͕ςετͷͨΊͷϝιουɻ ʮCPPLEFDP@UJUMF͸ ݄ͷϥΠΦϯ ͱ ಉ͡ ʹͳΔ΂͖ʯ ͱ͍͏ςετίʔυͰ͢ɻ CPPLEFDP@UJUMFͷ݁Ռ͕ ݄ͷϥΠΦϯ ͷ৔߹ʹςετΛ௨ա͠·͢ɻ ҟͳΔ৔߹΍͏·͘ಈ͔ͳ͍৔߹͸ςετ͕ࣦഊ͠·͢ɻ
  11. HFNUXJUUFSCPPUTUSBQSBJMT HFNMFTTSBJMT (FNpMFΛՕॴฤू͠·͢ɻ CVOEMF ฤूͨ͠ΒCVOEMFίϚϯυͰมߋΛ൓өͤ͞·͢ɻ 5XJUUFS#PPUTUSBQΠϯετʔϧ 4FFIUUQTHJUIVCDPNTTUFQIFOTPOFYFDKTSFBENFGPSNPSFTVQQPSUFESVOUJNFT HFNUIFSVCZSBDFS QMBUGPSNTSVCZ HSPVQBTTFUTEPFOEͷதʹҎԼΛ௥ՃͰॻ͍͍ͯͩ͘͞ɻ

    ྫ͑͹HSPVQBTTFUTEPͷԼͷߦͱ͔ ҎԼͷίϝϯτߦઌ಄ͷΛ࡟ͬͯ༗ޮʹ͍ͯͩ͘͠͞ɻ ؀ڥʹΑͬͯQMBUGPSNTͷ෦෼͕ҟͳΔ͔΋͠Ε·ͤΜɻʣ 4FFIUUQTHJUIVCDPNTTUFQIFOTPOFYFDKTSFBENFGPSNPSFTVQQPSUFESVOUJNFT HFNUIFSVCZSBDFS QMBUGPSNTSVCZ ‐ίϨ࡟আ