configuration_manager 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e58571651ad2b507c43f085876783f1a6c5b7aee
4
+ data.tar.gz: c46ce375821dc0254bfe8b8e2d06326ebb258549
5
+ SHA512:
6
+ metadata.gz: cf0f54e581a31ba62c535eb7bd40a37e85a6a60338a0fc2f19d019bcf79bbec7fce3c4577ec3f5e7249f2817a8fb5b18c7ca56840612035a245735e8746925a1
7
+ data.tar.gz: 23c31c0f23d5a5334d799e037cdf31efbc1729bf7b7f3fe8b89b5370ac79a777489885d91b5ab6a3e19982f702921e624a29ce8bcd6f6b4be58d1e83f19919a3
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "activesupport"
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.3"
22
24
  spec.add_development_dependency "rake"
23
25
  end
@@ -0,0 +1,32 @@
1
+ module ConfigurationManager
2
+ class Merger
3
+ class << self
4
+
5
+ def write(theme_name)
6
+ File.open("#{Rails.root}/config/application.yml", "w") do |file|
7
+ file.write config(theme_name).to_yaml
8
+ end
9
+ end
10
+
11
+ def config(theme_name)
12
+ common = YAML.load_file "#{Rails.root}/config/application.common.dev.yml"
13
+ theme = YAML.load_file "#{Rails.root}/config/application.#{theme_name}.dev.yml"
14
+
15
+ {
16
+ "development" => get(common, "development").deep_merge( get(theme, "development") ),
17
+ "test" => get(common, "test").deep_merge( get(theme, "test") )
18
+ }
19
+ end
20
+
21
+ private
22
+
23
+ def get(config, env_name)
24
+ common = config["common"] || {}
25
+ env = config[env_name] || {}
26
+
27
+ common.deep_merge(env)
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module ConfigurationManager
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require "configuration_manager/configuration"
2
+ require "configuration_manager/merger"
2
3
  require "configuration_manager/railtie"
3
4
  require "configuration_manager/version"
4
5
 
@@ -12,16 +13,13 @@ module ConfigurationManager
12
13
  end
13
14
 
14
15
  def check_configuration_freshness
15
- current = "application.yml"
16
- reference = "application.#{AppConfig.theme}.dev.yml"
16
+ current = YAML.load_file("#{Rails.root}/config/application.yml")
17
+ generated = Merger.config(AppConfig.current_theme)
17
18
 
18
- current_path = "#{Rails.root}/config/#{current}"
19
- reference_path = "#{Rails.root}/config/#{reference}"
20
-
21
- different = configs_different? current_path, reference_path
19
+ different = configs_different? current, generated
22
20
 
23
21
  if different && !AppConfig['allow_custom_configuration']
24
- raise "Current configuration #{current} does not match #{reference}. " +
22
+ raise "Current application.yml does not match the default for #{AppConfig.current_theme}. " +
25
23
  "Either run `rake config:update` or set allow_custom_configuration to true" +
26
24
  " in your application.yml."
27
25
  end
@@ -29,10 +27,7 @@ module ConfigurationManager
29
27
 
30
28
  private
31
29
 
32
- def configs_different?(path_one, path_two)
33
- one = YAML.load_file(path_one)
34
- two = YAML.load_file(path_two)
35
-
30
+ def configs_different?(one, two)
36
31
  relevant_configs_one = relevant_configs(one)
37
32
  relevant_configs_two = relevant_configs(two)
38
33
 
@@ -1,10 +1,13 @@
1
+ require_relative '../configuration_manager/merger'
2
+
1
3
  namespace :config do
2
- desc "Switch configurations to another theme, specieid by THEME"
4
+
5
+ desc "Switch configurations to another theme, specified by THEME"
3
6
  task :switch do
4
7
  theme = ENV['THEME']
5
8
 
6
9
  puts "= Switching to the #{theme} configuration"
7
- copy_theme(theme)
10
+ ConfigurationManager::Merger.write(theme)
8
11
 
9
12
  puts "= Clearing temp files"
10
13
  Rake::Task["tmp:clear"].invoke
@@ -15,13 +18,7 @@ namespace :config do
15
18
  theme = AppConfig.theme
16
19
 
17
20
  puts "= Updating config, using the #{theme} configuration"
18
- copy_theme(theme)
21
+ ConfigurationManager::Merger.write(theme)
19
22
  end
20
23
 
21
- def copy_theme(theme)
22
- source = "#{Rails.root}/config/application.#{theme}.dev.yml"
23
- dest = "#{Rails.root}/config/application.yml"
24
-
25
- system "cp #{source} #{dest}"
26
- end
27
24
  end
metadata CHANGED
@@ -1,20 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configuration_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bruz Marzolf
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2014-03-18 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: bundler
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
31
  - - ~>
20
32
  - !ruby/object:Gem::Version
@@ -22,7 +34,6 @@ dependencies:
22
34
  type: :development
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
38
  - - ~>
28
39
  - !ruby/object:Gem::Version
@@ -30,17 +41,15 @@ dependencies:
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rake
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ! '>='
45
+ - - '>='
36
46
  - !ruby/object:Gem::Version
37
47
  version: '0'
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ! '>='
52
+ - - '>='
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  description: Manage development configurations for themed apps
@@ -58,38 +67,32 @@ files:
58
67
  - configuration_manager.gemspec
59
68
  - lib/configuration_manager.rb
60
69
  - lib/configuration_manager/configuration.rb
70
+ - lib/configuration_manager/merger.rb
61
71
  - lib/configuration_manager/railtie.rb
62
72
  - lib/configuration_manager/version.rb
63
73
  - lib/tasks/config.rake
64
74
  homepage: ''
65
75
  licenses:
66
76
  - MIT
77
+ metadata: {}
67
78
  post_install_message:
68
79
  rdoc_options: []
69
80
  require_paths:
70
81
  - lib
71
82
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
83
  requirements:
74
- - - ! '>='
84
+ - - '>='
75
85
  - !ruby/object:Gem::Version
76
86
  version: '0'
77
- segments:
78
- - 0
79
- hash: 912823216979744525
80
87
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
88
  requirements:
83
- - - ! '>='
89
+ - - '>='
84
90
  - !ruby/object:Gem::Version
85
91
  version: '0'
86
- segments:
87
- - 0
88
- hash: 912823216979744525
89
92
  requirements: []
90
93
  rubyforge_project:
91
- rubygems_version: 1.8.25
94
+ rubygems_version: 2.2.2
92
95
  signing_key:
93
- specification_version: 3
96
+ specification_version: 4
94
97
  summary: Themed app configuration management
95
98
  test_files: []