config-file-loader 0.1.1 → 0.1.2

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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in config_file_loader.gemspec
4
+ gemspec
@@ -0,0 +1,24 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ config-file-loader (0.1.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ rspec (2.11.0)
11
+ rspec-core (~> 2.11.0)
12
+ rspec-expectations (~> 2.11.0)
13
+ rspec-mocks (~> 2.11.0)
14
+ rspec-core (2.11.1)
15
+ rspec-expectations (2.11.3)
16
+ diff-lcs (~> 1.1.3)
17
+ rspec-mocks (2.11.3)
18
+
19
+ PLATFORMS
20
+ java
21
+
22
+ DEPENDENCIES
23
+ config-file-loader!
24
+ rspec (>= 1.2.9)
@@ -1,6 +1,6 @@
1
1
  # config-file-loader
2
2
 
3
- Inspired/ ripped off from ryan bate's great railscast
3
+ Inspired/ ripped off from Ryan Bate's great railscast
4
4
 
5
5
  [http://railscasts.com/episodes/85-yaml-configuration-file]()
6
6
 
@@ -9,19 +9,12 @@ Inspired/ ripped off from ryan bate's great railscast
9
9
  * configuration file is in yaml
10
10
  * supports erb in yaml file
11
11
  * assumes/adds yml extension
12
- * assumes file is in RAILS_ROOT/config
12
+ * assumes file is in config/
13
13
  * can override config file location per file (using an absolute or relative path) or globally
14
14
  * allows custom override files, so for local developers or production per machine values
15
15
  * different variable values for different "Rails" environments.
16
16
  * works in Rails, but also in non rails-projects.
17
17
 
18
- ## planned features
19
-
20
- * monitoring files and updating upon file changes using fsevents.
21
- * database based config values
22
- * memcache config values
23
- * ui to see and edit variables (will save to db/memcache - probably not file)
24
-
25
18
  ## file format
26
19
 
27
20
  supports aliases, erb, and any yaml construct.
@@ -47,14 +40,20 @@ override file:
47
40
  attribute2:
48
41
  attribute2a: replaced-value2a
49
42
 
50
- If you are nesting hashes within a file, remember that yaml will replace the whole hash.
43
+ Note: override files do deep merges. but yml files ( <<: *defaults and &defaults) does not work for deep merge
51
44
 
52
45
  But a separate override file will merge in values. So in development, only attribute2a will be replaced.
53
46
 
54
- ## usage
47
+ ## Installation
48
+
49
+ Add this line to your application's Gemfile:
50
+
51
+ gem 'config_file_loader'
52
+
53
+ ## Usage
55
54
 
56
55
  APP_CONFIG = ConfigFileLoader.load(
57
- 'app_config.yml',
56
+ 'app_config',
58
57
  'app_config_local.yml',
59
58
  '/opt/local/config/app_config_override.yml'
60
59
  )
@@ -72,4 +71,4 @@ But a separate override file will merge in values. So in development, only attri
72
71
 
73
72
  ## Copyright
74
73
 
75
- Copyright (c) 2010 kbrock. See LICENSE for details.
74
+ Copyright (c) 2012 kbrock. See LICENSE for details.
data/Rakefile CHANGED
@@ -1,45 +1,6 @@
1
- require 'rubygems'
2
- require 'rake'
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "config-file-loader"
8
- gem.summary = %Q{Load config files from disk}
9
- gem.description = %Q{simple way to load erb yaml config files. based upon http://railscasts.com/episodes/85-yaml-configuration-file}
10
- gem.email = "keenan@thebrocks.net"
11
- gem.homepage = "http://github.com/kbrock/config-file-loader"
12
- gem.authors = ["kbrock"]
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
4
+ RSpec::Core::RakeTask.new('spec')
20
5
 
21
- require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
25
- end
26
-
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
31
- end
32
-
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
-
37
- require 'rake/rdoctask'
38
- Rake::RDocTask.new do |rdoc|
39
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
-
41
- rdoc.rdoc_dir = 'rdoc'
42
- rdoc.title = "config-file-loader #{version}"
43
- rdoc.rdoc_files.include('README*')
44
- rdoc.rdoc_files.include('lib/**/*.rb')
45
- end
6
+ task :default => :spec
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'config_file_loader/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "config-file-loader"
8
+ s.version = ConfigFileLoader::VERSION
9
+ s.authors = ["kbrock"]
10
+ s.email = "keenan@thebrocks.net"
11
+ s.description = "simple way to load erb yaml config files. based upon http://railscasts.com/episodes/85-yaml-configuration-file"
12
+ s.summary = "Load config files from disk"
13
+ s.homepage = "http://github.com/kbrock/config-file-loader"
14
+
15
+ s.files = `git ls-files`.split($/)
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_development_dependency "rspec", ">= 1.2.9"
22
+ end
@@ -1,6 +1,8 @@
1
1
  require 'erb'
2
2
  require 'yaml'
3
3
  require 'ostruct'
4
+ require "config_file_loader/version"
5
+
4
6
  class ConfigFileLoader
5
7
 
6
8
  ## base directory for configuration
@@ -21,12 +23,14 @@ class ConfigFileLoader
21
23
 
22
24
 
23
25
  def self.env
24
- if defined?(@@env)
25
- @@env
26
- elsif defined?(RAILS_ENV)
27
- RAILS_ENV
28
- end
29
- #else nil
26
+ @@env ||=
27
+ if defined?(Rails)
28
+ Rails.env
29
+ elsif defined?(RAILS_ENV)
30
+ RAILS_ENV
31
+ else
32
+ ENV['RACK_ENV'] || ENV['RAILS_ENV'] || ENV['ENVIRONMENT']
33
+ end
30
34
  end
31
35
 
32
36
  def self.env=(val)
@@ -0,0 +1,3 @@
1
+ class ConfigFileLoader
2
+ VERSION = "0.1.2"
3
+ end
@@ -1,9 +1,8 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'config_file_loader'
4
- require 'spec'
5
- require 'spec/autorun'
1
+ require 'rubygems'
2
+ require 'bundler/setup'
6
3
 
7
- Spec::Runner.configure do |config|
4
+ require 'config-file-loader'
5
+
6
+ RSpec.configure do |config|
8
7
  ConfigFileLoader.base = File.join(File.dirname(__FILE__),'config/')
9
8
  end
metadata CHANGED
@@ -1,59 +1,52 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: config-file-loader
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - kbrock
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2010-08-18 00:00:00 -04:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-09-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 13
30
- segments:
31
- - 1
32
- - 2
33
- - 9
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
34
21
  version: 1.2.9
35
22
  type: :development
36
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.2.9
37
30
  description: simple way to load erb yaml config files. based upon http://railscasts.com/episodes/85-yaml-configuration-file
38
31
  email: keenan@thebrocks.net
39
32
  executables: []
40
-
41
33
  extensions: []
42
-
43
- extra_rdoc_files:
44
- - LICENSE
45
- - README.markdown
46
- files:
34
+ extra_rdoc_files: []
35
+ files:
47
36
  - .document
48
37
  - .gitignore
49
38
  - CHANGELOG
39
+ - Gemfile
40
+ - Gemfile.lock
50
41
  - LICENSE
51
42
  - README.markdown
52
43
  - Rakefile
53
44
  - VERSION
45
+ - config_file_loader.gemspec
54
46
  - init.rb
55
47
  - lib/config-file-loader.rb
56
48
  - lib/config_file_loader.rb
49
+ - lib/config_file_loader/version.rb
57
50
  - rails/init.rb
58
51
  - spec/config/a.yml
59
52
  - spec/config/b.yml
@@ -64,43 +57,37 @@ files:
64
57
  - spec/spec.opts
65
58
  - spec/spec_helper.rb
66
59
  - spec/symbolize_keys_spec.rb
67
- has_rdoc: true
68
60
  homepage: http://github.com/kbrock/config-file-loader
69
61
  licenses: []
70
-
71
62
  post_install_message:
72
- rdoc_options:
73
- - --charset=UTF-8
74
- require_paths:
63
+ rdoc_options: []
64
+ require_paths:
75
65
  - lib
76
- required_ruby_version: !ruby/object:Gem::Requirement
66
+ required_ruby_version: !ruby/object:Gem::Requirement
77
67
  none: false
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- hash: 3
82
- segments:
83
- - 0
84
- version: "0"
85
- required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
73
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
94
78
  requirements: []
95
-
96
79
  rubyforge_project:
97
- rubygems_version: 1.3.7
80
+ rubygems_version: 1.8.24
98
81
  signing_key:
99
82
  specification_version: 3
100
83
  summary: Load config files from disk
101
- test_files:
84
+ test_files:
85
+ - spec/config/a.yml
86
+ - spec/config/b.yml
87
+ - spec/config/dev_prod.yml
102
88
  - spec/config_file_loader_spec.rb
103
89
  - spec/deep_merge_spec.rb
104
90
  - spec/filename_spec.rb
91
+ - spec/spec.opts
105
92
  - spec/spec_helper.rb
106
93
  - spec/symbolize_keys_spec.rb