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
14k
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
Teambox: Starting and Learning
jrom
133
8.8k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
17k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
24k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
0
54
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
760
The World Runs on Bad Software
bkeepers
PRO
65
11k
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Λࢼͯ͠ΈΔΤϯδχΞืू͍ͯ͠·͢