Skip to content

Commit

Permalink
@ teracyhq#321 | should implement project specific config support fea…
Browse files Browse the repository at this point in the history
…ture: override instead of overide
  • Loading branch information
hoatle committed Jul 21, 2017
1 parent b10207c commit 64cf937
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ begin
org_config_file = File.read(parsing_file)
org_config_hash = JSON.parse(org_config_file)

overide_config_file_path = parsing_file.gsub(/default\.json$/, "overide.json")
if File.exist?(overide_config_file_path)
override_config_file = File.read(overide_config_file_path)
parsing_file = overide_config_file_path
overide_config_hash = JSON.parse(override_config_file)
org_config_hash = overrides(org_config_hash, overide_config_hash)
override_config_file_path = parsing_file.gsub(/default\.json$/, "override.json")
if File.exist?(override_config_file_path)
override_config_file = File.read(override_config_file_path)
parsing_file = override_config_file_path
override_config_hash = JSON.parse(override_config_file)
org_config_hash = overrides(org_config_hash, override_config_hash)
end

if !org_config_hash.nil?
Expand All @@ -41,7 +41,7 @@ begin

if data_hash['vagrant'] && data_hash['vagrant']['config_paths']
data_hash['vagrant']['config_paths'].map do |default_config_file_path|
overide_config_file_path = default_config_file_path.gsub(/default\.json$/, "overide.json")
override_config_file_path = default_config_file_path.gsub(/default\.json$/, "override.json")

if File.exist?(File.dirname(__FILE__) + '/' + default_config_file_path)
default_config_file = File.read(File.dirname(__FILE__) + '/' + default_config_file_path)
Expand All @@ -51,11 +51,11 @@ begin
puts "[teracy-dev][INFO]: #{default_config_file_path} not found, make sure this is intended."
end

if File.exist?(File.dirname(__FILE__) + '/' + overide_config_file_path)
override_config_file = File.read(File.dirname(__FILE__) + '/' + overide_config_file_path)
parsing_file = overide_config_file_path
overide_config_hash = JSON.parse(override_config_file)
project_config_hash = overrides(project_config_hash, overide_config_hash)
if File.exist?(File.dirname(__FILE__) + '/' + override_config_file_path)
override_config_file = File.read(File.dirname(__FILE__) + '/' + override_config_file_path)
parsing_file = override_config_file_path
override_config_hash = JSON.parse(override_config_file)
project_config_hash = overrides(project_config_hash, override_config_hash)
end
if !project_config_hash.nil?
overrides(data_hash, project_config_hash)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions spec/utility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@
context "Giving many config file follow project base config requirement" do
it "after override the config must satisfy the requirement" do
teracy_default_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/config.json'))
teracy_override_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/config_overide.json'))
teracy_override_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/config_override.json'))
project_org_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/org_project.json'))
project1_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/project1.json'))
project2_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/project2.json'))

origin_teracy_default_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/config.json'))
origin_teracy_override_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/config_overide.json'))
origin_teracy_override_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/config_override.json'))
origin_project_org_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/org_project.json'))
origin_project1_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/project1.json'))
origin_project2_config = JSON.parse(File.read(File.dirname(__FILE__) + '/fixture/project2.json'))
Expand Down

0 comments on commit 64cf937

Please sign in to comment.