env_config 0.1.0 → 0.2.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/LICENSE +19 -0
- data/Rakefile +3 -1
- data/bin/env_config +27 -18
- data/lib/env_config/railtie.rb +8 -0
- data/lib/env_config/version.rb +1 -1
- data/lib/env_config.rb +1 -9
- data/test/rake_test.rb +2 -0
- metadata +6 -5
- data/env_config.rb +0 -23
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2011 Jerry Cheung
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/Rakefile
CHANGED
data/bin/env_config
CHANGED
@@ -1,23 +1,32 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'optparse'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
option_parser = OptionParser.new do |opts|
|
6
|
+
opts.banner = "EnvConfig - Simple app configuration management with environment variables"
|
7
|
+
opts.separator " "
|
8
|
+
opts.separator "SYNOPSIS"
|
9
|
+
opts.separator "Generate configuration yaml and configuration loader."
|
10
|
+
opts.separator " "
|
11
|
+
opts.separator " env_config init [OPTIONS]"
|
12
|
+
opts.separator " "
|
13
|
+
opts.separator "OPTIONS"
|
14
|
+
|
15
|
+
opts.on('-c', '--config-path=CONFIG_PATH', 'path to output generated application.yml. Default: config/application.yml') do |path|
|
16
|
+
@config_path = path || 'config/application.yml'
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
opts.on('-l', '--loader_path=LOADER_PATH', 'path to output generated EnvConfig initializer. Default: env_config.rb') do |path|
|
20
|
+
@loader_path = path || 'env_config.rb'
|
21
|
+
end
|
22
|
+
|
23
|
+
opts.on_tail('--help', '-h', "display this help information") do
|
24
|
+
puts opts
|
25
|
+
exit
|
26
|
+
end
|
27
|
+
end
|
28
|
+
option_parser.parse!(ARGV)
|
22
29
|
|
23
|
-
|
30
|
+
require 'rake'
|
31
|
+
load 'tasks/env_config.rake'
|
32
|
+
Rake::Task['env_config:init'].invoke(@config_path, @loader_path)
|
data/lib/env_config/version.rb
CHANGED
data/lib/env_config.rb
CHANGED
@@ -3,8 +3,7 @@ require "erb"
|
|
3
3
|
require "pathname"
|
4
4
|
require "yaml"
|
5
5
|
require "env_config/config"
|
6
|
-
require
|
7
|
-
load 'tasks/env_config.rake'
|
6
|
+
require "env_config/railtie" if defined?(Rails)
|
8
7
|
|
9
8
|
module EnvConfig
|
10
9
|
extend self
|
@@ -31,13 +30,6 @@ module EnvConfig
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
34
|
-
# Creates initial application.yml and loader. See env_config.rake
|
35
|
-
def init!(config_path, loader_path)
|
36
|
-
require 'rake'
|
37
|
-
load 'tasks/env_config.rake'
|
38
|
-
Rake::Task['env_config:init'].invoke(config_path, loader_path)
|
39
|
-
end
|
40
|
-
|
41
33
|
private
|
42
34
|
|
43
35
|
# iterate through namespaces until we have the scoped config we want
|
data/test/rake_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: env_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-25 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: fstest
|
17
|
-
requirement: &
|
17
|
+
requirement: &70197638309740 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70197638309740
|
26
26
|
description: Simple configuration management with environment variables
|
27
27
|
email:
|
28
28
|
- jch@whatcodecraves.com
|
@@ -33,13 +33,14 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- .gitignore
|
35
35
|
- Gemfile
|
36
|
+
- LICENSE
|
36
37
|
- README.md
|
37
38
|
- Rakefile
|
38
39
|
- bin/env_config
|
39
40
|
- env_config.gemspec
|
40
|
-
- env_config.rb
|
41
41
|
- lib/env_config.rb
|
42
42
|
- lib/env_config/config.rb
|
43
|
+
- lib/env_config/railtie.rb
|
43
44
|
- lib/env_config/version.rb
|
44
45
|
- lib/tasks/env_config.rake
|
45
46
|
- templates/application.yml
|
data/env_config.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
EnvConfig.configure do |config|
|
2
|
-
# yaml to read default config variables
|
3
|
-
config.config_path = /Users/jch/projects/beerpad/env_config/test/tmp/config_dir/loader.yml
|
4
|
-
|
5
|
-
# Whether to override a variable that's already defined in an environment
|
6
|
-
# variable. Keep to false if using Heroku.
|
7
|
-
config.override_env = false
|
8
|
-
|
9
|
-
# Namespace config values
|
10
|
-
# for deeper nesting, separate with '/'.
|
11
|
-
# For example, to namespace by platform and rails environment
|
12
|
-
#
|
13
|
-
# config.namespace_by = "{RbConfig::CONFIG['host_os']}/#{Rails.env}"
|
14
|
-
#
|
15
|
-
# Then in your config/application.yml, you can nest your config by the
|
16
|
-
# namepaces.
|
17
|
-
#
|
18
|
-
# darwin11.0.0:
|
19
|
-
# development:
|
20
|
-
# var_name: "mac development specific value"
|
21
|
-
#
|
22
|
-
config.namespace_by = ""
|
23
|
-
end
|