testcloud-config 0.0.0.1
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.
- checksums.yaml +7 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +71 -0
- data/LICENSE.txt +22 -0
- data/README.md +58 -0
- data/Rakefile +8 -0
- data/lib/testcloud/config.rb +26 -0
- data/lib/testcloud/config/configuration.rb +33 -0
- data/lib/testcloud/config/errors.rb +17 -0
- data/lib/testcloud/config/gem_version.rb +15 -0
- data/lib/testcloud/config/loader.rb +56 -0
- data/lib/testcloud/config/manager.rb +37 -0
- data/lib/testcloud/config/settings.rb +71 -0
- data/lib/testcloud/config/version.rb +15 -0
- data/lib/testcloud_config.rb +1 -0
- data/spec/fixtures/configs/one_level/redis.yml +8 -0
- data/spec/fixtures/configs/one_level_file +0 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/support/paths.rb +17 -0
- data/spec/testcloud/config/settings_spec.rb +103 -0
- data/spec/testcloud/config_spec.rb +12 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0ebd18bb831a726e746e107b98eb182fbf580c8c
|
4
|
+
data.tar.gz: 596551c4465862283ddc2233e7826f30cb7a3d48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0653bad60937806ac6893bd76bf579afc24a0674782971d17719ea9bd4562c0d4b258729303ecc34b7f81ead7a78cd948e4bae76b76f1e4b000ee63e9d86f7c4
|
7
|
+
data.tar.gz: 93cec4818cf79d57c54a97894a7040727d84836933764985de7df5c6af4120d8e37e98cac08b127c7345fa42a7828e124d8b28a07a077e0d59660b11e917feb7
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
testcloud-config (0.0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (4.1.5)
|
10
|
+
i18n (~> 0.6, >= 0.6.9)
|
11
|
+
json (~> 1.7, >= 1.7.7)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
thread_safe (~> 0.1)
|
14
|
+
tzinfo (~> 1.1)
|
15
|
+
builder (3.2.2)
|
16
|
+
coderay (1.1.0)
|
17
|
+
cucumber (1.3.16)
|
18
|
+
builder (>= 2.1.2)
|
19
|
+
diff-lcs (>= 1.1.3)
|
20
|
+
gherkin (~> 2.12)
|
21
|
+
multi_json (>= 1.7.5, < 2.0)
|
22
|
+
multi_test (>= 0.1.1)
|
23
|
+
diff-lcs (1.2.5)
|
24
|
+
gherkin (2.12.2)
|
25
|
+
multi_json (~> 1.3)
|
26
|
+
i18n (0.6.11)
|
27
|
+
json (1.8.1)
|
28
|
+
method_source (0.8.2)
|
29
|
+
minitest (5.4.1)
|
30
|
+
multi_json (1.10.1)
|
31
|
+
multi_test (0.1.1)
|
32
|
+
pry (0.10.1)
|
33
|
+
coderay (~> 1.1.0)
|
34
|
+
method_source (~> 0.8.1)
|
35
|
+
slop (~> 3.4)
|
36
|
+
rake (10.3.2)
|
37
|
+
rspec (3.0.0)
|
38
|
+
rspec-core (~> 3.0.0)
|
39
|
+
rspec-expectations (~> 3.0.0)
|
40
|
+
rspec-mocks (~> 3.0.0)
|
41
|
+
rspec-core (3.0.4)
|
42
|
+
rspec-support (~> 3.0.0)
|
43
|
+
rspec-expectations (3.0.4)
|
44
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
45
|
+
rspec-support (~> 3.0.0)
|
46
|
+
rspec-mocks (3.0.4)
|
47
|
+
rspec-support (~> 3.0.0)
|
48
|
+
rspec-support (3.0.4)
|
49
|
+
shoulda (3.5.0)
|
50
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
51
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
52
|
+
shoulda-context (1.2.1)
|
53
|
+
shoulda-matchers (2.6.2)
|
54
|
+
activesupport (>= 3.0.0)
|
55
|
+
slop (3.6.0)
|
56
|
+
thread_safe (0.3.4)
|
57
|
+
tzinfo (1.2.2)
|
58
|
+
thread_safe (~> 0.1)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
activesupport (>= 4.1)
|
65
|
+
bundler (~> 1.7)
|
66
|
+
cucumber (~> 1.3.16)
|
67
|
+
pry
|
68
|
+
rake (~> 10.0)
|
69
|
+
rspec (~> 3.0.0)
|
70
|
+
shoulda (~> 3.5.0)
|
71
|
+
testcloud-config!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 John Faucett
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
[](https://travis-ci.org/testCloud/testcloud-config)
|
2
|
+
|
3
|
+
## Testcloud Config
|
4
|
+
|
5
|
+
Testcloud config is a library for managing configuration options in gems, rails apps, and
|
6
|
+
generic ruby projects.
|
7
|
+
|
8
|
+
It currently handles loading yaml files based off of an environment.
|
9
|
+
If you are not using environments in your project, it requires you to set a 'default'
|
10
|
+
as your root yaml node.
|
11
|
+
|
12
|
+
#### Usage
|
13
|
+
|
14
|
+
Say we have this directory structure:
|
15
|
+
```bash
|
16
|
+
config/
|
17
|
+
redis.yml
|
18
|
+
```
|
19
|
+
|
20
|
+
And redis.yml looks like this:
|
21
|
+
```yaml
|
22
|
+
test:
|
23
|
+
url: 'redis://localhost:6378'
|
24
|
+
development:
|
25
|
+
url: 'redis://password@localhost:6379'
|
26
|
+
production:
|
27
|
+
url: 'redis://other-pw@production.server:4000'
|
28
|
+
```
|
29
|
+
|
30
|
+
Then we can load the file like so:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
|
34
|
+
Testcloud::Config.setup do |config|
|
35
|
+
config.environment = 'test'
|
36
|
+
|
37
|
+
# set the path to your root config directory
|
38
|
+
config.config_directory = '/path/to/config'
|
39
|
+
|
40
|
+
# set the name of the class you want to use
|
41
|
+
# to access the parsed config hash
|
42
|
+
config.config_classname = 'Configuration'
|
43
|
+
|
44
|
+
# automatically load/parse files after
|
45
|
+
# this setup block finishes executing
|
46
|
+
config.eager_load = true
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
And now we can do the following:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
Configuration.redis.url #=> 'redis://localhost:6378'
|
54
|
+
# oops, redis.yml had the wrong port
|
55
|
+
# we edit redis.yml and then call reload!
|
56
|
+
Testcloud::Config.reload!
|
57
|
+
Configuration.redis.url #=> 'redis://localhost:6379'
|
58
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
require 'monitor'
|
3
|
+
|
4
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
5
|
+
require 'active_support/core_ext/hash/deep_merge'
|
6
|
+
require 'active_support/core_ext/hash/slice'
|
7
|
+
|
8
|
+
module Testcloud
|
9
|
+
module Config
|
10
|
+
require 'testcloud/config/errors'
|
11
|
+
require 'testcloud/config/manager'
|
12
|
+
require 'testcloud/config/settings'
|
13
|
+
require 'testcloud/config/configuration'
|
14
|
+
require 'testcloud/config/loader'
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def setup(options = {}, &block)
|
18
|
+
lock = Monitor.new
|
19
|
+
lock.synchronize do
|
20
|
+
Manager.new(options, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module Testcloud
|
6
|
+
module Config
|
7
|
+
|
8
|
+
# thin wrapper around the internal hash representation object
|
9
|
+
class Configuration
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
attr_reader :hash
|
13
|
+
|
14
|
+
def_delegators :hash, :key?, :[], :[]=, :to_hash, :to_json, :inspect
|
15
|
+
|
16
|
+
def initialize(hash)
|
17
|
+
@hash = hash.respond_to?(:with_indifferent_access) ? hash.with_indifferent_access : hash
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def method_missing(method_name, *args, &block)
|
23
|
+
method_name = method_name.to_s[0..-2] if method_name.to_s[-1] == '?'
|
24
|
+
if key?(method_name)
|
25
|
+
value = hash[method_name]
|
26
|
+
value.is_a?(Hash) ? Testcloud::Config::Configuration.new(value) : value
|
27
|
+
else
|
28
|
+
super(method_name, *args, &block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end # Config
|
33
|
+
end # Testcloud
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Testcloud
|
2
|
+
module Config
|
3
|
+
module Errors
|
4
|
+
|
5
|
+
# raised when attempting to read the environment and no environment has been set
|
6
|
+
class NoEnvironmentError < StandardError; ;end
|
7
|
+
|
8
|
+
# raised when attempting to read the config_directory
|
9
|
+
# and no config_directory has been set
|
10
|
+
class ConfigDirectoryError < StandardError; ;end
|
11
|
+
|
12
|
+
# raised when trying to set config_name if something other than a String is passed.
|
13
|
+
class ConfigClassnameError < StandardError; ;end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Testcloud
|
2
|
+
module Config
|
3
|
+
module VERSION
|
4
|
+
def self.gem_version
|
5
|
+
@gem_version ||= Gem::Version.new(STRING)
|
6
|
+
end
|
7
|
+
|
8
|
+
MAJOR = 0
|
9
|
+
MINOR = 0
|
10
|
+
PATCH = 0
|
11
|
+
PRE = 1
|
12
|
+
STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
|
5
|
+
module Testcloud
|
6
|
+
module Config
|
7
|
+
class Loader
|
8
|
+
|
9
|
+
extend Forwardable
|
10
|
+
|
11
|
+
def_delegators :@settings, :environment, :config_directory
|
12
|
+
|
13
|
+
def initialize(settings = nil)
|
14
|
+
@settings = settings
|
15
|
+
end
|
16
|
+
|
17
|
+
def load_configuration
|
18
|
+
_load_configuration(config_directory, environment)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def _load_configuration(dir, env)
|
24
|
+
config = load_from_file(dir, env)
|
25
|
+
config.deep_merge!(load_from_directory(dir, env))
|
26
|
+
Testcloud::Config::Configuration.new(config)
|
27
|
+
end
|
28
|
+
|
29
|
+
def load_from_file(dir, env)
|
30
|
+
config = {}
|
31
|
+
if File.exists?(file = "#{dir}.yml")
|
32
|
+
config_file = YAML.load(ERB.new(IO.read(file)).result)
|
33
|
+
config = config_file[:default] || config_file['default'] || {}
|
34
|
+
config.deep_merge!(config_file[env] || {})
|
35
|
+
end
|
36
|
+
config
|
37
|
+
end
|
38
|
+
|
39
|
+
def load_from_directory(dir, env)
|
40
|
+
config = {}
|
41
|
+
if File.directory?(dir)
|
42
|
+
Dir["#{dir}/*"].each do |entry|
|
43
|
+
namespace = namespace_for_entry(dir, entry)
|
44
|
+
config.deep_merge!(namespace => _load_configuration(entry.gsub(/.yml$/, ''), env))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
config
|
48
|
+
end
|
49
|
+
|
50
|
+
def namespace_for_entry(dir, entry)
|
51
|
+
entry.gsub(/^#{dir}\/?/, '').gsub(/\.yml$/, '')
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Testcloud
|
2
|
+
module Config
|
3
|
+
|
4
|
+
class Manager
|
5
|
+
|
6
|
+
attr_reader :settings, :configuration, :loader
|
7
|
+
|
8
|
+
def initialize(options = {}, &block)
|
9
|
+
setup(options, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
def load!
|
13
|
+
@configuration = nil
|
14
|
+
@configuration = loader.load_configuration
|
15
|
+
set_config_constant!(@configuration) if settings.config_classname?
|
16
|
+
end
|
17
|
+
|
18
|
+
alias :reload! :load!
|
19
|
+
|
20
|
+
def setup(options = {}, &block)
|
21
|
+
@settings = Settings.new(options)
|
22
|
+
yield(@settings) if block_given?
|
23
|
+
@loader = Loader.new(@settings)
|
24
|
+
load! if settings.eager_load?
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def set_config_constant!(config)
|
29
|
+
if Kernel.const_defined?(settings.config_classname)
|
30
|
+
Kernel.__send__(:remove_const, settings.config_classname)
|
31
|
+
end
|
32
|
+
Kernel.const_set(settings.config_classname, config)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Testcloud
|
4
|
+
module Config
|
5
|
+
class Settings
|
6
|
+
|
7
|
+
PUBLIC_API_METHODS = [:environment, :config_directory, :config_classname, :eager_load].freeze
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@eager_load = true # always eager_load unless overridden
|
11
|
+
options.slice!(*PUBLIC_API_METHODS)
|
12
|
+
options.each do |method_name, value|
|
13
|
+
api_method = "#{method_name}="
|
14
|
+
self.public_send(api_method, value) if self.respond_to?(api_method)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def environment=(env)
|
19
|
+
@environment = env.respond_to?(:call) ? env.call : env
|
20
|
+
end
|
21
|
+
|
22
|
+
def environment
|
23
|
+
unless @environment
|
24
|
+
raise Testcloud::Config::Errors::NoEnvironmentError.new('environment must be defined.')
|
25
|
+
end
|
26
|
+
@environment
|
27
|
+
end
|
28
|
+
|
29
|
+
def config_directory=(dir)
|
30
|
+
unless File.exists?(dir) && File.directory?(dir)
|
31
|
+
raise Testcloud::Config::Errors::ConfigDirectoryError.new("config_directory: #{dir.inspect} must exist and be a directory.")
|
32
|
+
end
|
33
|
+
@config_directory = dir
|
34
|
+
end
|
35
|
+
|
36
|
+
def config_directory
|
37
|
+
unless @config_directory
|
38
|
+
raise Testcloud::Config::Errors::ConfigDirectoryError.new('config_directory must be defined.')
|
39
|
+
end
|
40
|
+
@config_directory
|
41
|
+
end
|
42
|
+
|
43
|
+
def config_classname=(konst)
|
44
|
+
unless konst.is_a?(String)
|
45
|
+
raise Testcloud::Config::Errors::ConfigClassnameError.new("config_classname: #{konst.inspect} must be a String")
|
46
|
+
end
|
47
|
+
@config_classname = konst
|
48
|
+
end
|
49
|
+
|
50
|
+
def config_classname
|
51
|
+
@config_classname
|
52
|
+
end
|
53
|
+
|
54
|
+
def config_classname?
|
55
|
+
!!config_classname
|
56
|
+
end
|
57
|
+
|
58
|
+
# allow eager loading i.e. load configuration files directly after setup block
|
59
|
+
def eager_load=(value)
|
60
|
+
@eager_load = value
|
61
|
+
end
|
62
|
+
|
63
|
+
# default eager_load to false
|
64
|
+
def eager_load
|
65
|
+
!!@eager_load
|
66
|
+
end
|
67
|
+
|
68
|
+
alias :eager_load? :eager_load
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'testcloud/config'
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
ENV['TESTCLOUD_ENV'] = ENV['RAILS_ENV'] = 'test'
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'testcloud_config'
|
5
|
+
|
6
|
+
# load support files
|
7
|
+
require_relative 'support/paths'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.include(Paths)
|
11
|
+
config.pattern = 'spec/**/*_spec.rb'
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Paths
|
2
|
+
class << self
|
3
|
+
|
4
|
+
def spec_root
|
5
|
+
@root ||= File.expand_path('../../../spec', __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
def fixtures
|
9
|
+
@fixtures ||= File.join(spec_root, 'fixtures')
|
10
|
+
end
|
11
|
+
|
12
|
+
def configs
|
13
|
+
@configs ||= File.join(fixtures, 'configs')
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Testcloud::Config::Settings do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@settings = Testcloud::Config::Settings.new
|
7
|
+
end
|
8
|
+
|
9
|
+
context 'environment' do
|
10
|
+
it 'should raise a NoEnvironmentError when accessing and not set' do
|
11
|
+
expect {
|
12
|
+
@settings.environment
|
13
|
+
}.to raise_error(Testcloud::Config::Errors::NoEnvironmentError)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should return the environment when already set' do
|
17
|
+
@settings.environment = 'foo'
|
18
|
+
expect(@settings.environment).to eq('foo')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should accept a callable object' do
|
22
|
+
my_env = 'bar'
|
23
|
+
@settings.environment = Proc.new { my_env }
|
24
|
+
expect(@settings.environment).to eq('bar')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'config_directory' do
|
29
|
+
it 'should raise a ConfigDirectoryError when accessed and not set' do
|
30
|
+
expect {
|
31
|
+
@settings.config_directory
|
32
|
+
}.to raise_error(Testcloud::Config::Errors::ConfigDirectoryError)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should raise a ConfigDirectoryError when not a directory' do
|
36
|
+
path = File.join(Paths.configs, 'one_level_file')
|
37
|
+
expect(File.exists?(path)).to eq(true)
|
38
|
+
expect {
|
39
|
+
@settings.config_directory = path
|
40
|
+
}.to raise_error(Testcloud::Config::Errors::ConfigDirectoryError)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should raise a ConfigDirectoryError when not existent' do
|
44
|
+
path = 'foobar'
|
45
|
+
expect(File.exists?(path)).to eq(false)
|
46
|
+
expect {
|
47
|
+
@settings.config_directory = path
|
48
|
+
}.to raise_error(Testcloud::Config::Errors::ConfigDirectoryError)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should set the config_directory when argument is a directory' do
|
52
|
+
path = File.join(Paths.configs, 'one_level')
|
53
|
+
expect(File.directory?(path)).to eq(true)
|
54
|
+
@settings.config_directory = path
|
55
|
+
expect(@settings.config_directory).to eq(path)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context 'config_classname' do
|
60
|
+
it 'should default to nil' do
|
61
|
+
expect(@settings.config_classname).to eq(nil)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should be settable' do
|
65
|
+
@settings.config_classname = 'Foo'
|
66
|
+
expect(@settings.config_classname).to eq('Foo')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should raise a ConfigClassnameError if a non-string is passed' do
|
70
|
+
[nil, Object.new, :foo, 45].each do |o|
|
71
|
+
expect {
|
72
|
+
@settings.config_classname = o
|
73
|
+
}.to raise_error(Testcloud::Config::Errors::ConfigClassnameError)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should be boolean questionable' do
|
78
|
+
expect(@settings.config_classname?).to eq(false)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'eager_load' do
|
83
|
+
it 'should default to true' do
|
84
|
+
expect(@settings.eager_load).to eq(true)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should be settable' do
|
88
|
+
@settings.eager_load = true
|
89
|
+
expect(@settings.eager_load).to eq(true)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should accept truthy values for the setter' do
|
93
|
+
[Object.new, "asdf", 100, true].each do |value|
|
94
|
+
@settings.eager_load = value
|
95
|
+
expect(@settings.eager_load).to eq(true)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should have an eager_load? alias' do
|
100
|
+
expect(@settings).to respond_to(:eager_load?)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: testcloud-config
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- testCloud Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '4.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '4.1'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- team@testcloud.io
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Gemfile.lock
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/testcloud/config.rb
|
68
|
+
- lib/testcloud/config/configuration.rb
|
69
|
+
- lib/testcloud/config/errors.rb
|
70
|
+
- lib/testcloud/config/gem_version.rb
|
71
|
+
- lib/testcloud/config/loader.rb
|
72
|
+
- lib/testcloud/config/manager.rb
|
73
|
+
- lib/testcloud/config/settings.rb
|
74
|
+
- lib/testcloud/config/version.rb
|
75
|
+
- lib/testcloud_config.rb
|
76
|
+
- spec/fixtures/configs/one_level/redis.yml
|
77
|
+
- spec/fixtures/configs/one_level_file
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/support/paths.rb
|
80
|
+
- spec/testcloud/config/settings_spec.rb
|
81
|
+
- spec/testcloud/config_spec.rb
|
82
|
+
homepage: https://testcloud.io
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.2.0
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Manage configuration options for gems and ruby apps
|
106
|
+
test_files:
|
107
|
+
- spec/fixtures/configs/one_level/redis.yml
|
108
|
+
- spec/fixtures/configs/one_level_file
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
- spec/support/paths.rb
|
111
|
+
- spec/testcloud/config/settings_spec.rb
|
112
|
+
- spec/testcloud/config_spec.rb
|