cupcakinator 1.0.1 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7fb293e6149e867f87d9035717003c5a01c704e6
4
- data.tar.gz: f09b3e9605786096e4fe20d40c83f50bb3a3a088
3
+ metadata.gz: ef9ce571b53c125b293184143541e24ec299eadd
4
+ data.tar.gz: 6d108263870627cbdd02e5ae943112a907cf3997
5
5
  SHA512:
6
- metadata.gz: 8b743b447c53e9195a07c8f39819e8b91782fac0d75a84867098f37635ffa14c101780bceac0c385418c3f0202994ac3ba24e345370cfb2b9215a06afbd00915
7
- data.tar.gz: 0cfd6d092cbd0c3a78ff1f975fa4374d40a7d2cca129148fef2bab608a200c5ef6ba752104581636e74018fb095263f6ce16cc6d49ece71fb5993bfeeb6cec80
6
+ metadata.gz: baf0a1919f69fb660b916cc70f719129f2131cb86bb249404fb51082c7110e7d1b49dd4ab190eb20d5d439f8bce3ba8684cdf7faee5a72dad462caf9c7bf2e54
7
+ data.tar.gz: 916184623bb21a1186488ee94408fe18ae53643e1d5dc545b63908d99cc319957168070656f17c1ff9718c8c6931a6eb1701f6cccf8c1dcd6833d42bd0a659cd
@@ -1 +1 @@
1
- 2.0.0-p353
1
+ 2.1.0
data/Gemfile CHANGED
@@ -10,12 +10,15 @@ gem 'json', '~> 1.8'
10
10
  group :development, :test do
11
11
  gem 'debugger'
12
12
  gem 'guard'
13
+ gem 'guard-bundler'
13
14
  gem 'guard-rspec'
14
15
  gem 'guard-spork'
15
- gem 'rake'
16
- gem 'rb-readline'
17
16
  gem 'redcarpet'
17
+ gem 'yard'
18
+ end
19
+
20
+ group :development, :test, :ci do
21
+ gem 'rake'
18
22
  gem 'rspec'
19
23
  gem 'simplecov', require: false
20
- gem 'yard'
21
24
  end
data/Guardfile CHANGED
@@ -11,6 +11,7 @@ end
11
11
  guard 'spork', :test_unit => false do
12
12
  watch('Gemfile')
13
13
  watch('Gemfile.lock')
14
+ watch('lib/cupcakinator.rb')
14
15
  watch('spec/spec_helper.rb') { :rspec }
15
16
  end
16
17
 
@@ -24,6 +24,7 @@ module Cupcakinator
24
24
 
25
25
  unless @_i18n_initialized_for_cupcakinator
26
26
  locale_file = File.expand_path(File.join(File.dirname(__FILE__), '../config/locales.yml'))
27
+ I18n.enforce_available_locales = false
27
28
  I18n.load_path << locale_file
28
29
  @_i18n_initialized_for_cupcakinator = true
29
30
  end
@@ -27,6 +27,7 @@ module Cupcakinator
27
27
  # @option options.last [Hash] :dir The directory where the file can be found
28
28
  # @option options.last [Hash] :file The configuration filename
29
29
  # @option options.last [Hash] :method The method used to access the configuration options
30
+ # @option options.last [Hash] :root_key A key in the top level of the config file that will become the base
30
31
  # @example Default usage - Foo will load ./config/config.yml into a method named 'config'
31
32
  # class Foo
32
33
  # include cupcakinator
@@ -55,6 +56,17 @@ module Cupcakinator
55
56
  # >> puts Foo.new.config
56
57
  # { :foo => 'bar' }
57
58
  #
59
+ # @example with Rails - Foo will load config/foo_config.yml relative to Rails root into a method named 'config'
60
+ # beginning at the root_key based on the Rails.env
61
+ # class Foo
62
+ # include cupcakinator
63
+ # cupcakinate dir: Rails.root.join('config'), file: 'foo_config.yml', root_key: Rails.env
64
+ # end
65
+ # >> puts Foo.config
66
+ # { :foo => 'bar' }
67
+ # >> puts Foo.new.config
68
+ # { :foo => 'bar' }
69
+ #
58
70
  def cupcakinate(*options)
59
71
  if !options.empty?
60
72
  default_options = _cupcakinator_options
@@ -82,7 +94,12 @@ module Cupcakinator
82
94
  def load_cupcakinator_config
83
95
  filename = File.join(_cupcakinator_options[:dir], _cupcakinator_options[:file])
84
96
  yaml_config = YAML.load_file(filename)
85
- @cupcakinator_config = Cupcakinator::Config.new(yaml_config)
97
+ if _cupcakinator_options.has_key?(:root_key)
98
+ rk = _cupcakinator_options[:root_key]
99
+ @cupcakinator_config = Cupcakinator::Config.new(yaml_config[rk])
100
+ else
101
+ @cupcakinator_config = Cupcakinator::Config.new(yaml_config)
102
+ end
86
103
  rescue Errno::ENOENT
87
104
  raise Cupcakinator::ConfigFileNotFoundError.new(filename, _cupcakinator_options)
88
105
  rescue Psych::SyntaxError => e
@@ -1,3 +1,3 @@
1
1
  module Cupcakinator
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'
3
3
  end
@@ -97,6 +97,19 @@ describe Cupcakinator::Base do
97
97
  expect{ CupcakinatorBaseSpecBadFile.load_cupcakinator_config }.to raise_error(Cupcakinator::ConfigFileInvalidError)
98
98
  end
99
99
 
100
+ it 'should load the YAML anchored at root_key' do
101
+ class CupcakinatorBaseSpecRootKey
102
+ include Cupcakinator
103
+
104
+ cupcakinate dir: File.expand_path(File.join(File.dirname(__FILE__), '..')), file: 'el_config.yml', root_key: 'special'
105
+ end
106
+
107
+ subject = CupcakinatorBaseSpecRootKey.new
108
+ subject.config.has_key?(:special).should be_false
109
+ subject.config.bacon.chunky.should be_false
110
+ end
111
+
112
+
100
113
  end
101
114
 
102
115
 
@@ -1,2 +1,5 @@
1
1
  bacon:
2
- chunky: true
2
+ chunky: true
3
+ special:
4
+ bacon:
5
+ chunky: false
metadata CHANGED
@@ -1,40 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cupcakinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-20 00:00:00.000000000 Z
11
+ date: 2014-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 2.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.0.0
27
- description: ' Add config from YAML to any class '
27
+ description: " Add config from YAML to any class "
28
28
  email:
29
29
  - bcptaylor@gmail.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - .gitignore
35
- - .rspec
36
- - .ruby-version
37
- - .travis.yml
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".ruby-version"
37
+ - ".travis.yml"
38
38
  - Gemfile
39
39
  - Guardfile
40
40
  - LICENSE
@@ -63,17 +63,17 @@ require_paths:
63
63
  - lib
64
64
  required_ruby_version: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - '>='
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.0.14
76
+ rubygems_version: 2.2.0
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: Easy to add config from YAML to any class