webmat-local_config 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/Rakefile ADDED
@@ -0,0 +1,57 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "local_config"
8
+ gem.summary = %Q{Micro plugin to solve a micro problem: loading
9
+ either your .local.yml config file if it's there, or the official .yml otherwise.}
10
+ gem.email = "webmat@gmail.com"
11
+ gem.homepage = "http://github.com/webmat/local_config"
12
+ gem.authors = ["Mathieu Martin"]
13
+
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ rescue LoadError
17
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/*_test.rb'
24
+ test.verbose = false
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/*_test.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+
41
+ task :default => :test
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ if File.exist?('VERSION.yml')
46
+ config = YAML.load(File.read('VERSION.yml'))
47
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
48
+ else
49
+ version = ""
50
+ end
51
+
52
+ rdoc.rdoc_dir = 'rdoc'
53
+ rdoc.title = "local_config #{version}"
54
+ rdoc.rdoc_files.include('README*')
55
+ rdoc.rdoc_files.include('lib/**/*.rb')
56
+ end
57
+
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :minor: 2
3
- :patch: 0
4
2
  :major: 0
3
+ :minor: 2
4
+ :patch: 1
data/lib/local_config.rb CHANGED
@@ -11,9 +11,21 @@ module LocalConfig
11
11
  yaml = YAML.load(File.read(config_file))
12
12
  if yaml.is_a? Hash
13
13
  config = HashWithIndifferentAccess.new yaml
14
- environment ? config[RAILS_ENV] : config
14
+ if environment
15
+ log "WARNING: LocalConfig loaded an empty configuration for #{name}. Maybe you want to use :environment => false?" if config[RAILS_ENV].nil?
16
+ config[RAILS_ENV]
17
+ else
18
+ config
19
+ end
15
20
  else
16
21
  yaml
17
22
  end
18
23
  end
24
+
25
+ def self.log(message)
26
+ warn message
27
+ if defined?(Rails)
28
+ Rails.logger.warn message
29
+ end
30
+ end
19
31
  end
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{local_config}
8
+ s.version = "0.2.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mathieu Martin"]
12
+ s.date = %q{2009-09-25}
13
+ s.email = %q{webmat@gmail.com}
14
+ s.extra_rdoc_files = [
15
+ "LICENSE",
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "LICENSE",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION.yml",
24
+ "lib/local_config.rb",
25
+ "local_config.gemspec",
26
+ "test/local_config_test.rb",
27
+ "test/test_helper.rb",
28
+ "test/test_rails_root/config/no_env.yml",
29
+ "test/test_rails_root/config/no_env_no_hash.yml",
30
+ "test/test_rails_root/config/no_env_with_hash.yml",
31
+ "test/test_rails_root/config/with_local.local.yml",
32
+ "test/test_rails_root/config/with_local.yml",
33
+ "test/test_rails_root/config/without_local.yml"
34
+ ]
35
+ s.has_rdoc = true
36
+ s.homepage = %q{http://github.com/webmat/local_config}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.2}
40
+ s.summary = %q{Micro plugin to solve a micro problem: loading either your .local.yml config file if it's there, or the official .yml otherwise.}
41
+ s.test_files = [
42
+ "test/local_config_test.rb",
43
+ "test/test_helper.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ else
52
+ end
53
+ else
54
+ end
55
+ end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class LocalConfigTest < Test::Unit::TestCase
4
4
  context "with RAILS_ENV set to 'development'" do
@@ -39,9 +39,25 @@ class LocalConfigTest < Test::Unit::TestCase
39
39
  assert_equal 'never overridden', @config[:param]
40
40
  end
41
41
  end
42
+
43
+ context "reading no_env_with_hash.yml which contains a hash with no env" do
44
+ context "forgetting to specify :environment => false" do
45
+ setup do
46
+ @config = LocalConfig.load_config('no_env_with_hash')
47
+ end
48
+
49
+ should "return nil" do
50
+ assert_nil @config
51
+ end
52
+
53
+ before_should "give a console warning" do
54
+ LocalConfig.expects(:warn).with{ |param| param =~ /empty.*no_env_with_hash/ }
55
+ end
56
+ end
57
+ end
42
58
  end
43
59
 
44
- context "reading no_env_ho_hash.yml which contains an array rather than a hash" do
60
+ context "reading no_env_no_hash.yml which contains an array rather than a hash" do
45
61
  setup do
46
62
  @config = LocalConfig.load_config('no_env_no_hash', :environment => false)
47
63
  end
data/test/test_helper.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
3
  require 'shoulda'
4
+ gem 'mocha', '= 0.9.5'
5
+ require 'mocha'
4
6
  require 'activesupport'
5
7
 
6
8
  test_dir = File.dirname(__FILE__)
@@ -0,0 +1 @@
1
+ param: value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webmat-local_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathieu Martin
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-03 00:00:00 -07:00
12
+ date: 2009-09-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -20,27 +20,29 @@ executables: []
20
20
  extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
- - README.rdoc
24
23
  - LICENSE
24
+ - README.rdoc
25
25
  files:
26
+ - .gitignore
27
+ - LICENSE
26
28
  - README.rdoc
29
+ - Rakefile
27
30
  - VERSION.yml
28
31
  - lib/local_config.rb
32
+ - local_config.gemspec
29
33
  - test/local_config_test.rb
30
34
  - test/test_helper.rb
31
- - test/test_rails_root
32
- - test/test_rails_root/config
33
35
  - test/test_rails_root/config/no_env.yml
34
36
  - test/test_rails_root/config/no_env_no_hash.yml
37
+ - test/test_rails_root/config/no_env_with_hash.yml
35
38
  - test/test_rails_root/config/with_local.local.yml
36
39
  - test/test_rails_root/config/with_local.yml
37
40
  - test/test_rails_root/config/without_local.yml
38
- - LICENSE
39
41
  has_rdoc: true
40
42
  homepage: http://github.com/webmat/local_config
43
+ licenses:
41
44
  post_install_message:
42
45
  rdoc_options:
43
- - --inline-source
44
46
  - --charset=UTF-8
45
47
  require_paths:
46
48
  - lib
@@ -59,9 +61,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
61
  requirements: []
60
62
 
61
63
  rubyforge_project:
62
- rubygems_version: 1.2.0
64
+ rubygems_version: 1.3.5
63
65
  signing_key:
64
- specification_version: 2
66
+ specification_version: 3
65
67
  summary: "Micro plugin to solve a micro problem: loading either your .local.yml config file if it's there, or the official .yml otherwise."
66
- test_files: []
67
-
68
+ test_files:
69
+ - test/local_config_test.rb
70
+ - test/test_helper.rb