rails_config 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,3 +1,9 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gemspec
3
+ gemspec
4
+
5
+ gem "ruby-debug", :platforms => :mri_18
6
+ gem "ruby-debug19", :platforms => :mri_19
7
+
8
+ gem "autotest", ">= 0"
9
+ gem "growl-glue", ">= 0"
data/Gemfile.lock CHANGED
@@ -1,14 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_config (0.1.5)
4
+ rails_config (0.1.7)
5
5
  activesupport (~> 3.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  activesupport (3.0.0)
11
+ archive-tar-minitar (0.5.2)
12
+ autotest (4.3.2)
13
+ columnize (0.3.1)
11
14
  diff-lcs (1.1.2)
15
+ growl-glue (1.0.7)
16
+ linecache (0.43)
17
+ linecache19 (0.5.11)
18
+ ruby_core_source (>= 0.1.4)
12
19
  rspec (2.0.0)
13
20
  rspec-core (= 2.0.0)
14
21
  rspec-expectations (= 2.0.0)
@@ -19,11 +26,30 @@ GEM
19
26
  rspec-mocks (2.0.0)
20
27
  rspec-core (= 2.0.0)
21
28
  rspec-expectations (= 2.0.0)
29
+ ruby-debug (0.10.3)
30
+ columnize (>= 0.1)
31
+ ruby-debug-base (~> 0.10.3.0)
32
+ ruby-debug-base (0.10.3)
33
+ linecache (>= 0.3)
34
+ ruby-debug-base19 (0.11.24)
35
+ columnize (>= 0.3.1)
36
+ linecache19 (>= 0.5.11)
37
+ ruby_core_source (>= 0.1.4)
38
+ ruby-debug19 (0.11.6)
39
+ columnize (>= 0.3.1)
40
+ linecache19 (>= 0.5.11)
41
+ ruby-debug-base19 (>= 0.11.19)
42
+ ruby_core_source (0.1.4)
43
+ archive-tar-minitar (>= 0.5.2)
22
44
 
23
45
  PLATFORMS
24
46
  ruby
25
47
 
26
48
  DEPENDENCIES
27
49
  activesupport (~> 3.0)
50
+ autotest
51
+ growl-glue
28
52
  rails_config!
29
- rspec (>= 2.0.0.beta.19)
53
+ rspec (~> 2.0)
54
+ ruby-debug
55
+ ruby-debug19
data/README.md CHANGED
@@ -38,7 +38,7 @@ This will generate `config/initializers/rails_config.rb` with a set of default s
38
38
 
39
39
  ## Accessing the Settings object
40
40
 
41
- After installing this plugin, the Settings object will be global available. Entries are accessed via object member notation:
41
+ After installing this plugin, the `Settings` object will be available globally. Entries are accessed via object member notation:
42
42
 
43
43
  Settings.my_config_entry
44
44
 
@@ -50,21 +50,21 @@ If you have set a different constant name for the object in the initializer file
50
50
 
51
51
  ## Common config file
52
52
 
53
- Config entries are compiled from
53
+ Config entries are compiled from:
54
54
 
55
55
  config/settings.yml
56
56
  config/settings/#{environment}.yml
57
57
  config/environments/#{environment}.yml
58
58
 
59
- settings defined in files that are lower in the list override settings higher
59
+ Settings defined in files that are lower in the list override settings higher.
60
60
 
61
61
  ### Reloading settings
62
62
 
63
- You can reload the Settings object at any time by running Settings.reload!
63
+ You can reload the Settings object at any time by running `Settings.reload!`.
64
64
 
65
65
  ### Reloading settings and config files
66
66
 
67
- You can also reload the Settings object from different config files at runtime.
67
+ You can also reload the `Settings` object from different config files at runtime.
68
68
 
69
69
  For example, in your tests if you want to test the production settings, you can:
70
70
 
@@ -77,7 +77,7 @@ For example, in your tests if you want to test the production settings, you can:
77
77
 
78
78
  ### Environment specific config files
79
79
 
80
- You can have environment specific config files. Environment specific config entries take precedence over common config entries.
80
+ You can have environment specific config files. Environment specific config entries take precedence over common config entries.
81
81
 
82
82
  Example development environment config file:
83
83
 
@@ -87,9 +87,23 @@ Example production environment config file:
87
87
 
88
88
  #{Rails.root}/config/environments/production.yml
89
89
 
90
+ ### Adding sources at Runtime
91
+
92
+ You can add new YAML config files at runtime. Just use:
93
+
94
+ Settings.add_source!("/path/to/source.yml")
95
+ Settings.reload!
96
+
97
+ This will use the given source.yml file and use its settings to overwrite any previous ones.
98
+
99
+ One thing I like to do for my Rails projects is provide a local.yml config file that is .gitignored (so its independent per developer). Then I create a new initializer in `config/initializers/add_local_config.rb` with the contents
100
+
101
+ Settings.add_source!("#{Rails.root}/config/settings/local.yml")
102
+ Settings.reload!
103
+
90
104
  ## Embedded Ruby (ERB)
91
105
 
92
- Embedded Ruby is allowed in the configuration files. See examples below.
106
+ Embedded Ruby is allowed in the configuration files. See examples below.
93
107
 
94
108
  ## Accessing Configuration Settings
95
109
 
data/Rakefile CHANGED
@@ -1,23 +1,43 @@
1
+ require "bundler"
2
+ Bundler.setup
3
+
1
4
  require 'rake'
5
+ require 'rake/gempackagetask'
6
+
7
+ gemspec = eval(File.read('rails_config.gemspec'))
8
+ Rake::GemPackageTask.new(gemspec) do |pkg|
9
+ pkg.gem_spec = gemspec
10
+ end
11
+
12
+ desc "build the gem and release it to rubygems.org"
13
+ task :release => :gem do
14
+ puts "Tagging #{gemspec.version}..."
15
+ system "git tag -a #{gemspec.version} -m 'Tagging #{gemspec.version}'"
16
+ puts "Pushing to Github..."
17
+ system "git push --tags"
18
+ puts "Pushing to rubygems.org..."
19
+ system "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
20
+ end
21
+
22
+ require "rspec"
23
+ require "rspec/core/rake_task"
24
+
25
+ Rspec::Core::RakeTask.new(:spec) do |spec|
26
+ spec.pattern = "spec/**/*_spec.rb"
27
+ end
28
+
29
+ Rspec::Core::RakeTask.new('spec:progress') do |spec|
30
+ spec.rspec_opts = %w(--format progress)
31
+ spec.pattern = "spec/**/*_spec.rb"
32
+ end
33
+
34
+ require "rake/rdoctask"
35
+ Rake::RDocTask.new do |rdoc|
36
+ rdoc.rdoc_dir = "rdoc"
37
+ rdoc.title = "Rails Config #{gemspec.version}"
38
+ rdoc.rdoc_files.include("README*")
39
+ rdoc.rdoc_files.include("lib/**/*.rb")
40
+ end
41
+
2
42
 
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |s|
6
- s.name = "rails_config"
7
- s.summary = "provides an Settings for rails3 that reads config/settings.yml"
8
- s.homepage = "http://github.com/railsjedi/rails_config"
9
- s.description = "Provides an easy to use Application Configuration object"
10
- s.authors = ["Jacques Crocker", "Fred Wu"]
11
- s.email = ["railsjedi@gmail.com", "ifredwu@gmail.com"]
12
- s.files = FileList["[A-Z]*", "{bin,generators,lib,spec}/**/*"]
13
-
14
- s.add_dependency 'activesupport', "~> 3.0"
15
- s.add_development_dependency 'rspec', "~> 2.0"
16
- s.add_development_dependency 'autotest'
17
- s.add_development_dependency 'growl-glue'
18
- s.add_development_dependency 'ruby-debug' if RUBY_VERSION < "1.9"
19
- end
20
- Jeweler::GemcutterTasks.new
21
- rescue LoadError
22
- puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
23
- end
43
+ task :default => :spec
data/lib/rails_config.rb CHANGED
@@ -24,8 +24,9 @@ module RailsConfig
24
24
 
25
25
  # add yaml sources
26
26
  [files].flatten.compact.uniq.each do |file|
27
- config.add_source!(Sources::YAMLSource.new(file))
27
+ config.add_source!(file.to_s)
28
28
  end
29
+
29
30
  config.load!
30
31
  config
31
32
  end
@@ -7,6 +7,9 @@ module RailsConfig
7
7
  end
8
8
 
9
9
  def add_source!(source)
10
+ # handle yaml file paths
11
+ source = (Sources::YAMLSource.new(source)) if source.is_a?(String)
12
+
10
13
  @config_sources ||= []
11
14
  @config_sources << source
12
15
  end
@@ -0,0 +1,34 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "rails_config"
3
+ s.version = "0.1.7"
4
+
5
+ s.authors = ["Jacques Crocker", "Fred Wu"]
6
+ s.summary = "Provides a Settings helper for rails3 that reads from config/settings.yml"
7
+ s.description = "Easy to use Settings helper that loads its data in from config/settings.yml. Handles adding multiple sources, and easy reloading."
8
+ s.email = ["railsjedi@gmail.com", "ifredwu@gmail.com"]
9
+ s.homepage = "http://github.com/railsjedi/rails_config"
10
+
11
+ s.require_paths = ["lib"]
12
+ s.files = Dir['lib/**/*',
13
+ 'spec/**/*',
14
+ 'rails_config.gemspec',
15
+ 'Gemfile',
16
+ 'Gemfile.lock',
17
+ 'LICENSE',
18
+ 'Rakefile',
19
+ 'README.md',
20
+ 'TODO']
21
+
22
+ s.test_files = Dir['spec/**/*']
23
+ s.rdoc_options = ["--charset=UTF-8"]
24
+ s.extra_rdoc_files = [
25
+ "LICENSE",
26
+ "README.md",
27
+ "TODO"
28
+ ]
29
+
30
+ s.add_runtime_dependency "activesupport", "~> 3.0"
31
+ s.add_development_dependency "rspec", "~> 2.0"
32
+
33
+ end
34
+
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rails_config'
2
2
  require 'pathname'
3
- require "bundler"
4
- Bundler.setup
3
+ require 'bundler/setup'
5
4
 
6
5
  def in_editor?
7
6
  ENV.has_key?('TM_MODE') || ENV.has_key?('EMACS') || ENV.has_key?('VIM')
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_config
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 21
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 6
9
- version: 0.1.6
9
+ - 7
10
+ version: 0.1.7
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jacques Crocker
@@ -15,64 +16,40 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-10-12 00:00:00 +11:00
19
+ date: 2010-10-26 00:00:00 -07:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
- name: activesupport
23
+ type: :runtime
23
24
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
+ name: activesupport
26
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
27
  none: false
26
28
  requirements:
27
29
  - - ~>
28
30
  - !ruby/object:Gem::Version
31
+ hash: 7
29
32
  segments:
30
33
  - 3
31
34
  - 0
32
35
  version: "3.0"
33
- type: :runtime
34
- version_requirements: *id001
36
+ requirement: *id001
35
37
  - !ruby/object:Gem::Dependency
36
- name: rspec
38
+ type: :development
37
39
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ name: rspec
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
39
42
  none: false
40
43
  requirements:
41
44
  - - ~>
42
45
  - !ruby/object:Gem::Version
46
+ hash: 3
43
47
  segments:
44
48
  - 2
45
49
  - 0
46
50
  version: "2.0"
47
- type: :development
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: autotest
51
- prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- segments:
58
- - 0
59
- version: "0"
60
- type: :development
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: growl-glue
64
- prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
66
- none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- segments:
71
- - 0
72
- version: "0"
73
- type: :development
74
- version_requirements: *id004
75
- description: Provides an easy to use Application Configuration object
51
+ requirement: *id002
52
+ description: Easy to use Settings helper that loads its data in from config/settings.yml. Handles adding multiple sources, and easy reloading.
76
53
  email:
77
54
  - railsjedi@gmail.com
78
55
  - ifredwu@gmail.com
@@ -85,24 +62,17 @@ extra_rdoc_files:
85
62
  - README.md
86
63
  - TODO
87
64
  files:
88
- - Gemfile
89
- - Gemfile.lock
90
- - LICENSE
91
- - README.md
92
- - Rakefile
93
- - TODO
94
- - VERSION
95
65
  - lib/generators/rails_config/install_generator.rb
96
66
  - lib/generators/rails_config/templates/rails_config.rb
97
- - lib/generators/rails_config/templates/settings.yml
98
67
  - lib/generators/rails_config/templates/settings/development.yml
99
68
  - lib/generators/rails_config/templates/settings/production.yml
100
69
  - lib/generators/rails_config/templates/settings/test.yml
101
- - lib/rails_config.rb
70
+ - lib/generators/rails_config/templates/settings.yml
102
71
  - lib/rails_config/options.rb
103
72
  - lib/rails_config/railtie.rb
104
73
  - lib/rails_config/sources/yaml_source.rb
105
74
  - lib/rails_config/vendor/deep_merge.rb
75
+ - lib/rails_config.rb
106
76
  - spec/fixtures/bool_override/config1.yml
107
77
  - spec/fixtures/bool_override/config2.yml
108
78
  - spec/fixtures/custom_types/hash.yml
@@ -119,6 +89,13 @@ files:
119
89
  - spec/rails_config_spec.rb
120
90
  - spec/sources/yaml_source_spec.rb
121
91
  - spec/spec_helper.rb
92
+ - rails_config.gemspec
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE
96
+ - Rakefile
97
+ - README.md
98
+ - TODO
122
99
  has_rdoc: true
123
100
  homepage: http://github.com/railsjedi/rails_config
124
101
  licenses: []
@@ -133,6 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
110
  requirements:
134
111
  - - ">="
135
112
  - !ruby/object:Gem::Version
113
+ hash: 3
136
114
  segments:
137
115
  - 0
138
116
  version: "0"
@@ -141,6 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
119
  requirements:
142
120
  - - ">="
143
121
  - !ruby/object:Gem::Version
122
+ hash: 3
144
123
  segments:
145
124
  - 0
146
125
  version: "0"
@@ -150,8 +129,21 @@ rubyforge_project:
150
129
  rubygems_version: 1.3.7
151
130
  signing_key:
152
131
  specification_version: 3
153
- summary: provides an Settings for rails3 that reads config/settings.yml
132
+ summary: Provides a Settings helper for rails3 that reads from config/settings.yml
154
133
  test_files:
134
+ - spec/fixtures/bool_override/config1.yml
135
+ - spec/fixtures/bool_override/config2.yml
136
+ - spec/fixtures/custom_types/hash.yml
137
+ - spec/fixtures/deep_merge/config1.yml
138
+ - spec/fixtures/deep_merge/config2.yml
139
+ - spec/fixtures/deep_merge2/config1.yml
140
+ - spec/fixtures/deep_merge2/config2.yml
141
+ - spec/fixtures/development.yml
142
+ - spec/fixtures/empty1.yml
143
+ - spec/fixtures/empty2.yml
144
+ - spec/fixtures/settings.yml
145
+ - spec/fixtures/settings2.yml
146
+ - spec/fixtures/with_erb.yml
155
147
  - spec/rails_config_spec.rb
156
148
  - spec/sources/yaml_source_spec.rb
157
149
  - spec/spec_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.6