dynamic_configuration 0.3.13 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/dynamic_configuration.gemspec +4 -3
- data/lib/dynamic_configuration.rb +29 -17
- data/lib/railtie.rb +15 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 425ae95c29d5bd5d332340549b603a14bc7763bb
|
4
|
+
data.tar.gz: e7238415edef3f48da4bc43137f2e543cee1823c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9536a059603c8568aff1c5c62ba84b24c7e6480733104e409c605ddd0cf8a2588e6386f147ee6fff0efef0bc738993955d12dad6446d294169dae19fa04ef18
|
7
|
+
data.tar.gz: 59e496dc3da5fab5eee01485e8a24d574b71386c1f2d637ca8c4ac193f92479dc099f5beb73faef68d908ede187adc3c78165506a4dd0bc4a7ddcabf57b44d6c
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.14
|
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: dynamic_configuration 0.3.
|
5
|
+
# stub: dynamic_configuration 0.3.14 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "dynamic_configuration"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.14"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Jaros\u{142}aw Rzesz\u{f3}tko"]
|
14
|
-
s.date = "2014-02-
|
14
|
+
s.date = "2014-02-07"
|
15
15
|
s.description = "Flexible configuration library for Ruby and Rails applications."
|
16
16
|
s.email = "jrzeszotko@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
|
|
27
27
|
"VERSION",
|
28
28
|
"dynamic_configuration.gemspec",
|
29
29
|
"lib/dynamic_configuration.rb",
|
30
|
+
"lib/railtie.rb",
|
30
31
|
"spec/dynamic_configuration_spec.rb",
|
31
32
|
"spec/options/local/main.rb",
|
32
33
|
"spec/options/main.rb",
|
@@ -1,16 +1,30 @@
|
|
1
1
|
require 'blankslate'
|
2
2
|
|
3
3
|
module DynamicConfiguration
|
4
|
-
|
5
|
-
|
4
|
+
class << self
|
5
|
+
def create(const_name, root_file_path)
|
6
|
+
@config_paths.push(File.dirname(root_file_path))
|
7
|
+
@const_names.push(const_name)
|
8
|
+
ConfigFactory.new.create_config(const_name, root_file_path)
|
9
|
+
end
|
10
|
+
|
11
|
+
def config_paths
|
12
|
+
@config_paths
|
13
|
+
end
|
14
|
+
|
15
|
+
def const_names
|
16
|
+
@const_names
|
17
|
+
end
|
6
18
|
end
|
7
|
-
|
19
|
+
|
20
|
+
@const_names, @config_paths = [], []
|
21
|
+
|
8
22
|
private
|
9
23
|
|
10
|
-
class ConfigFactory
|
11
|
-
def create_config(const_name,
|
24
|
+
class ConfigFactory
|
25
|
+
def create_config(const_name, root_file_path)
|
12
26
|
detect_rails
|
13
|
-
setup_config(const_name,
|
27
|
+
setup_config(const_name, root_file_path)
|
14
28
|
load_main_configuration_files
|
15
29
|
load_per_environment_configuration_files if @rails_loaded
|
16
30
|
load_local_configuration_files
|
@@ -23,20 +37,21 @@ module DynamicConfiguration
|
|
23
37
|
def detect_rails
|
24
38
|
@rails_loaded = Object.const_defined?(:Rails)
|
25
39
|
end
|
26
|
-
|
27
|
-
def setup_config(const_name,
|
40
|
+
|
41
|
+
def setup_config(const_name, root_file_path)
|
28
42
|
@const_name = const_name
|
29
|
-
@
|
43
|
+
@root_file_path = root_file_path
|
44
|
+
@config_directory = Pathname.new(File.dirname(@root_file_path))
|
30
45
|
@config = Config.new(@const_name, @config_directory)
|
31
46
|
|
32
|
-
Object.const_set
|
47
|
+
Object.const_set(@const_name, @config)
|
33
48
|
end
|
34
49
|
|
35
50
|
def load_main_configuration_files
|
36
51
|
@config_directory.entries.each do |mod_file|
|
37
52
|
next if ["..", "."].include?(mod_file.basename.to_s)
|
38
53
|
mod_file = @config_directory + mod_file
|
39
|
-
next unless mod_file.file? && mod_file.
|
54
|
+
next unless mod_file.file? && mod_file.to_s != @root_file_path
|
40
55
|
@config.load_module(mod_file)
|
41
56
|
end
|
42
57
|
end
|
@@ -71,18 +86,13 @@ module DynamicConfiguration
|
|
71
86
|
|
72
87
|
def finalize_config
|
73
88
|
@config.freeze
|
74
|
-
|
75
|
-
if @rails_loaded
|
76
|
-
::ActiveSupport::Dependencies.autoload_paths << @config_directory.to_s
|
77
|
-
::ActiveSupport::Dependencies.explicitly_unloadable_constants << @const_name.to_s
|
78
|
-
end
|
79
89
|
end
|
80
90
|
end
|
81
91
|
|
82
92
|
class Config < ::BlankSlate
|
83
93
|
reveal :freeze
|
84
94
|
reveal :respond_to?
|
85
|
-
|
95
|
+
|
86
96
|
def initialize(const_name, config_directory)
|
87
97
|
@const_name, @config_directory = const_name, config_directory
|
88
98
|
end
|
@@ -142,3 +152,5 @@ module DynamicConfiguration
|
|
142
152
|
class MissingGroupException < StandardError; end
|
143
153
|
class MissingSettingException < StandardError; end
|
144
154
|
end
|
155
|
+
|
156
|
+
require 'railtie' if defined?(Rails)
|
data/lib/railtie.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class DynamicConfigurationRailtie < Rails::Railtie
|
2
|
+
config.to_prepare do
|
3
|
+
DynamicConfiguration.const_names.each do |const_name|
|
4
|
+
Object.send(:remove_const, const_name) if Object.const_defined?(const_name)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
initializer "dynamic_configuration.initialize" do |app|
|
9
|
+
DynamicConfiguration.config_paths.each do |path|
|
10
|
+
unless ActiveSupport::Dependencies.autoload_paths.include?(path)
|
11
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_configuration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jarosław Rzeszótko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Flexible configuration library for Ruby and Rails applications.
|
14
14
|
email: jrzeszotko@gmail.com
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- VERSION
|
27
27
|
- dynamic_configuration.gemspec
|
28
28
|
- lib/dynamic_configuration.rb
|
29
|
+
- lib/railtie.rb
|
29
30
|
- spec/dynamic_configuration_spec.rb
|
30
31
|
- spec/options/local/main.rb
|
31
32
|
- spec/options/main.rb
|