config_reader 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ *.gem
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.7 2010-02-14
2
+ * moved to jeweler
3
+ * removed the annoying post install message
4
+ * updated specs
5
+
1
6
  == 0.0.6 2009-04-02
2
7
  * handle keys as ['foo'], [:foo] and .foo for real this time
3
8
  * return nil on non-existent key instead of error
data/README.rdoc ADDED
@@ -0,0 +1,45 @@
1
+ = ConfigReader
2
+
3
+ Provides a way to manage environment specific configuration settings. It will use the defaults for any environment and override any values you specify for an environment.
4
+
5
+ Example config file:
6
+
7
+ defaults:
8
+ site_url: http://localhost:3000
9
+ host_name: CHANGE-ME.com
10
+ mail_from: noreply@CHANGE_ME.com
11
+ site_name: CHANGE-ME
12
+ admin_email: admin@CHANGE-ME.com
13
+ blackbird: true
14
+
15
+ production:
16
+ site_url: http://CHANGE-ME.com
17
+ blackbird: false
18
+
19
+ test:
20
+ blackbird: false
21
+
22
+ Example class:
23
+
24
+ class MyConfig < ConfigReader
25
+ self.config_file = 'config/my_config.yml'
26
+ end
27
+
28
+ Usage:
29
+
30
+ MyConfig.mail_from #=> noreply@CHANGE_ME.com
31
+ MyConfig[:mail_from] #=> noreply@CHANGE_ME.com
32
+
33
+ == Note on Patches/Pull Requests
34
+
35
+ * Fork the project.
36
+ * Make your feature addition or bug fix.
37
+ * Add tests for it. This is important so I don't break it in a
38
+ future version unintentionally.
39
+ * Commit, do not mess with rakefile, version, or history.
40
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
41
+ * Send me a pull request. Bonus points for topic branches.
42
+
43
+ == Copyright
44
+
45
+ Copyright (c) 2008 Michael Moen. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "config_reader"
8
+ gem.summary = %Q{Provides a way to manage environment specific configuration settings.}
9
+ gem.description = %Q{Provides a way to manage environment specific configuration settings.}
10
+ gem.email = "michael@underpantsgnome.com"
11
+ gem.homepage = "http://github.com/UnderpantsGnome/config_reader-gem"
12
+ gem.authors = ["Michael Moen"]
13
+ gem.add_development_dependency "rspec", ">= 1.2.9"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ require 'spec/rake/spectask'
29
+ Spec::Rake::SpecTask.new(:spec) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.spec_files = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
35
+ spec.libs << 'lib' << 'spec'
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :spec => :check_dependencies
41
+
42
+ task :default => :spec
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "temp #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.7
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{config_reader}
8
+ s.version = "0.0.7"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Michael Moen"]
12
+ s.date = %q{2010-02-24}
13
+ s.description = %q{Provides a way to manage environment specific configuration settings.}
14
+ s.email = %q{michael@underpantsgnome.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "History.txt",
21
+ "License.txt",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "config_reader.gemspec",
26
+ "lib/config_reader.rb",
27
+ "spec/config_reader_spec.rb",
28
+ "spec/spec.opts",
29
+ "spec/spec_helper.rb",
30
+ "spec/test_config.rb",
31
+ "spec/test_config.yml"
32
+ ]
33
+ s.homepage = %q{http://github.com/UnderpantsGnome/config_reader-gem}
34
+ s.rdoc_options = ["--charset=UTF-8"]
35
+ s.require_paths = ["lib"]
36
+ s.rubygems_version = %q{1.3.6}
37
+ s.summary = %q{Provides a way to manage environment specific configuration settings.}
38
+ s.test_files = [
39
+ "spec/config_reader_spec.rb",
40
+ "spec/spec_helper.rb",
41
+ "spec/test_config.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
50
+ else
51
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
52
+ end
53
+ else
54
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
55
+ end
56
+ end
57
+
data/lib/config_reader.rb CHANGED
@@ -5,9 +5,6 @@ rescue LoadError
5
5
  puts "ERB not found, you won't be able to use ERB in your config"
6
6
  end
7
7
 
8
- $:.unshift(File.dirname(__FILE__)) unless
9
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
10
-
11
8
  class ConfigReader
12
9
  @config_file = nil
13
10
  @config = nil
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe "ConfigReader" do
4
+ describe "parsing a YAML file" do
5
+ it "should find values with method_missing" do
6
+ TestConfig.app_name.should == 'default_app'
7
+ end
8
+
9
+ it "should find values using [] and a string" do
10
+ TestConfig['app_name'].should == 'default_app'
11
+ end
12
+
13
+ it "should find values using [] and a symbol" do
14
+ TestConfig[:app_name].should == 'default_app'
15
+ end
16
+
17
+ it "should find nested values using using method_missing" do
18
+ TestConfig.nested_key.value.should == 'test'
19
+ end
20
+
21
+ it "should find nested values using [] and a string" do
22
+ TestConfig['nested_key']['value'].should == 'test'
23
+ end
24
+ end
25
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'spec'
4
+ require 'spec/autorun'
5
+ require 'config_reader'
6
+ require 'spec/test_config'
7
+
8
+ Spec::Runner.configure do |config|
9
+
10
+ end
@@ -0,0 +1,3 @@
1
+ class TestConfig < ConfigReader
2
+ self.config_file = 'spec/test_config.yml'
3
+ end
@@ -0,0 +1,8 @@
1
+ ---
2
+ defaults:
3
+ app_name: default_app
4
+ nested_key:
5
+ value: 'test'
6
+
7
+ test:
8
+ app_name: test_app
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_reader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 7
9
+ version: 0.0.7
5
10
  platform: ruby
6
11
  authors:
7
12
  - Michael Moen
@@ -9,71 +14,76 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2009-04-02 00:00:00 -05:00
17
+ date: 2010-02-24 00:00:00 -06:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
- name: hoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
23
- version: 1.8.0
24
- version:
25
- description: Configurations based on environment ala Rails
26
- email:
27
- - michael@underpantsgnome.com
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
31
+ version: 1.2.9
32
+ type: :development
33
+ version_requirements: *id001
34
+ description: Provides a way to manage environment specific configuration settings.
35
+ email: michael@underpantsgnome.com
28
36
  executables: []
29
37
 
30
38
  extensions: []
31
39
 
32
40
  extra_rdoc_files:
33
- - History.txt
34
- - License.txt
35
- - PostInstall.txt
36
- - README.txt
41
+ - README.rdoc
37
42
  files:
43
+ - .gitignore
38
44
  - History.txt
39
45
  - License.txt
40
- - PostInstall.txt
41
- - README.txt
46
+ - README.rdoc
47
+ - Rakefile
48
+ - VERSION
49
+ - config_reader.gemspec
42
50
  - lib/config_reader.rb
43
- - lib/config_reader/version.rb
51
+ - spec/config_reader_spec.rb
52
+ - spec/spec.opts
53
+ - spec/spec_helper.rb
54
+ - spec/test_config.rb
55
+ - spec/test_config.yml
44
56
  has_rdoc: true
45
- homepage: http://underpantsgnome.rubyforge.org
46
- post_install_message: |+
47
-
48
- For more information on config_reader, see http://config_reader.rubyforge.org
49
-
50
- NOTE: Change this information in PostInstall.txt
51
- You can also delete it if you don't want it.
52
-
53
-
57
+ homepage: http://github.com/UnderpantsGnome/config_reader-gem
58
+ licenses: []
59
+
60
+ post_install_message:
54
61
  rdoc_options:
55
- - --main
56
- - README.txt
62
+ - --charset=UTF-8
57
63
  require_paths:
58
64
  - lib
59
65
  required_ruby_version: !ruby/object:Gem::Requirement
60
66
  requirements:
61
67
  - - ">="
62
68
  - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
63
71
  version: "0"
64
- version:
65
72
  required_rubygems_version: !ruby/object:Gem::Requirement
66
73
  requirements:
67
74
  - - ">="
68
75
  - !ruby/object:Gem::Version
76
+ segments:
77
+ - 0
69
78
  version: "0"
70
- version:
71
79
  requirements: []
72
80
 
73
- rubyforge_project: underpantsgnome
74
- rubygems_version: 1.3.1
81
+ rubyforge_project:
82
+ rubygems_version: 1.3.6
75
83
  signing_key:
76
- specification_version: 2
77
- summary: Configurations based on environment ala Rails
78
- test_files: []
79
-
84
+ specification_version: 3
85
+ summary: Provides a way to manage environment specific configuration settings.
86
+ test_files:
87
+ - spec/config_reader_spec.rb
88
+ - spec/spec_helper.rb
89
+ - spec/test_config.rb
data/PostInstall.txt DELETED
@@ -1,7 +0,0 @@
1
-
2
- For more information on config_reader, see http://config_reader.rubyforge.org
3
-
4
- NOTE: Change this information in PostInstall.txt
5
- You can also delete it if you don't want it.
6
-
7
-
data/README.txt DELETED
@@ -1,48 +0,0 @@
1
- = config_reader
2
-
3
- * FIX (url)
4
-
5
- == DESCRIPTION:
6
-
7
- FIX (describe your package)
8
-
9
- == FEATURES/PROBLEMS:
10
-
11
- * FIX (list of features or problems)
12
-
13
- == SYNOPSIS:
14
-
15
- FIX (code sample of usage)
16
-
17
- == REQUIREMENTS:
18
-
19
- * FIX (list of requirements)
20
-
21
- == INSTALL:
22
-
23
- * FIX (sudo gem install, anything else)
24
-
25
- == LICENSE:
26
-
27
- (The MIT License)
28
-
29
- Copyright (c) 2008 FIXME full name
30
-
31
- Permission is hereby granted, free of charge, to any person obtaining
32
- a copy of this software and associated documentation files (the
33
- 'Software'), to deal in the Software without restriction, including
34
- without limitation the rights to use, copy, modify, merge, publish,
35
- distribute, sublicense, and/or sell copies of the Software, and to
36
- permit persons to whom the Software is furnished to do so, subject to
37
- the following conditions:
38
-
39
- The above copyright notice and this permission notice shall be
40
- included in all copies or substantial portions of the Software.
41
-
42
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,9 +0,0 @@
1
- module ConfigReader
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 0
5
- TINY = 6
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end