Slide 1

Slide 1 text

ຖ೔ͷ։ൃʹ໾ཱͭ RailsϓϥάΠϯ
 ͮ͘Γͷൿ݃ @a_matsuda

Slide 2

Slide 2 text

࠷ॳʹ͓஌Βͤ 3ͭ

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

RubyKaigiͷLTͷϓϩϙʔβϧड෇தʂ ໌ޙ೔·Ͱʂ

Slide 5

Slide 5 text

RejectKaigiͷϓϩϙʔβϧ΋ืूதʂ ࠓ݄͍ͬͺ͍ʂ

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

Asakusa.rb Ֆݟ΍Γ·͢ʂ
 དྷिͷ౔༵೔ʂ

Slide 8

Slide 8 text

ࠓ೔࿩͢͜ͱ ൺֱత࠷ۙ࡞ͬͨgemͷ࿩ ͋Δ͍͸ ਓ͸ͳͥgemΛ࡞Δͷ͔

Slide 9

Slide 9 text

ࠓ೔࿩͢͜ͱ ͦΕ͔Βɺ

Slide 10

Slide 10 text

ࠓ೔࿩͢͜ͱ ςετίʔυ͕։ൃΛ
 υϥΠϒ͢Δ࿩

Slide 11

Slide 11 text

ࠓ೔࿩͞ͳ͍͜ͱ action_args active_decorator database_rewinder gem_src i18n_generators jb kaminari motorhead rfd stateful_enum string_template traceroute ...

Slide 12

Slide 12 text

Question

Slide 13

Slide 13 text

Կ͔࣮༻ϨϕϧͷgemΛࣗ෼Ͱ࡞ͬͯ
 ϦϦʔεͯ͠Έͨ͜ͱ͕͋Δਓ ✋

Slide 14

Slide 14 text

͍·खΛڍ͛ͯͳ͍ਓͨͪʹ
 ݴ͍͍ͨ

Slide 15

Slide 15 text

Why Don't You Create
 Your Own Gems?

Slide 16

Slide 16 text

ͳͥgemΛ࡞Βͳ͍ͷ͔ʁ ·ͨ͸ɺਓ͸ͳͥgemΛ
 ࡞Δͷ͔ʁ

Slide 17

Slide 17 text

๻ͷ৔߹͸ɺ΄΅100%
 ʮݱ৔ͷ໰୊Λղܾ͢ΔͨΊʯ

Slide 18

Slide 18 text

Case #1

Slide 19

Slide 19 text

ݱ৔ͷ໰୊ ςετ͸΋ͪΖΜॻ͔ͳͬͪ͘Ό͋
 ͍͚ͳ͍ Ͱ΋E2Eςετॻ͘ͷΊΜͲ͍ ߲໨͕૿͖͑ͯͨΓ͢ΔͱͭΒ͍

Slide 20

Slide 20 text

͖͔͚ͬ

Slide 21

Slide 21 text

͖͔͚ͬ

Slide 22

Slide 22 text

͖͔͚ͬ ৽نϓϩδΣΫτΛ࢝ΊΔʹ͋ͨͬͯɺ E2Eςετͱ͔͋Μ·Γॻ͍ͨ͜ͱ
 ͳ͍͍ͬͯ͏ए͍ϝϯόʔ΋ډͨ ୭Ͱ΋ςετ͕αΫαΫͬͱॻ͚Δͱ
 ͍͍ͳ͊ɺͱࢥͬͯ࡞ͬͯΈͨ

Slide 23

Slide 23 text

heavens_door

Slide 24

Slide 24 text

͜ͷgemΛ࡞Δʹ͋ͨͬͯ
 ؾΛ͚ͭͨ͜ͱ ͱʹ͔͘୯ػೳʹ͢Δ

Slide 25

Slide 25 text

ϒϥ΢βͷૢ࡞Λه࿥ͯ͠Capybaraͷ γφϦΦΛ࡞ΔϓϥάΠϯ ͘͢͝௚ײత

Slide 26

Slide 26 text

࢖͍ํ͸READMEʹషͬͨΞχϝgifΛ ݟΕ͹͙͢Θ͔ΔͷͰɺઆ໌͸লུ

Slide 27

Slide 27 text

heavens_door https:/ /github.com/ amatsuda/heavens_door

Slide 28

Slide 28 text

ͱ͜ΖͰɺ

Slide 29

Slide 29 text

͝هԱͷํ΋Կ໊͔͍Βͬ͠Όͬͨ Α͏Ͱ͕͢ɺ

Slide 30

Slide 30 text

࣮͸ɺ͜ͷίϯηϓτ͸શવ
 ৽͘͠ͳͯ͘ɺ

Slide 31

Slide 31 text

͸Δ͔ੲʹhocus_pocusͰ
 Ұ౓΍ͬͨ͜ͱͷম͖௚͠

Slide 32

Slide 32 text

Case #2

Slide 33

Slide 33 text

hocus_pocus ྺ࢙ͷڱؒʹຒ΋ΕͨΦʔύʔπ ௒ଟػೳͳϒϥ΢β಺౷߹։ൃ
 ؀ڥΈ͍ͨͳ΋ͷΛ໨ࢦͨ͠

Slide 34

Slide 34 text

͜Ε͸ɺԿ͔ղܾ͍ͨ͠໰୊͕͋ͬͨͱ͍͏ΑΓ͸ɺ ࡞Εͦ͏ͳؾ͕͔ͨ͠Β࡞Γ࢝ΊͯΈͨɺͱ͍͏ײ͡

Slide 35

Slide 35 text

hocus_pocusͷߏ଄ main_appʹmount͞Εͨhocus_pocus
 Τϯδϯ͕͞Βʹ4ͭͷαϒmountable engine Λmountͯ͠Δͱ͍͏ແବʹෳࡶͳߏ੒ ౰࣌ੈքॳͩͬͨ͸ͣͩ͠ɺͨͿΜະͩʹ
 ͦΜͳengine͸ଞʹແ͍ͷͰ͸ͳ͍͔

Slide 36

Slide 36 text

hocus_pocusͷࢥ૝ "resource missing" driven development ϖʔδ಺ʹWikiNameΛॻ͍ͨΒɺ
 ৽͍͠Wikiϖʔδ΁ͷϦϯΫʹͳͬͯ͘
 ͋ͷײ͡

Slide 37

Slide 37 text

ͱ͔2019೥ʹݴͬͯ΋ɺ͋Μ·Γ
 ఻ΘΒͳͦ͏ͳͷͰ

Slide 38

Slide 38 text

͓Αͦ7೥ͿΓʹDEMO

Slide 39

Slide 39 text

7೥લ

Slide 40

Slide 40 text

hocus_pocus https:/ /github.com/ amatsuda/hocus_pocus

Slide 41

Slide 41 text

9೥લʹ࡞Γ࢝Ίͨ΍ͭ ·ͬͨ͘ྲྀߦΒͳ͔ͬͨ ͱ͍͏͔׬੒͢Β͠ͳ͔ͬͨ

Slide 42

Slide 42 text

hocus_pocusͷͦͷޙ ૖େͳߏ૝͸৭ʑ͚͋ͬͨͲɺ
 ΍Δؾ͕࣋ଓͤͣʹdiscon

Slide 43

Slide 43 text

΋͏ͪΐ͍׬੒౓͕ߴ͘ͳͬͨΒυΩϡϝϯτ
 ͱ͔΋ͪΌΜͱॻ͜͏ɺͱࢥͬͯͨ ͚ͲɺͦΜͳ೔͸དྷͳ͔ͬͨ

Slide 44

Slide 44 text

͔͜͜Βಘͨڭ܇ ݱ৔ͷ໰୊υϦϒϯ͡Όͳ͍झຯͷ։ൃ͸Ϟνϕʔ γϣϯͷҡ͕࣋೉͍͠ খ͘͞࡞ͬͯૣΊʹϦϦʔεɺ͕΍ͬͺΓେࣄ υΩϡϝϯςʔγϣϯେࣄ ͦ΋ͦ΋࢖͍ํ͕೉͗͢͠Δπʔϧ͸࢖ͬͯ΋Β͑
 ͳ͍

Slide 45

Slide 45 text

খ͘͞࡞ͬͯૣΊʹϦϦʔεɺ
 ͕΍ͬͺΓେࣄ ࢥ͍͍ͭͨΞΠσΞ͸͙͢ʹ࣮૷ Ͱ͖ΔαΠζ͡Όͳ͍ͱɺͳΜ ͔ͩͬͨ๨ΕΔ

Slide 46

Slide 46 text

υΩϡϝϯςʔγϣϯ େ࡞ͳgem͸υΩϡϝϯτΛॻ͘
 োน͕ߴ͍ ͦ͏͍͏ҙຯͰ΋ػೳ͸গͳ͍
 ΄͏͕ྑ͍

Slide 47

Slide 47 text

ͦ΋ͦ΋࢖͍ํ͕೉͗͢͠Δπʔϧ ͸࢖ͬͯ΋Β͑ͳ͍ ίϯηϓτ͕ಛघͩͬͨΓ͢Δ ͱɺ఻ΘΒͣʹऴΘΔ

Slide 48

Slide 48 text

hocus_pocusͰͷࣦഊΛ׆͔ͯ͠ heavens_doorͰ΍ͬͯΈͨ͜ͱ

Slide 49

Slide 49 text

Ξχϝgif

Slide 50

Slide 50 text

Ξχϝgif͍͢͝

Slide 51

Slide 51 text

ʮݴ༿ʯͰͳ͘ʮ৺ʯͰ
 ཧղͰ͖Δʂ

Slide 52

Slide 52 text

Ͱ΋ɺ͜ͷϝιου͕ద༻Ͱ͖ΔRuby ͷϥΠϒϥϦ͸ͦΜͳʹଟ͘ͳ͍͔΋ʁ ࣮ࡍɺࣗ෼͕࡞ͬͨଞͷϥΠϒϥϦͰ͜ͷϝιου
 ͕׆༻Ͱ͖Δ͔Ͳ͏͔ߟ͑ͯΈ͚ͨͲɺ࣮ࡍͳ͔ͳ͔
 νϟϯε͸ͳͦ͞͏ ͯͳΘ͚ͰɺRubyͷϥΠϒϥϦΑΓ΋JSͱ͔ͷ
 ϥΠϒϥϦͷํ͕⭐ΛूΊ΍ͦ͢͏ɺ͍ͬͯ͏࿩͸
 ͋ΔΜͩΑͳ͊

Slide 53

Slide 53 text

ͱ͜ΖͰɺ͜ͷϒϥ΢β಺ͰΞϓϦ Λ։ൃ͍ͯ͘͠ͱ͍͏ίϯηϓτ 2019೥ʹͳͬͯɺ͋ͷ”conductor”͕ ੝Γ্͕ΓΛݟͤΔػӡ ͜Ε͔Β·ͩ·ͩՄೳੑͷ͋Δ෼໺
 ͳͷͰ͸

Slide 54

Slide 54 text

ͦ͜Ͱɺϒϥ΢βͰԿ͔͢Δ΍ͭΛ
 ΋͏1ͭ

Slide 55

Slide 55 text

Case #3

Slide 56

Slide 56 text

ݱ৔ͷ໰୊ ERਤ͕ݟ͍ͨʂ

Slide 57

Slide 57 text

ݱ৔ͰERਤݟ͍ͨͰ͢ΑͶʁ ͨͱ͑͹ͪΐͬͱΤϯλʔϓϥΠ ζͬΆ͍Ҋ݅ʹ్த͔Βࢀըͨ͠ ࣌ͱ͔

Slide 58

Slide 58 text

ͦ͜Ͱerd RailsΞϓϦʹmountͯ͠࢖͏ engine ਌ΞϓϦͷERਤΛϒϥ΢β಺ʹදࣔ ͍ͭͰʹૢ࡞

Slide 59

Slide 59 text

ૢ࡞ʁ create tableͱ͔alter tableͱ͔ migrationΛ࡞੒ɺ࣮ߦ migrationͷॻ͖ํΛ֮͑ΒΕͳ͍/ࢥ͍ग़ͤͳ͍
 ਓʹ͓͢͢Ί migration ͕ʮݴ༿ʯͰͳ͘ʮ৺ʯͰ(ry

Slide 60

Slide 60 text

DEMO

Slide 61

Slide 61 text

Status of erd ͥΜͥΜະ׬੒ UI͕͍Ζ͍ΖϏϛϣʔ ΋ͬͱϒϥογϡΞοϓ͍ͨ͠ؾ࣋ͪ͸͋Δ͚ͲJSॻ͘ͷ
 ͠ΜͲ͍ coffeeͰࡶʹॻ͍ͯdecafͨ͠ίʔυ͕΋͸΍ϝϯςෆೳϨϕϧ ୭͔JS͕ಘҙͳํɺॿ͚͍ͯͩ͘͞ʂʂʂʂ(੾࣮)

Slide 62

Slide 62 text

erd https:/ /github.com/ amatsuda/erd

Slide 63

Slide 63 text

ͯ͞ɺ࿩͸มΘͬͯɺϒϥ΢β্ͰΤϯϓϥ
 ͬΆ͍ਤΛදࣔ͢ΔengineΛ΋͏1ͭ

Slide 64

Slide 64 text

Case #4

Slide 65

Slide 65 text

ݱ৔ͷ໰୊ ࠓ౓͸ը໘ભҠਤ͕ݟ͍ͨʂ

Slide 66

Slide 66 text

͜Ε΋ݱ৔ͷ੾࣮ͳ໰୊ routes.rb ΛݟΕ͹Ϧιʔεͷ
 Ұཡ͸Θ͔Δ Ͱ΋ͭͳ͕Γ͸ݟ͑ͳ͍

Slide 67

Slide 67 text

΍ͬͺը໘ભҠਤ

Slide 68

Slide 68 text

ίϯηϓτ ը໘ભҠਤͬͯੲ͸ΈΜͳखඳ͖ ͯͨ͠΋ͷ͚ͩͲɺߟ͑ͯΈͨΒ ͜Εͬͯੜ੒Ͱ͖ΔΜ͡Όͳ͍ ͔ʁ

Slide 69

Slide 69 text

roundabout

Slide 70

Slide 70 text

DEMO

Slide 71

Slide 71 text

΍ͬͯΔ͜ͱ E2Eςετ಺Ͱ࣮ߦ͞Εͨը໘
 ભҠΛશͯه࿥ ͦͷ݁ՌΛਤࣔ

Slide 72

Slide 72 text

͜Ε͕ԿΛද͍ͯ͠Δͷ͔ ࣮ࡍʹ࣮૷͞Εͯͯςετ͞Εͯ ͍Δը໘ભҠΛه࿥ ͨͩͷ routes.rb ͷਤࣔͱ͸ҧ͏

Slide 73

Slide 73 text

ςετ͕ͪΌΜͱॻ͔Ε͍ͯΔ͔ͷ ֬ೝʹͳΔ ͋ΔҙຯΧόϨοδͷදࣔͷҰछ ͷΑ͏ͳ΋ͷͱݴ͑Δ͔΋

Slide 74

Slide 74 text

͜ͷgemͷΑ͞ ॻ͍ͨςετ͕ܗΛม͑ͨࢿ࢈ʹ ͳΔͷ͕Α͍

Slide 75

Slide 75 text

࣍͸΋͏1ͭɺςετࢿ࢈Λ׆͔͢΍ͭ Λ͝঺հ

Slide 76

Slide 76 text

Case #5

Slide 77

Slide 77 text

ݱ৔ͷ໰୊ RailsΞοϓάϨʔυͰσάϨ
 ͨ͘͠ͳ͍

Slide 78

Slide 78 text

still_life

Slide 79

Slide 79 text

still_lifeͰͰ͖Δ͜ͱ ςετΛ૸Βͤͨࡍʹɺςετத ʹrender͞ΕͨHTMLΛશ෦
 ϑΝΠϧʹॻ͖ग़͢

Slide 80

Slide 80 text

͍͢͝ྗٕͳϓϥάΠϯ

Slide 81

Slide 81 text

໨త ΞϓϦέʔγϣϯίʔυͷॻ͖׵͑
 લޙʹɺϢʔβʔʹಧ͚͍ͯΔ΋ͷ ͕มԽ͍ͯ͠ͳ͍͜ͱΛ֬ೝͰ͖Δ

Slide 82

Slide 82 text

ಛ௃ ը໘Λ౿ΜͰճΔ͚ͩͰྑͯ͘ɺ ΞαʔγϣϯΛॻ͔ͳͯ͘ྑ͍
 ͷͰָνϯ

Slide 83

Slide 83 text

Ͳ͏͍͏࣌ʹ࢖͏ͷ͔ ಛʹRailsͷΞοϓάϨʔυ͕
 ૝ఆ༻్ Ұൠతʹ֤छϦϑΝΫλϦϯάͷ ࢧԉʹͳΔ͸ͣ

Slide 84

Slide 84 text

ͦ΋ͦ΋ͷݩωλ 2011೥ʹɺΫοΫύουͷRails ͷόʔδϣϯΛ্͛Δ࣌ʹηίϯ ͞Μ͕ॻ͖ࣺͯͨεΫϦϓτ

Slide 85

Slide 85 text

https:/ /speakerdeck.com/a_matsuda/the-recipe- for-the-worlds-largest-rails-monolith?slide=129

Slide 86

Slide 86 text

cookpad

Slide 87

Slide 87 text

·͞ʹݱ৔ͷ໰୊Λత֬ʹղܾ͢Δ ৬ਓٕ

Slide 88

Slide 88 text

gemԽʹ͋ͨͬͯɺҎԼͷશ໘αϙʔτ
 Λ௥Ճ Capybara 3 RSpec 3 test-unit minitest

Slide 89

Slide 89 text

օ͞Μͷݱ৔Ͱ΋΋͏͖͡ Rails 5.2 -> 6.0 ͷΞοϓάϨʔυۀ͕࢝·Δͱࢥ͍·͕͢ɺ ͔ͳΓ༗༻͔΋͠Εͳ͍ͷͰɺ
 Ͳ͏ͧ͝׆༻͍ͩ͘͞

Slide 90

Slide 90 text

ͱ͜ΖͰɺ͜ͷϥΠϒϥϦͷओͳೳྗ͸
 ΞϓϦΛ͜͡։͚ͯಈ࡞Λه࿥͢Δελϯυ ͜ͷೳྗͬͯɺ͜Εͦ͜
 "heavens_door" ͡Ό͋Ͷ͔͑ʂ

Slide 91

Slide 91 text

ͱࢥ͚ͬͨͲɺͦͷ໊લͷgem͸طʹ औΒΕͯ͠·͍ͬͯͨͷͰ͋ͬͨ

Slide 92

Slide 92 text

໊લॏཁ gemͷ໊લ͚ͭΔͷ೉͍͠……

Slide 93

Slide 93 text

͜ΕΛ8೥ӽ͠ͰgemԽ͖͔͚ͨͬ͠ ࣗ࡞ςϯϓϨʔτΤϯδϯͷಈ࡞ݕূͷ ͨΊʹཉ͘͠ͳͬͨ ๭ΠϯλʔωοτՈܭ฽ͷRailsΞοϓ άϨʔυͷࡍʹ͜ΕͷଘࡏΛࢥ͍ग़ͨ͠

Slide 94

Slide 94 text

Money Forward

Slide 95

Slide 95 text

ʮࣗ࡞ςϯϓϨʔτΤϯδϯʯ

Slide 96

Slide 96 text

Case #6

Slide 97

Slide 97 text

Himl

Slide 98

Slide 98 text

Himl ͖͔͚ͬ͸ɺӬ࿨γεςϜϚωδ ϝϯτͰຖ݄΍ͬͯΔOSSύον ձ

Slide 99

Slide 99 text

ͷ͋ͱͷҿΈձ

Slide 100

Slide 100 text

Ӭ࿨γεςϜϚωδϝϯτ

Slide 101

Slide 101 text

kamipo͞Μͷ۪ஒ kamipo: ձࣾͰHaml࢖ͬͯΔ͚ͲɺHaml ͱ͔Slimͱ͔จ๏͕Ṗ֮͗ͯ͑͢ΒΕ΁Μ ΘɻERBͰྑ͘ͳ͍ʁ me: ͍΍ʔɺHaml௒͍͍ͬ͢ΑɻERBʹ໭ Δͱ͔ϜϦϜϦɻ

Slide 102

Slide 102 text

͔͠͠ɺ͋ΒͨΊͯɺHamlͷྑͬͯ͞ ͳΜͩΖ͏ʁ ͔֬ʹɺ͋ͷه߸ͨͪΛۦ࢖ͨ͠จ๏ࣗମ ͸Hamlͷྑ͞ͷຊ࣭Ͱ͸ͳ͍͔΋ Hamlͷྑ͞͸ɺλάΛػց͕ดͯ͘͡ΕΔ ͓͔͛ͰɺίϯύΠϧ͞ΕͨHTML͕valid ͳ͜ͱ͕อূ͞ΕΔͱ͜Ζ

Slide 103

Slide 103 text

͡Ό͋ɺHamlͷྑ͞ΛERBʹ஫ೖͯ͠ ΍Ε͹ྑ͍ͷͰ͸ʁ

Slide 104

Slide 104 text

Αͦ͞͏ɺ͔΋͠Εͳ͍

Slide 105

Slide 105 text

ͷͰ࡞ͬͯΈͨ

Slide 106

Slide 106 text

Himl https:/ /github.com/ amatsuda/himl

Slide 107

Slide 107 text

ࠓճͷݱ৔͸… ਆాͷͱ͋Δډञ԰

Slide 108

Slide 108 text

Himlͷ։ൃΛ௨ͯ͡Θ͔ͬͨ͜ͱ

Slide 109

Slide 109 text

ډञ԰ͩͬͯݱ৔ͳΜ΍ʂ

Slide 110

Slide 110 text

·ͱΊ

Slide 111

Slide 111 text

ਓ͸ͳͥgemΛ࡞Δͷ͔ʁ ໰୊Λղͨ͘Ί

Slide 112

Slide 112 text

໰୊͸ͨ͘͞Μݱ৔ʹస͕ͬͯΔ

Slide 113

Slide 113 text

͜͏͍͏໰୊ͷղ͖ํ΋͍͍Μ͡Ό ͳ͍Ͱ͠ΐ͏͔ʁ ͳ͔ͳָ͔͍͠Ͱ͢Α

Slide 114

Slide 114 text

Why Don't You Create Your Own Gems? gem࡞Ζʔͥʂ

Slide 115

Slide 115 text

end

Slide 116

Slide 116 text

me Name: Akira Matsuda Twitter: @a_matsuda GitHub: amatsuda