dynamic_configuration 0.3.10 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c15ffcb6799d3bb37e31a1cd3e80bf260e8b3aa6
4
+ data.tar.gz: 36fdaf70fdc0f1ed7c4f0a2da34cf3bb073cce74
5
+ SHA512:
6
+ metadata.gz: 57fefc3634f73a354d2c7302f8cf442729200840ebb7b2e87ed540609405263898af830a76564cb8287ca0da48fcaa8400258ea9c84aa23b449f46447ecba2fd
7
+ data.tar.gz: b423c9d645a7a3cb8e2328d9464692ec09becb788e52e23c3f10547cbf2036cf1683e39b47e557e7f114c361b1b9f73d469574401368a500ba8860dc083be0bd
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.10
1
+ 0.3.11
@@ -2,14 +2,15 @@
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.11 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "dynamic_configuration"
8
- s.version = "0.3.10"
9
+ s.version = "0.3.11"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Jaros\u{142}aw Rzesz\u{f3}tko"]
12
- s.date = "2013-04-30"
13
+ s.date = "2013-10-31"
13
14
  s.description = "Flexible configuration library for Ruby and Rails applications."
14
15
  s.email = "jrzeszotko@gmail.com"
15
16
  s.extra_rdoc_files = [
@@ -34,16 +35,7 @@ Gem::Specification.new do |s|
34
35
  ]
35
36
  s.homepage = "http://github.com/jaroslawr/dynamic_configuration"
36
37
  s.require_paths = ["lib"]
37
- s.rubygems_version = "1.8.23"
38
+ s.rubygems_version = "2.1.10"
38
39
  s.summary = "Flexible configuration library for Ruby and Rails applications."
39
-
40
- if s.respond_to? :specification_version then
41
- s.specification_version = 3
42
-
43
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
- else
45
- end
46
- else
47
- end
48
40
  end
49
41
 
@@ -1,16 +1,16 @@
1
1
  require 'blankslate'
2
2
 
3
3
  module DynamicConfiguration
4
- def self.create(const_name, config_file_name)
5
- ConfigFactory.new.create_config(const_name, config_file_name)
4
+ def self.create(const_name, config_directory)
5
+ ConfigFactory.new.create_config(const_name, config_directory)
6
6
  end
7
7
 
8
8
  private
9
9
 
10
10
  class ConfigFactory
11
- def create_config(const_name, config_file_name)
11
+ def create_config(const_name, config_directory)
12
12
  detect_rails
13
- setup_config(const_name, config_file_name)
13
+ setup_config(const_name, config_directory)
14
14
  load_main_configuration_files
15
15
  load_per_environment_configuration_files if @rails_loaded
16
16
  load_local_configuration_files
@@ -24,27 +24,27 @@ module DynamicConfiguration
24
24
  @rails_loaded = Object.const_defined?(:Rails)
25
25
  end
26
26
 
27
- def setup_config(const_name, config_path)
28
- @const_name = const_name
29
- @config_path = Pathname.new(config_path)
30
- @config = Config.new(@const_name, @config_path)
27
+ def setup_config(const_name, config_directory)
28
+ @const_name = const_name
29
+ @config_directory = Pathname.new(config_directory)
30
+ @config = Config.new(@const_name, @config_directory)
31
31
 
32
32
  Object.const_set @const_name, @config
33
33
  end
34
34
 
35
35
  def load_main_configuration_files
36
- @config_path.entries.each do |mod_file|
36
+ @config_directory.entries.each do |mod_file|
37
37
  next if ["..", "."].include?(mod_file.basename.to_s)
38
- mod_file = @config_path + mod_file
38
+ mod_file = @config_directory + mod_file
39
39
  next unless mod_file.file? && mod_file.basename.to_s != "#{@const_name.to_s.downcase}.rb"
40
40
  @config.load_module(mod_file)
41
41
  end
42
42
  end
43
43
 
44
44
  def load_per_environment_configuration_files
45
- @config_path.entries.each do |directory|
45
+ @config_directory.entries.each do |directory|
46
46
  next if ["..", "."].include?(directory.basename.to_s)
47
- directory = @config_path + directory
47
+ directory = @config_directory + directory
48
48
  next unless directory.directory? && Rails.env == directory.basename.to_s
49
49
 
50
50
  directory.entries.each do |mod_file|
@@ -56,11 +56,11 @@ module DynamicConfiguration
56
56
  end
57
57
 
58
58
  def load_local_configuration_files
59
- local_settings_exist = FileTest.directory?(@config_path.to_s + "/local")
59
+ local_settings_exist = FileTest.directory?(@config_directory.to_s + "/local")
60
60
  rails_test_env = @rails_loaded && Rails.env == 'test'
61
61
  return if !local_settings_exist || rails_test_env
62
62
 
63
- local_mod_files_dir = @config_path + Pathname.new("local/")
63
+ local_mod_files_dir = @config_directory + Pathname.new("local/")
64
64
  local_mod_files_dir.entries.each do |mod_file|
65
65
  next if ["..", "."].include?(mod_file.basename.to_s)
66
66
  mod_file = local_mod_files_dir + mod_file
@@ -73,7 +73,7 @@ module DynamicConfiguration
73
73
  @config.freeze
74
74
 
75
75
  if @rails_loaded
76
- ::ActiveSupport::Dependencies.autoload_paths << @config_path.to_s
76
+ ::ActiveSupport::Dependencies.autoload_paths << @config_directory.to_s
77
77
  ::ActiveSupport::Dependencies.explicitly_unloadable_constants << @const_name.to_s
78
78
  end
79
79
  end
@@ -83,15 +83,15 @@ module DynamicConfiguration
83
83
  reveal :freeze
84
84
  reveal :respond_to?
85
85
 
86
- def initialize(const_name, config_path)
87
- @const_name, @config_path = const_name, config_path
86
+ def initialize(const_name, config_directory)
87
+ @const_name, @config_directory = const_name, config_directory
88
88
  end
89
89
 
90
90
  def load_module(file_pathname)
91
91
  mod_name = file_pathname.basename.to_s[0..-4]
92
92
 
93
93
  @modules ||= {}
94
- @modules[mod_name.intern] ||= Group.new
94
+ @modules[mod_name.intern] ||= Group.new(@config_directory)
95
95
  @modules[mod_name.intern].instance_eval(::IO.read(file_pathname.to_s))
96
96
 
97
97
  @settings ||= {}
@@ -112,9 +112,10 @@ module DynamicConfiguration
112
112
  end
113
113
 
114
114
  class Group < ::BlankSlate
115
- attr_accessor :settings
115
+ attr_accessor :settings, :config_directory
116
116
 
117
- def initialize
117
+ def initialize(config_directory)
118
+ @config_directory = config_directory
118
119
  @settings = {}
119
120
  end
120
121
 
@@ -14,6 +14,11 @@ describe DynamicConfiguration do
14
14
  Settings.main.setting_two.should == 123456
15
15
  end
16
16
 
17
+ it "should allow accessing the configuration directory path" do
18
+ DynamicConfiguration::create(:Settings, path)
19
+ File.exists?(File.join(Settings.main.path, 'main.rb')).should be_true
20
+ end
21
+
17
22
  it "should make per-environment settings take precedence over main configuration" do
18
23
  begin
19
24
  Rails = mock(:env => 'test').as_null_object
data/spec/options/main.rb CHANGED
@@ -2,3 +2,4 @@ setting_one 'Some string'
2
2
  setting_two 123456
3
3
  setting_three [1, 2, 3]
4
4
  setting_four 'original'
5
+ path config_directory
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_configuration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
5
- prerelease:
4
+ version: 0.3.11
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jarosław Rzeszótko
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-30 00:00:00.000000000 Z
11
+ date: 2013-10-31 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Flexible configuration library for Ruby and Rails applications.
15
14
  email: jrzeszotko@gmail.com
@@ -35,26 +34,25 @@ files:
35
34
  - spec_helper.rb
36
35
  homepage: http://github.com/jaroslawr/dynamic_configuration
37
36
  licenses: []
37
+ metadata: {}
38
38
  post_install_message:
39
39
  rdoc_options: []
40
40
  require_paths:
41
41
  - lib
42
42
  required_ruby_version: !ruby/object:Gem::Requirement
43
- none: false
44
43
  requirements:
45
- - - ! '>='
44
+ - - '>='
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
48
47
  required_rubygems_version: !ruby/object:Gem::Requirement
49
- none: false
50
48
  requirements:
51
- - - ! '>='
49
+ - - '>='
52
50
  - !ruby/object:Gem::Version
53
51
  version: '0'
54
52
  requirements: []
55
53
  rubyforge_project:
56
- rubygems_version: 1.8.23
54
+ rubygems_version: 2.1.10
57
55
  signing_key:
58
- specification_version: 3
56
+ specification_version: 4
59
57
  summary: Flexible configuration library for Ruby and Rails applications.
60
58
  test_files: []