Skip to content

Commit

Permalink
Merge pull request #24 from lzhan/merge
Browse files Browse the repository at this point in the history
Add more details on merge log
  • Loading branch information
lzhan committed Nov 20, 2013
2 parents f65268e + 76b423e commit 2550d8b
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 16 deletions.
12 changes: 8 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Ycb.prototype = {
if (options.validate) {
console.log('The YCB option "validate" is not implemented yet.');
}

delete config.__ycb_source__;
return config;
},

Expand Down Expand Up @@ -361,7 +361,7 @@ Ycb.prototype = {
part,
kv,
context,
setting,
settings,
key;

// Extract each section from the bundle
Expand All @@ -384,7 +384,7 @@ Ycb.prototype = {
}
context[kv[0]] = kv[1];
}
setting = section.settings;
settings = section.settings;
// Remove the settings key now we are done with it
delete section.settings;

Expand All @@ -397,7 +397,11 @@ Ycb.prototype = {
this.settings[key] = section;
} else {
if (options.debug) {
console.log("Merging sections for setting: " + setting);
console.log('Merging section ' + JSON.stringify(settings) + (
section.__ycb_source__ ? (' from ' + section.__ycb_source__) : ''
) + (
this.settings[key] ? (' onto ' + this.settings[key].__ycb_source__) : ''
));
}
objectMerge(section, this.settings[key]);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/fixtures/simple-1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"links": {
"home": "http://www.yahoo.com",
"mail": "http://mail.yahoo.com"
}
},
"__ycb_source__": "tests/fixtures/simple-1.json"
}
]
3 changes: 2 additions & 1 deletion tests/fixtures/simple-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"links": {
"home": "http://www.yahoo.com",
"mail": "http://mail.yahoo.com"
}
},
"__ycb_source__": "tests/fixtures/simple-2.json"
}
]
24 changes: 16 additions & 8 deletions tests/fixtures/simple-3.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"links": {
"home": "http://ca.yahoo.com",
"mail": "http://ca.mail.yahoo.com"
}
},
"__ycb_source__": "tests/fixtures/simple-3.json"
},
{
"settings": ["region:gb"],
Expand All @@ -15,12 +16,14 @@
"links": {
"home": "http://gb.yahoo.com",
"mail": "http://gb.mail.yahoo.com"
}
},
"__ycb_source__": "tests/fixtures/simple-3.json"
},
{
"settings": ["lang:fr"],

"logo": "yahoo_FR.png"
"logo": "yahoo_FR.png",
"__ycb_source__": "tests/fixtures/simple-3.json"
},
{
"settings": ["region:fr"],
Expand All @@ -29,26 +32,31 @@
"links": {
"home": "http://fr.yahoo.com",
"mail": "http://fr.mail.yahoo.com"
}
},
"__ycb_source__": "tests/fixtures/simple-3.json"
},
{
"settings": ["flavor:att"],

"logo": "yahoo_att.png"
"logo": "yahoo_att.png",
"__ycb_source__": "tests/fixtures/simple-3.json"
},
{
"settings": ["flavor:att","region:ca"],

"logo": "yahoo_att_CA.png"
"logo": "yahoo_att_CA.png",
"__ycb_source__": "tests/fixtures/simple-3.json"
},
{
"settings": ["flavor:bt","region:gb"],

"logo": "yahoo_bt_GB.png"
"logo": "yahoo_bt_GB.png",
"__ycb_source__": "tests/fixtures/simple-3.json"
},
{
"settings": ["region:fr","flavor:bt"],

"logo": "yahoo_bt_FR.png"
"logo": "yahoo_bt_FR.png",
"__ycb_source__": "tests/fixtures/simple-3.json"
}
]
6 changes: 4 additions & 2 deletions tests/fixtures/simple-4.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"baz": false,
"oof": 4,
"rab": 5,
"zab": 6
"zab": 6,
"__ycb_source__": "tests/fixtures/simple-4.json"
},
{
"settings": ["lang:fr"],
Expand All @@ -15,6 +16,7 @@
"baz": 3,
"oof": null,
"rab": 0,
"zab": false
"zab": false,
"__ycb_source__": "tests/fixtures/simple-4.json"
}
]
2 changes: 2 additions & 0 deletions tests/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ cases = {

A.areSame('YRB_YAHOO_2nd', ycb.settings['*/*/*/*/*/*/*/*/*/*/*'].title_key);
A.areSame('yahoo.png', ycb.settings['*/*/*/*/*/*/*/*/*/*/*'].logo1);
A.areSame('tests/fixtures/simple-2.json', ycb.settings['*/*/*/*/*/*/*/*/*/*/*'].__ycb_source__);
A.isNotUndefined(ycb.dimensions[7].region.us);
},

Expand Down Expand Up @@ -271,6 +272,7 @@ cases = {
A.areSame('YRB_YAHOO', config.title_key);
A.areSame('http://www.yahoo.com', config.links.home);
A.areSame('http://mail.yahoo.com', config.links.mail);
A.isUndefined(config.__ycb_source__);
},


Expand Down

0 comments on commit 2550d8b

Please sign in to comment.