Slide 1

Slide 1 text

ྑ͍ΠϯλʔϑΣΠεͷ୳ٻ ίϚϯυύλʔϯΛྫʹ େ૔խ࢙ʢ@okuramasafumiʣ ໊ݹ԰Rubyձٞ04―େਢԋܳ৔ 2019-06-08ʢ౔ʣ

Slide 2

Slide 2 text

ࠓ೔ͷൃද͸࿩୊͕͋ͪͪ͜ʹ ભҠ͍͖ͯ͠·͢ɻ མޠͩͱࢥָͬͯ͠Έͳ͕Β ͓͔͚͖͍ͬͯͯͩ͘͞!

Slide 3

Slide 3 text

pp self • ໊લɿ΂͢ͱ௾·͞;Έʢେ૔խ࢙ʣ • ॴଐɿϑϦʔϥϯε • ׆ಈ৔ॴɿ౦ژ • ޷͖ͳgemɿPry, RSpec • ӡӦͯ͠ΔίϛϡχςΟɿGrow.rb

Slide 4

Slide 4 text

໊ݹ԰Rubyձٞ

Slide 5

Slide 5 text

໊ݹ԰Rubyձٞ

Slide 6

Slide 6 text

զʑ͸ͳͥRubyΛ࢖͏ͷ͔

Slide 7

Slide 7 text

Rubyͷ࿩

Slide 8

Slide 8 text

զʑ͸ͳͥRubyΛ࢖͏ͷ͔ • ॻ͖΍͍͢ • ʮॻ͖΍͢͞ʯͬͯͳΜͩΖ͏ • ಡΈ΍͍͢ • ʮಡΈ΍͢͞ʯͬͯ(ry • Rails

Slide 9

Slide 9 text

զʑ͕RubyΛ࢖͏ཧ༝

Slide 10

Slide 10 text

ϓϩάϥϛϯάָ͕͍͠

Slide 11

Slide 11 text

ͳͥRubyͰϓϩάϥϛϯάΛ͢Δͱ ָ͍͠ͷͩΖ͏͔ʁ

Slide 12

Slide 12 text

https://www.atmarkit.co.jp/news/ 200907/24/ruby2.html

Slide 13

Slide 13 text

yuguiɿ ͦΕ͸ɺίϨΫγϣϯ͕͋ͬͯγϟοϑϧ ͍ͨ͠ͱࢥͬͨΒɺshuffleͱॻ͍ͯɺͦΕ Ͱಈ͔ͳ͖Ό͍͚ͳ͍ΜͰ͢Αɻ

Slide 14

Slide 14 text

ࢥͬͨͱ͓Γʹಈ͘ ʢৗʹಈ͘ͱ͸ݴ͍ͬͯͳ͍ʣ

Slide 15

Slide 15 text

ͱ͜ΖͰɿ ͳΜͰ͜ͷ࿩Λ͍ͯ͠Δͷ͔

Slide 16

Slide 16 text

ָ͘͠ϓϩάϥϛϯάͰ͖Δ ྖҬΛ޿͍͛ͨʂ

Slide 17

Slide 17 text

ϥΠϒϥϦΛॻ͍ͯΈΑ͏ →ॻ͖·ͨ͠

Slide 18

Slide 18 text

https://github.com/okuramasafumi/ neco

Slide 19

Slide 19 text

150ߦͪΐ͍ͷϥΠϒϥϦ

Slide 20

Slide 20 text

2ճ΄Ͳॻ͖௚͍ͯ͠Δ

Slide 21

Slide 21 text

ΠϯλʔϑΣΠεʹೲಘ͕͍͔ͳ͔ͬͨ

Slide 22

Slide 22 text

ΠϯλʔϑΣΠεʹ͍ͭͯ ͍Ζ͍Ζߟ͑ͨͷͰɺ ͦͷ੒ՌʢʁʣΛڞ༗͍ͨ͠

Slide 23

Slide 23 text

ͦ΋ͦ΋ɿ ΠϯλʔϑΣΠεͬͯ ͳΜ͚ͩͬʁ

Slide 24

Slide 24 text

Interface (MacOSͷࣙॻΑΓ) 1. a point where two systems, subjects, organizations, etc. meet and interact 2. Computing a device or program enabling a user to communicate with a computer

Slide 25

Slide 25 text

ΠϯλʔϑΣΠε͸ ίϯϐϡʔλͱͷίϛϡχέʔγϣϯ ͷͱΓํΛܾఆ͢Δ΋ͷ

Slide 26

Slide 26 text

ΠϯλʔϑΣΠεʹϝιου

Slide 27

Slide 27 text

ΠϯλʔϑΣΠεʹϝιουγάχνϟ

Slide 28

Slide 28 text

ʮࢥͬͨͱ͓Γʹಈ͘ʯ

Slide 29

Slide 29 text

Ruby͸ ΠϯλʔϑΣΠεʢ㲓ϝιουγάχνϟʣ ͕ྑ͍͔Β࢖ΘΕ͍ͯΔ

Slide 30

Slide 30 text

DSL

Slide 31

Slide 31 text

ҎԼɺ ʮDSLʯ͸ʮݴޠ಺DSLʯΛࢦ͠·͢

Slide 32

Slide 32 text

Domain Specific Language

Slide 33

Slide 33 text

Ruby͕࢖ΘΕΔཧ༝ͷҰͭ

Slide 34

Slide 34 text

RubyʹΑΔDSLͷ۩ମྫ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • Puppet΍ChefɺVagrantʢDevOpsܥʣ • HomebrewʢύοέʔδϚωʔδϟʣ

Slide 35

Slide 35 text

ڞ௨఺

Slide 36

Slide 36 text

DSL͸Կ͔Λఆ͍ٛͯ͠Δ

Slide 37

Slide 37 text

RubyʹΑΔDSLͷ۩ମྫʢ࠶ܝʣ • ActiveRecordʢRailsܥʣ • RakeʢϏϧυܥʣ • RSpecʢBDDʣ • Puppet΍ChefɺVagrantʢDevOpsܥʣ • HomebrewʢύοέʔδϚωʔδϟʣ

Slide 38

Slide 38 text

RubyʹΑΔDSLͷ۩ମྫʢఆٛྫ෇͖ʣ • ActiveRecordʢσʔλϞσϧͷఆٛʣ • RakeʢϏϧυϓϩηεͷఆٛʣ • RSpecʢ๬·ΕΔৼΔ෣͍ͷఆٛʣ • Puppet΍ChefɺVagrantʢ֤छΠϯϑϥϦιʔεͷఆٛʣ • Homebrewʢύοέʔδͷఆٛʣ

Slide 39

Slide 39 text

ͱ͜ΖͰɿ DSL͸୯ͳΔΫϥεϝιου ʢͷ৔߹͕ଟ͍ʣ

Slide 40

Slide 40 text

ͭ·Γɿ DSL΋·ͨΠϯλʔϑΣΠε

Slide 41

Slide 41 text

͜͜·Ͱͷ·ͱΊ • ΠϯλʔϑΣΠε͕ྑ͍ͱָ͘͠ϓϩάϥϛϯάͰ͖Δ • ΠϯλʔϑΣΠεͱ͸͍͍ͩͨϝιουγάχνϟͷ͜ͱ • ֤ॴͰ࢖ΘΕ͍ͯΔDSL΋࣮͸ͨͩͷϝιου • DSL͸ʮఆٛʯʹڧ͍ • ΠϯλʔϑΣΠε͸ʮ७ਮͳϝιουʯͱDSLʹ෼͚ΒΕΔ

Slide 42

Slide 42 text

https://rubykaigi.org/2019/ presentations/tanaka_akr.html

Slide 43

Slide 43 text

ྑ͍ΠϯλʔϑΣΠεͬͯ ͳΜͩΖ͏ʁʁʁ

Slide 44

Slide 44 text

⚠ ͜Ε͸͢΂ͯࢲͷ୯ͳΔҰҙݟͰ͢ Ͳ͔ͬͪͱ͍͏ͱ൓࿦͕΄͍͠… ࠙਌ձͰ͓࿩͠·͠ΐ͏

Slide 45

Slide 45 text

ྑ͍ΠϯλʔϑΣΠεͷ̏ݪଇ • ໎Θͳ͍ • ґଘ͠ͳ͍ • ೚ͤ͗͢ͳ͍

Slide 46

Slide 46 text

໎Θͳ͍ • ϝιου໊ʹࡾ୯ݱͷʮsʯ͸ඞཁ͚ͩͬʁ • ͋ͷΫϥε͸callͰݺͿΜ͚ͩͬɺperform͚ͩͬʁ • Πϯελϯεϝιου͚ͩͬɺΫϥεϝιου͚ͩͬʁ • Ҿ਺ͷॱং͸ʁ

Slide 47

Slide 47 text

ґଘ͠ͳ͍ • ϝιουνΣʔϯΛલఏͱ͠ͳ͍ʢಛఆͷฦΓ஋ʹґଘ͠ͳ ͍ʣ • ςετ࣌ͷελϒ͕ߴʑҰͭͰࡁΉ

Slide 48

Slide 48 text

೚ͤ͗͢ͳ͍ • ΤϯυϢʔβʔ͕ࣗྗͰͰ͖Δ͜ͱ͸΍Βͳ͍ • ୯७ͳόϦσʔγϣϯʹෳࡶͳDSL͸ຊ౰ʹඞཁ͔ʁ • ΤϯυϢʔβʔ͕ࣗྗͰ΍ΓͮΒ͍͜ͱΛ΍Δ • νΣʔϯͨ͠ϩʔϧόοΫॲཧ͸ࣗྗͰ͸೉͍͠ʢޙड़ʣ

Slide 49

Slide 49 text

௨ৗͷϝιου͔DSL͔ɺ ͦΕ͕໰୊ͩ

Slide 50

Slide 50 text

શ෦ϝιουͰ͍͍͡ΌΜɺ DSLͱ͔֮͑Δͷେมͩ͠ʂ Pure Ruby࠷ߴʂ

Slide 51

Slide 51 text

ͱࢥͬͯͨ࣌ظ͕๻ʹ΋͋Γ·ͨ͠…

Slide 52

Slide 52 text

ϝιουΠϯλʔϑΣΠεͷ௕ॴ • Ҿ਺΍selfͳͲ͕ࣗ໌ • ܧঝͨ͠ͱ͖ʹಈ࡞͕ཧղ͠΍͍͢ • ͦ͜ʹʮࠇຐज़ʯ͸ͳ͍

Slide 53

Slide 53 text

ϝιουΠϯλʔϑΣΠεͷ୹ॴ • ॊೈͳڍಈΛఏڙ͢ΔࡍʹϢʔβʔ͕ॻ͘΂͖ϝιου͕൥ࡶ ʹͳΓ͕ͪ • ϥΠϒϥϦ͕ϑϩʔΛίϯτϩʔϧ͠Α͏ͱ͢Δࡍʹඞཁͳ ϑοΫΛࠩ͠ڬΉͷ͕೉͍͠ʢϢʔβʔʹଟ਺ͷϝιουΛఆ ٛͯ͠΋Β͏ඞཁ͕ग़ͯ͘Δʣ

Slide 54

Slide 54 text

DSLͷ௕ॴ • ϒϩοΫҾ਺͸ϝιουҾ਺ΑΓॊೈ • ద੾ʹ໋໊͞Ε͍ͯΔ৔߹ɺՄಡੑ͕ߴ͍ • ϥΠϒϥϦ͕೚ҙͷॲཧΛϢʔβʔఆٛͷॲཧʹڬΈࠐΊΔ ʢϑοΫ΍ΩϟογϡͳͲʣ • ԿΛ͍ͨ͠ͷ͔ͷʮఆٛʯΛએݴతʹॻ͚Δ

Slide 55

Slide 55 text

DSLͷ୹ॴ • ʮࠇຐज़ʯ͕ଟ͘ͳΓ͕ͪͷͰɺڍಈΛਖ਼֬ʹ೺Ѳ͢Δͷ͕ࠔ ೉ • ద੾ʹ໋໊͞Ε͍ͯͳ͍৔߹ɺՄಡੑ͕ஶ͘͠མͪΔέʔε͕ ͋Δ • ϝλϓϩάϥϛϯάΛར༻͢Δ৔߹ɺσόοά͕ࠔ೉ʹͳΔ

Slide 56

Slide 56 text

ॊೈੑͷ఺ͰDSL͕༏Ґ

Slide 57

Slide 57 text

͡Ό͋શ෦DSLΛ༻ҙ͠·͘Ε͹ ͦΕͰ͍͍ͷ͔ʂʁ

Slide 58

Slide 58 text

ࠇຐज़͡Όͳ͍ͷͦΕʁ

Slide 59

Slide 59 text

DSL͸ຐज़౓͕௿͍ ʢby Joker1007ʣ

Slide 60

Slide 60 text

൑அ͕೉͍͠έʔε΋

Slide 61

Slide 61 text

ྫɿ όϦσʔγϣϯ͸ఆٛͳͷͰDSLΛ࢖͏ ͔͠͠ɺܕνΣοΫΛDSLͰߦ͏΂͖͔ʁ

Slide 62

Slide 62 text

ճ౴ྫɿ ೚ͤ͗͢ͳ͍ݪଇʹै͍ɺ࣮ࡍͷ όϦσʔγϣϯ͸Ϣʔβʔʹ೚ͤΔɺ ϥΠϒϥϦ͸όϦσʔγϣϯఆٛͷ ϑοΫDSLͷΈఏڙ

Slide 63

Slide 63 text

۩ମྫ ʢࠓճͷυϝΠϯ͸ίϚϯυύλʔϯʣ

Slide 64

Slide 64 text

Neco͸ϏδωεϩδοΫΛ ʮίϚϯυʯʹ෼ׂ͠ɺ ͦΕΒΛ૊Έ߹ΘͤΔϑϩʔΛ ࢧԉ͢ΔϥΠϒϥϦ

Slide 65

Slide 65 text

·ͱΊ • ͔ͤͬ͘RubyͰॻ͍ͯΔΜ͔ͩΒΠϯλʔϑΣΠεʹ͸ͩ͜Θ Γ͍ͨʢ࢖ָ͍ͬͯ͠ϥΠϒϥϦ͕΄͍͠ʣ • DSL͸RubyͷڧΈͰ΋͋Γɺద੾ʹ໋໊ɾ࣮૷͢Ε͹୯७ͳϝ ιουΑΓॊೈͳఆٛΠϯλʔϑΣΠεΛఏڙͰ͖Δ • ͕Μ͹ͬͯॊೈͳ࢖͍উखΛ໨ࢦͯ͠ΔͷͰNeco࢖ͬͯ͘ΕΑͳʢએ఻ʣ