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
49
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
16
7.1k
すこやかなサービス運営のための PWG (Performance Working Group)
onk
PRO
0
20
オブザーバビリティの Primary Signals
onk
PRO
2
3.4k
Cache Stampede
onk
PRO
1
1.9k
ORM - Object-relational mapping
onk
PRO
1
3.4k
デュアルトラックアジャイルとの向き合い方
onk
PRO
4
11k
技術記事を書く&楽しむチームの作り方
onk
PRO
0
65
グルーミングしながら進めるプロダクト開発
onk
PRO
0
70
エンジニアの個人ブランディングと技術組織
onk
PRO
0
64
Featured
See All Featured
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Gamification - CAS2011
davidbonilla
80
5k
Designing for Performance
lara
604
68k
Intergalactic Javascript Robots from Outer Space
tanoku
268
27k
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.2k
Being A Developer After 40
akosma
86
590k
Ruby is Unlike a Banana
tanoku
96
11k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
The Cost Of JavaScript in 2023
addyosmani
45
6.6k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
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Λࢼͯ͠ΈΔΤϯδχΞืू͍ͯ͠·͢