configutron 0.3.1 → 0.4.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/README.markdown CHANGED
@@ -1,23 +1,30 @@
1
1
  configutron
2
2
  ===========
3
3
 
4
- configutron is a rails gemplugin for simple, application wide settings. there are tons of projects like this; each does it differently, and this is how i like to do it. all the ones I tried seemed too heavy handed. i am publishing this as a convenience for myself to use in projects i work on.
4
+ configutron is a rails gem for simple, application wide settings. there are tons of projects like this; each does it differently, and this is how i like to do it. all the ones I tried seemed too heavy handed. i am publishing this as a convenience for myself to use in projects i work on.
5
+
6
+ tested on rails 2.3.5, 2.3.8, and 3.0.0.rc
5
7
 
6
8
  usage
7
9
  -----
8
10
 
9
- use the gem in your rails project:
11
+ in non-bundler rails projects:
10
12
 
11
13
  Rails::Initializer.run do |config|
12
14
  config.gem 'configutron'
13
15
  end
14
16
 
17
+ in your Gemfile
18
+
19
+ gem 'configutron'
20
+
21
+
15
22
  you have two options for specifying settings.
16
23
 
17
24
  1. one file (_config/settings.yml_)
18
25
  2. one file per environment (_config/settings/environment\_name.yml_)
19
26
 
20
- option 1 takes presedence; that is, if _config/settings.yml_ exists, it will be used, and the _config/settings_ directory will be ignored.
27
+ option 1 takes precedence; that is, if _config/settings.yml_ exists, it will be used, and the _config/settings_ directory will be ignored.
21
28
 
22
29
  config/settings.yml
23
30
  -------------------
@@ -56,12 +63,8 @@ try it out:
56
63
 
57
64
  name it something easier to type:
58
65
  ---------------------------------
59
- back in _environment.rb_
66
+ _config/initializers/configutron.rb_
60
67
 
61
- Rails::Initializer.run do |config|
62
- config.gem 'configutron'
63
- end
64
-
65
68
  Configutron.constant = 'App'
66
69
 
67
70
  try it out:
@@ -80,6 +83,10 @@ inspiration
80
83
  * [Christopher J. Bottaro](http://github.com/cjbottaro/app_config/)'s app_config
81
84
  * [Brian Smith](http://swig505.com)
82
85
 
86
+ thanks
87
+ ------
88
+ * [Todd Siegel and MerchLuv](http://merchluv.com)
89
+
83
90
  note on patches/pull requests
84
91
  -----------------------------
85
92
  * fork the project.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
data/lib/configutron.rb CHANGED
@@ -20,11 +20,11 @@ module Configutron
20
20
  end
21
21
 
22
22
  def setup
23
- settings_path = File.expand_path("#{RAILS_ROOT}/config/settings.yml")
24
- env_settings_path = File.expand_path("#{RAILS_ROOT}/config/settings/#{RAILS_ENV}.yml")
23
+ settings_path = File.expand_path(Rails.root.join('config', 'settings.yml'))
24
+ env_settings_path = File.expand_path(Rails.root.join('config', 'settings', "#{Rails.env}.yml"))
25
25
 
26
26
  if File.exist?(settings_path)
27
- @configutron = YAML.load(ERB.new(File.read(settings_path)).result)[RAILS_ENV].symbolize_keys
27
+ @configutron = YAML.load(ERB.new(File.read(settings_path)).result)[Rails.env].symbolize_keys
28
28
  elsif File.exists?(env_settings_path)
29
29
  @configutron = YAML.load(ERB.new(File.read(env_settings_path)).result).symbolize_keys
30
30
  else
@@ -1,11 +1,10 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- RAILS_ROOT = '/rails_root/'
3
- RAILS_ENV = 'test'
4
2
 
5
3
  describe Configutron do
6
4
  include FakeFS::SpecHelpers
5
+
7
6
  after(:each) { reset! }
8
-
7
+
9
8
  describe "module methods" do
10
9
  describe ".constant=" do
11
10
  it "should alias the Configutron constant to something you actually want to use" do
data/spec/spec_helper.rb CHANGED
@@ -4,11 +4,17 @@ require 'configutron'
4
4
  require 'spec'
5
5
  require 'spec/autorun'
6
6
  require 'fake_yml_files'
7
+ require 'pathname'
7
8
 
8
9
  require 'rubygems'
9
- require 'active_support'
10
10
  require 'fakefs/spec_helpers'
11
11
 
12
+ begin
13
+ require 'active_support/hash_with_indifferent_access'
14
+ rescue LoadError
15
+ require 'active_support'
16
+ end
17
+
12
18
  def mock_test_yml
13
19
  path = '/rails_root/config/settings/test.yml'
14
20
 
@@ -31,4 +37,14 @@ def reset!
31
37
  Configutron.instance_eval do
32
38
  @configutron = nil
33
39
  end
40
+ end
41
+
42
+ module Rails
43
+ def self.root
44
+ @root ||= Pathname.new('/rails_root')
45
+ end
46
+
47
+ def self.env
48
+ 'test'
49
+ end
34
50
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: configutron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Neal Clark
@@ -9,49 +15,69 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-03-03 00:00:00 -08:00
18
+ date: 2010-08-07 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: activesupport
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
23
32
  version: "0"
24
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: activesupport
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
30
40
  requirements:
31
41
  - - ">="
32
42
  - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
33
46
  version: "0"
34
- version:
47
+ type: :runtime
48
+ version_requirements: *id002
35
49
  - !ruby/object:Gem::Dependency
36
50
  name: rspec
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
40
54
  requirements:
41
55
  - - ">="
42
56
  - !ruby/object:Gem::Version
57
+ hash: 13
58
+ segments:
59
+ - 1
60
+ - 2
61
+ - 9
43
62
  version: 1.2.9
44
- version:
63
+ type: :development
64
+ version_requirements: *id003
45
65
  - !ruby/object:Gem::Dependency
46
66
  name: fakefs
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
50
70
  requirements:
51
71
  - - ">="
52
72
  - !ruby/object:Gem::Version
73
+ hash: 21
74
+ segments:
75
+ - 0
76
+ - 2
77
+ - 1
53
78
  version: 0.2.1
54
- version:
79
+ type: :development
80
+ version_requirements: *id004
55
81
  description: simple app-wide settings for rails applications
56
82
  email: nclark@thrownproject.com
57
83
  executables: []
@@ -84,21 +110,27 @@ rdoc_options:
84
110
  require_paths:
85
111
  - lib
86
112
  required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
87
114
  requirements:
88
115
  - - ">="
89
116
  - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
90
120
  version: "0"
91
- version:
92
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
+ none: false
93
123
  requirements:
94
124
  - - ">="
95
125
  - !ruby/object:Gem::Version
126
+ hash: 3
127
+ segments:
128
+ - 0
96
129
  version: "0"
97
- version:
98
130
  requirements: []
99
131
 
100
132
  rubyforge_project:
101
- rubygems_version: 1.3.5
133
+ rubygems_version: 1.3.7
102
134
  signing_key:
103
135
  specification_version: 3
104
136
  summary: simple app-wide settings for rails apps