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
63
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
41
15k
ADRを運用して3年経った僕らの現在地
onk
PRO
20
17k
1文字エイリアスのすゝめ
onk
PRO
0
11
すこやかなサービス運営のための PWG (Performance Working Group)
onk
PRO
0
73
オブザーバビリティの Primary Signals
onk
PRO
2
4.1k
Cache Stampede
onk
PRO
1
2k
ORM - Object-relational mapping
onk
PRO
2
3.5k
デュアルトラックアジャイルとの向き合い方
onk
PRO
4
11k
技術記事を書く&楽しむチームの作り方
onk
PRO
0
160
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Producing Creativity
orderedlist
PRO
342
39k
Making the Leap to Tech Lead
cromwellryan
133
9k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
1
140
A better future with KSS
kneath
238
17k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Designing for humans not robots
tammielis
250
25k
The Invisible Side of Design
smashingmag
299
50k
Thoughts on Productivity
jonyablonski
68
4.4k
The World Runs on Bad Software
bkeepers
PRO
66
11k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
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Λࢼͯ͠ΈΔΤϯδχΞืू͍ͯ͠·͢