Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added env to init method for Configatron::Rails.

  • Loading branch information...
commit 88844d20a81851fe722c2c9eaaab8d0d183e1636 1 parent fa0179f
@markbates markbates authored
View
2  Rakefile
@@ -4,7 +4,7 @@ require 'gemstub'
Gemstub.test_framework = :rspec
Gemstub.gem_spec do |s|
- s.version = "2.4.1"
+ s.version = "2.4.2"
s.summary = "A powerful Ruby configuration system."
s.rubyforge_project = "magrathea"
s.add_dependency('yamler', '>=0.1.0')
View
6 configatron.gemspec
@@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = %q{configatron}
- s.version = "2.4.1.20090826153428"
+ s.version = "2.4.2.20090909140253"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["markbates"]
- s.date = %q{2009-08-26}
+ s.date = %q{2009-09-09}
s.description = %q{configatron was developed by: markbates}
s.email = %q{mark@markbates.com}
s.extra_rdoc_files = ["README", "LICENSE"]
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
s.homepage = %q{http://www.metabates.com}
s.require_paths = ["lib"]
s.rubyforge_project = %q{magrathea}
- s.rubygems_version = %q{1.3.4}
+ s.rubygems_version = %q{1.3.5}
s.summary = %q{A powerful Ruby configuration system.}
if s.respond_to? :specification_version then
View
1  lib/configatron.rb
@@ -1,5 +1,6 @@
base = File.join(File.dirname(__FILE__), 'configatron')
require 'yamler'
+require 'fileutils'
require File.join(base, 'configatron')
require File.join(base, 'store')
require File.join(base, 'errors')
View
17 lib/configatron/rails.rb
@@ -16,14 +16,23 @@ module Rails
# <RAILS_ROOT>/config/configatron/<RAILS_ENV>/defaults.rb
# <RAILS_ROOT>/config/configatron/<RAILS_ENV>/bar.rb
# <RAILS_ROOT>/config/configatron/<RAILS_ENV>/foo.rb
- def self.init(root = RAILS_ROOT)
+ def self.init(root = nil, env = nil)
+ base_dir = root
+ if root.nil?
+ root = defined?(RAILS_ROOT) ? RAILS_ROOT : FileUtils.pwd
+ base_dir = File.expand_path(File.join(root, 'config', 'configatron'))
+ end
+
+ if env.nil?
+ env = defined?(RAILS_ENV) ? RAILS_ENV : 'development'
+ end
+
config_files = []
- base_dir = File.expand_path(File.join(root, 'config', 'configatron'))
config_files << File.join(base_dir, 'defaults.rb')
- config_files << File.join(base_dir, "#{RAILS_ENV}.rb")
+ config_files << File.join(base_dir, "#{env}.rb")
- env_dir = File.join(base_dir, RAILS_ENV)
+ env_dir = File.join(base_dir, env)
config_files << File.join(env_dir, 'defaults.rb')
Dir.glob(File.join(env_dir, '*.rb')).sort.each do |f|
Please sign in to comment.
Something went wrong with that request. Please try again.