Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
cpanfile が Ruby でパースできることに気づいた俺たちは
Search
Takafumi ONAKA
PRO
September 08, 2018
0
50
cpanfile が Ruby でパースできることに気づいた俺たちは
2018-09-08 builderscon tokyo 2018
初出:
https://www.slideshare.net/takafumionaka/cpanfileruby
Takafumi ONAKA
PRO
September 08, 2018
Tweet
Share
More Decks by Takafumi ONAKA
See All by Takafumi ONAKA
ADRを運用して3年経った僕らの現在地
onk
PRO
17
7.4k
すこやかなサービス運営のための PWG (Performance Working Group)
onk
PRO
0
23
オブザーバビリティの Primary Signals
onk
PRO
2
3.5k
Cache Stampede
onk
PRO
1
1.9k
ORM - Object-relational mapping
onk
PRO
1
3.4k
デュアルトラックアジャイルとの向き合い方
onk
PRO
4
11k
技術記事を書く&楽しむチームの作り方
onk
PRO
0
80
グルーミングしながら進めるプロダクト開発
onk
PRO
0
93
エンジニアの個人ブランディングと技術組織
onk
PRO
0
79
Featured
See All Featured
BBQ
matthewcrist
85
9.3k
Music & Morning Musume
bryan
46
6.2k
Facilitating Awesome Meetings
lara
49
6.1k
Docker and Python
trallard
40
3.1k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Put a Button on it: Removing Barriers to Going Fast.
kastner
59
3.5k
Speed Design
sergeychernyshev
24
600
Optimizing for Happiness
mojombo
376
69k
How to Ace a Technical Interview
jacobian
276
23k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Transcript
DQBOpMF͕3VCZͰύʔεͰ͖Δ ͜ͱʹؾ͍ͮͨԶͨͪ CVJMEFSTDPOUPLZP େೳ࢙BLBJEPOL
ࣗݾհ w େೳ࢙BLBJEPOL w ͯͳͱ͍͏ձࣾͰɺ1FSMΛॻ͍͍ͯ·͢ɻ ژ͔Βདྷ·ͨ͠ w ࠓͷ݄·Ͱલ৬Ͱ3VCZΛॻ͍͍ͯ·ͨ͠ɻ 3VCZྺ͙Β͍
લճͷϥʂ
1FSM͍ͷࠃͷ3VCZJTU w
1FSM͔Β3VCZ w
ࠓͷ
DQBOpMFΛ requires 'Plack'; ... on test => sub { requires
'Test2', '1.302138'; ... }
DQBOpMFΛ3VCZͰʜʜʁ $ ruby -cw cpanfile Syntax OK
͍ͭ͜ʜʜಈͧ͘ʜʜʂ
ͱ͍͏Ͱ͢ w ΑΖ͓͘͠ئ͍͠·͢
DQBOpMFͱ
DQBOpMFͱ w ϓϩδΣΫτͰ͏$1"/ϞδϡʔϧͷҰཡΛॻ͘ͷ w 3VCZͰ͍͏(FNpMF HFNpMFSC
DQBOpMFͷTZOUBY # requires Ͱ ͍͍ͨ CPAN Module ΛฒΔ requires 'Plack';
... # ಛఆͷ env ͰͷΈ͍͍ͨͷ on <ENV> Ͱ sub Λ͢ on test => sub { # ୈ2ҾͰόʔδϣϯݻఆ͍ͯ͠Δ߹͋Δ requires 'Test2', '1.302138'; ... }
DQBOpMFͷTZOUBY w 3VCZతʹ͜ͷDQBOpMFͲͷΑ͏ʹύʔε͞ΕΔ͔ w ৄ͘͠SVCZEVNQQBSTFUSFFDQBOpMFΛ࣮ߦ
DQBOpMFͷTZOUBYJO3VCZ w ͜ͷߦ3VCZͰಈ͘͜ͱ͕໌ന w SFRVJSFTϝιουʹจࣈྻͷҾΛ͍ͯ͠Δ w ߦͷηϛίϩϯ͕͋ͬͯͳ͍ requires 'Plack';
DQBOpMFͷTZOUBYJO3VCZ w ίον w ͜ΕΛ͏ͪΐͬͱ͚ͩΧοίΛิ͢Δͱ on test => sub {
requires 'Test2', '1.302138'; }
DQBOpMFͷTZOUBYJO3VCZ w ίον w ͜ΕΛ͏ͪΐͬͱ͚ͩΧοίΛิ͢Δͱ on({ test => sub {
requires 'Test2', '1.302138'; } })
DQBOpMFͷTZOUBYJO3VCZ w POϝιουʹϋογϡΛ͍ͯ͠Δ on({ test => sub { requires 'Test2',
'1.302138'; } })
DQBOpMFͷTZOUBYJO3VCZ w ϋογϡͷΩʔUFTUϝιου on({ test => sub { requires 'Test2',
'1.302138'; } })
DQBOpMFͷTZOUBYJO3VCZ w ϋογϡͷΩʔUFTUϝιου w ϋογϡͷόϦϡʔTVCϝιουʹϒϩοΫΛͨ͠ͷ on({ test => sub {
requires 'Test2', '1.302138'; } })
DQBOpMFͷTZOUBYJO3VCZ w ϋογϡͷΩʔUFTUϝιου w ϋογϡͷόϦϡʔTVCϝιουʹϒϩοΫΛͨ͠ͷ w ϒϩοΫͷதSFRVJSFTϝιουʹҾΛͨ͠ͷ on({ test =>
sub { requires 'Test2', '1.302138'; } })
DQBOpMFͷTZOUBYJO3VCZ w ͜͜·Ͱ͔ΕධՁͰ͖Δʂʂʂʂʂʂʁ on({ test => sub { requires 'Test2',
'1.302138'; } })
3VCZͰDQBOpMFΛධՁ͢Δ
3VCZͰDQBOpMFΛධՁ͢Δ w SFRVJSFTPSҾΛड͚औΔϝιου requires ‘Plack'; requires 'Test2', '1.302138';
3VCZͰDQBOpMFΛධՁ͢Δ w SFRVJSFTPSҾΛड͚औΔϝιου w ͱΓ͋͑ͣͲΜͳϞδϡʔϧΛ͍͍͔͔ͨΔΑ͏ʹɺΠϯελ ϯεมʹͰ٧Ί͓ͯ͜͏ @requires = [] def
requires(module_name, version = nil) @requires << [module_name, version] end
3VCZͰDQBOpMFΛධՁ͢Δ w POϋογϡΛҾʹऔΔϝιου on({ test => sub { requires 'Test2',
'1.302138'; } })
3VCZͰDQBOpMFΛධՁ͢Δ w POϋογϡΛҾʹऔΔϝιου w ͱΓࣺ͋͑ͣͯΕ͍͍͔ͳɻɻ w ͋ͱͰ͏Α͏ʹվળ͠·͢ ޙड़ def on(_hash)
# nop end
3VCZͰDQBOpMFΛධՁ͢Δ w UFTUϋογϡͷΩʔ on({ test => sub { requires 'Test2',
'1.302138'; } })
3VCZͰDQBOpMFΛධՁ͢Δ w UFTUϋογϡͷΩʔ w ͳͷͰɺจࣈྻͷlUFTUzͰฦ͓͚ͯ͠ྑ͍ w Կฦ͞ͳͯ͘OJM͕ΩʔʹͳΔ͚ͩͰ͢ def test "test"
end
3VCZͰDQBOpMFΛධՁ͢Δ w TVCϒϩοΫΛड͚औΔϝιου on({ test => sub { requires 'Test2',
'1.302138'; } })
3VCZͰDQBOpMFΛධՁ͢Δ w TVCϒϩοΫΛड͚औΔϝιου w ZJFME͠·͢ def sub yield end
3VCZͰDQBOpMFΛධՁ͢Δ w TVCϒϩοΫΛड͚औΔϝιου w ZJFME͠·͢ w ༨ஊ POΛ༗ޮʹ͏ͨΊʹԆධՁͤ͞ΔͷͰMBNCEBͰแΉ def sub
-> { yield } end def on(hash) hash.each do |env, sub| sub.call end end
3VCZͰDQBOpMFΛධՁ͢Δ w ͋ͱ࣮ߦ͢Δ͚ͩʂʂʂ w σϞ eval File.read("./cpanfile") pp @requires
3VCZͰDQBOpMFΛධՁ͢Δ w ͋ͱ࣮ߦ͢Δ͚ͩʂʂʂ $ ruby cpanfile_parser.rb [["Plack", nil], ["Test2", "1.302138"]]
DQBOpMFΛධՁͰ͖ΔͱԿ ͕Ͱ͖Δ͔
DQBOpMFΛධՁͰ͖ΔͱԿ͕Ͱ͖Δ͔ w %FQFOEBCPUΛ࡞Δ͜ͱ͕Ͱ͖Δ w ϓϩδΣΫτ͕ґଘ͍ͯ͠ΔϥΠϒϥϦͷҰཡදࣔ w ࠷৽όʔδϣϯΑΓݹ͍όʔδϣϯͰݻఆ͍ͯͨ͠ΒܯࠂΛग़͢
DQBOpMFΛධՁͰ͖ΔͱԿ͕Ͱ͖Δ͔ w %FQFOEBCPUΛ࡞Δ͜ͱ͕Ͱ͖Δ w ϓϩδΣΫτ͕ґଘ͍ͯ͠ΔϥΠϒϥϦͷҰཡදࣔ w ࠷৽όʔδϣϯΑΓݹ͍όʔδϣϯͰݻఆ͍ͯͨ͠ΒܯࠂΛग़͢ w ͱ͍͏Θ͚Ͱ࡞Γ·ͨ͠ EFNP
DQBOpMFΛධՁͰ͖ΔͱԿ͕Ͱ͖Δ͔
ఆ2"
21FSM͡Όμϝͩͬͨͷ w μϝͳΘ͚͕ͳ͍ w ໘നશ෦Ͱ3VCZͰ࣮͠·ͨ͠
ͯͳͰ1FSMϓϩάϥϜʹ3VCZͰ4ZOUBY $IFDLΛࢼͯ͠ΈΔΤϯδχΞืू͍ͯ͠·͢