configy 1.0.1 → 1.1.0
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.
- data/Gemfile.lock +6 -3
- data/HISTORY.md +4 -0
- data/{README.rdoc → README.md} +35 -19
- data/Rakefile +3 -3
- data/configy.gemspec +12 -11
- data/lib/configy/config_store.rb +3 -1
- data/lib/generators/configy/install/install_generator.rb +19 -0
- data/lib/generators/configy/install/templates/config/app_config.local.yml.tt +10 -0
- data/lib/generators/configy/install/templates/config/app_config.yml.tt +21 -0
- data/lib/generators/configy/install/templates/config/initializers/configy.rb.tt +2 -0
- data/lib/generators/configy_generator.rb +3 -0
- data/test/nested_config_test.rb +23 -0
- metadata +62 -72
- data/.document +0 -5
- data/Rakefile.compiled.rbc +0 -1177
- data/VERSION +0 -1
- data/lib/configy.rbc +0 -1336
- data/lib/configy/base.rbc +0 -1499
- data/lib/configy/config_file.rbc +0 -823
- data/lib/configy/config_store.rbc +0 -1255
- data/test/base_test.rbc +0 -2682
- data/test/config_file_test.rbc +0 -1125
- data/test/config_store_test.rbc +0 -1483
- data/test/configy_test.rbc +0 -974
- data/test/load_path_test.rbc +0 -917
- data/test/section_test.rbc +0 -945
- data/test/test_helper.rbc +0 -1061
data/Gemfile.lock
CHANGED
@@ -1,16 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
configy (
|
4
|
+
configy (1.1.0)
|
5
|
+
hashie (~> 1.2.0)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
9
|
-
|
10
|
+
hashie (1.2.0)
|
11
|
+
minitest (2.5.1)
|
10
12
|
|
11
13
|
PLATFORMS
|
12
14
|
ruby
|
13
15
|
|
14
16
|
DEPENDENCIES
|
17
|
+
bundler (>= 1.0.0)
|
15
18
|
configy!
|
16
|
-
minitest
|
19
|
+
minitest
|
data/HISTORY.md
ADDED
data/{README.rdoc → README.md}
RENAMED
@@ -1,47 +1,63 @@
|
|
1
|
-
|
1
|
+
# Configy
|
2
2
|
|
3
|
-
|
3
|
+
## Description
|
4
4
|
|
5
|
-
It allows to have a file (config/
|
5
|
+
It allows to have a file (`config/app_config.yml`) with application configuration parameters.
|
6
6
|
It should have a "common" section with all parameters along with default values and can also
|
7
7
|
contain a section for each of the rails environments (development, test, production, or
|
8
8
|
your custom one). The values from the current environment section will override the values in the
|
9
9
|
"common" section.
|
10
10
|
|
11
11
|
If some developer needs his own specific values for his working copy, he can simply create
|
12
|
-
a config/
|
12
|
+
a `config/app_config.local.yml` file and override any value there, again having a "common" section
|
13
13
|
and a section for each environment.
|
14
14
|
|
15
15
|
Nothing is mandatory (files, sections) you just have what you really need. The files are parsed with ERB,
|
16
16
|
so they can contain some Ruby. It also checks for file modifications so you don't have to restart the server to pick up new values on production.
|
17
17
|
|
18
|
-
|
18
|
+
## Usage
|
19
19
|
|
20
|
-
|
20
|
+
Configy provides an [optional] generator.
|
21
21
|
|
22
|
-
|
23
|
-
admin_email: admin@domain.com
|
24
|
-
xml_rpc_url: http://domain.com:8000/
|
25
|
-
media_path: <%= RAILS_ROOT %>/tmp/media
|
22
|
+
rails g configy:install
|
26
23
|
|
27
|
-
|
28
|
-
xml_rpc_url: http://localhost:8000/
|
24
|
+
An example of a config file (app_config.yml):
|
29
25
|
|
30
|
-
|
31
|
-
|
26
|
+
``` yaml
|
27
|
+
common:
|
28
|
+
admin_email: admin@domain.com
|
29
|
+
xml_rpc_url: http://domain.com:8000/
|
30
|
+
media_path: <%= RAILS_ROOT %>/tmp/media
|
31
|
+
|
32
|
+
development:
|
33
|
+
xml_rpc_url: http://localhost:8000/
|
34
|
+
|
35
|
+
test:
|
36
|
+
xml_rpc_url: http://localhost:8008/
|
37
|
+
```
|
32
38
|
|
33
|
-
In an initializer
|
34
|
-
|
39
|
+
In an initializer:
|
40
|
+
|
41
|
+
``` ruby
|
42
|
+
Configy.create(:app_config)
|
43
|
+
```
|
35
44
|
|
36
45
|
Then, in the application you can use the config parameters like this:
|
37
46
|
|
38
|
-
|
47
|
+
``` ruby
|
48
|
+
AppConfig.xml_rpc_url
|
49
|
+
```
|
39
50
|
|
40
51
|
So it means that you've got a Config object which holds all the configuration parameters defined.
|
41
52
|
It doesn't allow to change the values in the application code, BTW.
|
42
53
|
|
43
|
-
|
44
|
-
|
54
|
+
## Authors
|
55
|
+
|
56
|
+
* Gabe Varela
|
57
|
+
* Ben Marini
|
58
|
+
* Chip Miller
|
59
|
+
|
60
|
+
## History
|
45
61
|
|
46
62
|
The Configy gem based on the AppConfig plugin which was evolved from the original plugin by Eugene Bolshakov, eugene.bolshakov@gmail.com, http://www.taknado.com
|
47
63
|
|
data/Rakefile
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
4
|
require 'rake/testtask'
|
5
5
|
Rake::TestTask.new(:test) do |test|
|
@@ -24,7 +24,7 @@ end
|
|
24
24
|
|
25
25
|
task :default => :test
|
26
26
|
|
27
|
-
require '
|
27
|
+
require 'rdoc/task'
|
28
28
|
Rake::RDocTask.new do |rdoc|
|
29
29
|
if File.exist?('VERSION.yml')
|
30
30
|
config = YAML.load(File.read('VERSION.yml'))
|
data/configy.gemspec
CHANGED
@@ -1,24 +1,25 @@
|
|
1
|
-
|
2
1
|
Gem::Specification.new do |s|
|
3
|
-
s.name
|
4
|
-
s.version
|
5
|
-
|
6
|
-
s.required_rubygems_version = ">= 1.3.6"
|
7
|
-
s.authors = ["Gabe Varela", "Ben Marini"]
|
8
|
-
s.date = %q{2011-04-21}
|
9
|
-
s.email = %q{gvarela@gmail.com}
|
10
|
-
s.summary = %q{Simple yaml driven configuration gem}
|
11
|
-
s.homepage = %q{http://github.com/gvarela/configy}
|
2
|
+
s.name = "configy"
|
3
|
+
s.version = "1.1.0"
|
12
4
|
|
5
|
+
s.authors = [ "Gabe Varela", "Ben Marini", "Chip Miller" ]
|
6
|
+
s.date = "2012-03-18"
|
7
|
+
s.email = "bmarini@gmail.com"
|
8
|
+
s.summary = "Simple yaml driven configuration gem"
|
9
|
+
s.homepage = "http://github.com/bmarini/configy"
|
13
10
|
|
14
11
|
s.files = `git ls-files`.split("\n")
|
15
12
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
16
13
|
s.require_path = 'lib'
|
17
14
|
|
15
|
+
s.required_rubygems_version = ">= 1.3.6"
|
16
|
+
s.add_runtime_dependency "hashie", "~> 1.2.0"
|
18
17
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
|
+
s.add_development_dependency "minitest"
|
19
|
+
|
19
20
|
s.extra_rdoc_files = [
|
20
21
|
"LICENSE",
|
21
|
-
|
22
|
+
"README.md"
|
22
23
|
]
|
23
24
|
s.rdoc_options = ["--charset=UTF-8"]
|
24
25
|
s.require_paths = ["lib"]
|
data/lib/configy/config_store.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'hashie/mash'
|
2
|
+
|
1
3
|
unless Hash.new.respond_to?(:deep_merge)
|
2
4
|
class Hash
|
3
5
|
# Returns a new hash with +self+ and +other_hash+ merged recursively.
|
@@ -24,7 +26,7 @@ module Configy
|
|
24
26
|
|
25
27
|
# Takes a Hash as input
|
26
28
|
def initialize(config)
|
27
|
-
@config = config && config.to_hash || {}
|
29
|
+
@config = Hashie::Mash.new( config && config.to_hash || {} )
|
28
30
|
end
|
29
31
|
|
30
32
|
# Returns a new ConfigStore by merging `common` with `section`
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Configy
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
def copy_initializer_file # :nodoc:
|
6
|
+
template "config/initializers/configy.rb.tt", "config/initializers/configy.rb"
|
7
|
+
end
|
8
|
+
|
9
|
+
def copy_config_file # :nodoc:
|
10
|
+
template "config/app_config.yml.tt", "config/app_config.yml"
|
11
|
+
end
|
12
|
+
|
13
|
+
def copy_local_config_file # :nodoc:
|
14
|
+
template "config/app_config.local.yml.tt", "config/app_config.local.yml"
|
15
|
+
insert_into_file ".gitignore", "\nconfig/*.local.yml", :before => /\z/
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# EXAMPLE:
|
2
|
+
# common:
|
3
|
+
# admin_email: admin@domain.com
|
4
|
+
# xml_rpc_url: http://domain.com:8000/
|
5
|
+
# media_path: <%%= Rails.root %>/tmp/media
|
6
|
+
#
|
7
|
+
# development:
|
8
|
+
# xml_rpc_url: http://localhost:8000/
|
9
|
+
#
|
10
|
+
# test:
|
11
|
+
# xml_rpc_url: http://localhost:8008/
|
12
|
+
|
13
|
+
common:
|
14
|
+
|
15
|
+
development:
|
16
|
+
|
17
|
+
test:
|
18
|
+
|
19
|
+
production:
|
20
|
+
|
21
|
+
#custom_environment:
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class NestedConfigTest < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Configy.load_path = scratch_dir
|
6
|
+
Configy.cache_config = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_nested_configs_should_be_accessible_as_methods
|
10
|
+
with_config_file({
|
11
|
+
'common' => {
|
12
|
+
'level1' => {
|
13
|
+
'level2' => {
|
14
|
+
'level3' => 'whynot'
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}, 'nested_config') do
|
19
|
+
Configy.create('nested_config')
|
20
|
+
assert_equal 'whynot', NestedConfig.level1.level2.level3
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,119 +1,109 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: configy
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 1.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Gabe Varela
|
14
9
|
- Ben Marini
|
10
|
+
- Chip Miller
|
15
11
|
autorequire:
|
16
12
|
bindir: bin
|
17
13
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
date: 2012-03-18 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: hashie
|
18
|
+
requirement: &70237177506340 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.0
|
24
|
+
type: :runtime
|
24
25
|
prerelease: false
|
25
|
-
|
26
|
+
version_requirements: *70237177506340
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: &70237177505880 !ruby/object:Gem::Requirement
|
26
30
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
hash: 23
|
31
|
-
segments:
|
32
|
-
- 1
|
33
|
-
- 0
|
34
|
-
- 0
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
35
34
|
version: 1.0.0
|
36
35
|
type: :development
|
37
|
-
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *70237177505880
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: minitest
|
40
|
+
requirement: &70237177505500 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *70237177505500
|
38
49
|
description:
|
39
|
-
email:
|
50
|
+
email: bmarini@gmail.com
|
40
51
|
executables: []
|
41
|
-
|
42
52
|
extensions: []
|
43
|
-
|
44
|
-
extra_rdoc_files:
|
53
|
+
extra_rdoc_files:
|
45
54
|
- LICENSE
|
46
|
-
- README.
|
47
|
-
files:
|
48
|
-
- .document
|
55
|
+
- README.md
|
56
|
+
files:
|
49
57
|
- .gitignore
|
50
58
|
- .travis.yml
|
51
59
|
- Gemfile
|
52
60
|
- Gemfile.lock
|
61
|
+
- HISTORY.md
|
53
62
|
- LICENSE
|
54
|
-
- README.
|
63
|
+
- README.md
|
55
64
|
- Rakefile
|
56
|
-
- Rakefile.compiled.rbc
|
57
|
-
- VERSION
|
58
65
|
- configy.gemspec
|
59
66
|
- lib/configy.rb
|
60
|
-
- lib/configy.rbc
|
61
67
|
- lib/configy/base.rb
|
62
|
-
- lib/configy/base.rbc
|
63
68
|
- lib/configy/config_file.rb
|
64
|
-
- lib/configy/config_file.rbc
|
65
69
|
- lib/configy/config_store.rb
|
66
|
-
- lib/configy/
|
70
|
+
- lib/generators/configy/install/install_generator.rb
|
71
|
+
- lib/generators/configy/install/templates/config/app_config.local.yml.tt
|
72
|
+
- lib/generators/configy/install/templates/config/app_config.yml.tt
|
73
|
+
- lib/generators/configy/install/templates/config/initializers/configy.rb.tt
|
74
|
+
- lib/generators/configy_generator.rb
|
67
75
|
- test/base_test.rb
|
68
|
-
- test/base_test.rbc
|
69
76
|
- test/config_file_test.rb
|
70
|
-
- test/config_file_test.rbc
|
71
77
|
- test/config_store_test.rb
|
72
|
-
- test/config_store_test.rbc
|
73
78
|
- test/configy_test.rb
|
74
|
-
- test/configy_test.rbc
|
75
79
|
- test/load_path_test.rb
|
76
|
-
- test/
|
80
|
+
- test/nested_config_test.rb
|
77
81
|
- test/scratch/.gitkeep
|
78
82
|
- test/section_test.rb
|
79
|
-
- test/section_test.rbc
|
80
83
|
- test/test_helper.rb
|
81
|
-
|
82
|
-
has_rdoc: true
|
83
|
-
homepage: http://github.com/gvarela/configy
|
84
|
+
homepage: http://github.com/bmarini/configy
|
84
85
|
licenses: []
|
85
|
-
|
86
86
|
post_install_message:
|
87
|
-
rdoc_options:
|
87
|
+
rdoc_options:
|
88
88
|
- --charset=UTF-8
|
89
|
-
require_paths:
|
89
|
+
require_paths:
|
90
90
|
- lib
|
91
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
92
|
none: false
|
93
|
-
requirements:
|
94
|
-
- -
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
|
97
|
-
|
98
|
-
- 0
|
99
|
-
version: "0"
|
100
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
98
|
none: false
|
102
|
-
requirements:
|
103
|
-
- -
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
hash: 23
|
106
|
-
segments:
|
107
|
-
- 1
|
108
|
-
- 3
|
109
|
-
- 6
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
110
102
|
version: 1.3.6
|
111
103
|
requirements: []
|
112
|
-
|
113
104
|
rubyforge_project:
|
114
|
-
rubygems_version: 1.
|
105
|
+
rubygems_version: 1.8.11
|
115
106
|
signing_key:
|
116
107
|
specification_version: 3
|
117
108
|
summary: Simple yaml driven configuration gem
|
118
109
|
test_files: []
|
119
|
-
|