configloader 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{configloader}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Vinicius Teles"]
12
- s.date = %q{2011-02-08}
12
+ s.date = %q{2011-02-09}
13
13
  s.description = %q{If you need to create a custom config file for you project, ConfigLoader will help you to load the contents of this file.}
14
14
  s.email = %q{vinicius@improveit.com.br}
15
15
  s.extra_rdoc_files = [
@@ -47,7 +47,19 @@ module ConfigLoader
47
47
  # server: <%= `hostname` %>
48
48
  # port: 5984
49
49
  # database_name: addressbook_test
50
- def self.load(file_name, running_env = ENV['RAILS_ENV'], project_root = ENV['RAILS_ROOT'])
50
+ def self.load(file_name, running_env = default_running_env, project_root = default_project_root)
51
51
  ConfigLoader::Map.new(file_name, running_env, project_root).load
52
52
  end
53
+
54
+ private
55
+
56
+ def self.default_running_env
57
+ return Rails.env if defined?(Rails)
58
+ ENV['RAILS_ENV'] || ENV['RACK_ENV']
59
+ end
60
+
61
+ def self.default_project_root
62
+ return Rails.root if defined?(Rails)
63
+ ENV['RAILS_ROOT'] || ENV['RACK_ROOT']
64
+ end
53
65
  end
@@ -1,7 +1,12 @@
1
1
  module ConfigLoader
2
2
  class MissingConfigFileError < RuntimeError
3
3
  def initialize(filename)
4
- super("The config file couldn't be found: #{filename}")
4
+ message = [ "The config file couldn't be found: #{filename}",
5
+ "ENV['RAILS_ENV'] = '#{ENV["RAILS_ENV"]}'",
6
+ "ENV['RACK_ENV'] = '#{ENV["RACK_ENV"]}'",
7
+ "ENV['RAILS_ROOT'] = '#{ENV["RAILS_ROOT"]}'" ]
8
+
9
+ super(message.join("\n"))
5
10
  end
6
11
  end
7
12
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configloader
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Vinicius Teles
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-08 00:00:00 -03:00
18
+ date: 2011-02-09 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency