Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
cpanfile が Ruby でパースできることに気づいた俺たちは
Search
Takafumi ONAKA
PRO
September 08, 2018
0
51
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
強いチームと開発生産性
onk
PRO
39
13k
ADRを運用して3年経った僕らの現在地
onk
PRO
19
7.8k
すこやかなサービス運営のための PWG (Performance Working Group)
onk
PRO
0
42
オブザーバビリティの Primary Signals
onk
PRO
2
3.8k
Cache Stampede
onk
PRO
1
1.9k
ORM - Object-relational mapping
onk
PRO
2
3.4k
デュアルトラックアジャイルとの向き合い方
onk
PRO
4
11k
技術記事を書く&楽しむチームの作り方
onk
PRO
0
120
グルーミングしながら進めるプロダクト開発
onk
PRO
0
370
Featured
See All Featured
Designing for Performance
lara
604
68k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Writing Fast Ruby
sferik
627
61k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.2k
Navigating Team Friction
lara
183
15k
Statistics for Hackers
jakevdp
796
220k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
1
210
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Λࢼͯ͠ΈΔΤϯδχΞืू͍ͯ͠·͢