File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ require_relative '../.tasks/helpers'
2+
3+ RSpec . describe Hash do
4+ describe '#recursive_merge' do
5+ it 'leaves the receiver alone' do
6+ main = { 'framework' => { 'version' => 1 } }
7+ main . recursive_merge ( 'framework' => { 'website' => 'first.example' } )
8+
9+ expect ( main ) . to eq ( 'framework' => { 'version' => 1 } )
10+ end
11+
12+ # .tasks/db.rake merges into the same main config once per framework, so a
13+ # value read here has to come from the hash passed in and from nothing else.
14+ it 'does not carry a value over to the next merge' do
15+ main = { }
16+ first = main . recursive_merge ( 'framework' => { 'website' => 'first.example' } )
17+ second = main . recursive_merge ( 'framework' => { 'version' => 2 } )
18+
19+ expect ( first . dig ( 'framework' , 'website' ) ) . to eq ( 'first.example' )
20+ expect ( second . dig ( 'framework' , 'website' ) ) . to be_nil
21+ end
22+
23+ it 'merges nested hashes' do
24+ config = { 'framework' => { 'version' => 1 , 'engines' => { 'node' => 'a' } } }
25+
26+ expect ( config . recursive_merge ( 'framework' => { 'engines' => { 'node' => 'b' , 'bun' => 'c' } } ) )
27+ . to eq ( 'framework' => { 'version' => 1 , 'engines' => { 'node' => 'b' , 'bun' => 'c' } } )
28+ end
29+ end
30+ end
Original file line number Diff line number Diff line change @@ -8,7 +8,11 @@ def normalize_shell(shell)
88end
99
1010class Hash
11+ # Returns a new hash and leaves the receiver alone. With `merge!` the receiver
12+ # kept every key it was ever merged with, so in .tasks/db.rake, where the same
13+ # main config is merged once per framework, a framework whose config.yaml does
14+ # not set a key got the value of the framework merged before it.
1115 def recursive_merge ( hash )
12- merge! ( hash ) { |_ , old , new | old . instance_of? ( Hash ) ? old . recursive_merge ( new ) : new }
16+ merge ( hash ) { |_ , old , new | old . instance_of? ( Hash ) ? old . recursive_merge ( new ) : new }
1317 end
1418end
Load diff This file was deleted.
Original file line number Diff line number Diff line change 11framework :
22 github : vlang/v
3+ version : 1822cbb4b5316f433df4805bb68560fadd4df385
34
45 # Install as the `vanilla` module (import vanilla.http_server). `v install <url>`
56 # now namespaces by owner (~/.vmodules/enghitalo/vanilla), so clone to the
Original file line number Diff line number Diff line change 11framework :
22 github : vlang/v
3+ version : 1822cbb4b5316f433df4805bb68560fadd4df385
34
45 # Install as the `vanilla` module (import vanilla.http_server). `v install <url>`
56 # now namespaces by owner (~/.vmodules/enghitalo/vanilla), so clone to the
Original file line number Diff line number Diff line change 11framework :
22 github : karlseguin/http.zig
3+ version : 52eb187cff75e168316b44480cd9f0fae26a1c5e
You can’t perform that action at this time.
0 commit comments