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 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
@@ -6,4 +6,6 @@ Rake::TestTask.new do |t|
6
6
  t.libs << ["lib", "test"]
7
7
  t.test_files = FileList['test/*_test.rb']
8
8
  t.verbose = true
9
- end
9
+ end
10
+
11
+ task :default => :test
data/bin/env_config CHANGED
@@ -1,23 +1,32 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'env_config'
3
+ require 'optparse'
4
4
 
5
- unless ARGV.size == 1
6
- puts "Simple configuration management with environment variables"
7
- puts ""
8
- puts "Run 'env_config init' to initialize configuration yaml and loader."
9
- puts "Please visit https://github.com/jch/env_config for more details."
10
- puts ""
11
- puts "Example:"
12
- puts ""
13
- puts "env_config init config/application.yml config/initializers/env_config.rb"
14
- puts ""
15
- exit 1
16
- end
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
- # TODO: gross that defaults are duplicated here. Ideally would just run
19
- # rake env_config:init config_path=... loader_path=...
20
- config_path = ARGV[1] || 'config/application.yml'
21
- loader_path = ARGV[2] || 'config/initializers/env_config.rb'
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
- EnvConfig.init!(config_path, loader_path)
30
+ require 'rake'
31
+ load 'tasks/env_config.rake'
32
+ Rake::Task['env_config:init'].invoke(@config_path, @loader_path)
@@ -0,0 +1,8 @@
1
+ module EnvConfig
2
+ class Railtie < Rails::Railtie
3
+ railtie_name :env_config
4
+ rake_tasks do
5
+ load "tasks/env_config.rake"
6
+ end
7
+ end
8
+ end
@@ -1,3 +1,3 @@
1
1
  module EnvConfig
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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 'rake'
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
@@ -1,6 +1,8 @@
1
1
  require 'test_helper'
2
2
  require 'pathname'
3
3
  require 'fstest'
4
+ require 'rake'
5
+ load 'tasks/env_config.rake'
4
6
 
5
7
  class RakeTest < Test::Unit::TestCase
6
8
  include FSTest
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.1.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-23 00:00:00.000000000 -04:00
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: &70268031170440 !ruby/object:Gem::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: *70268031170440
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