cupcakinator 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85d96fd34cbf9876f34a2936895f0bd51159c6cb
4
+ data.tar.gz: dc7070c4bffd98a15c4fe4a2fbd44eee78e66b50
5
+ SHA512:
6
+ metadata.gz: 60303713ed114c3004178f42c63cb9da4e1d9dae743eff5db7573650fac2700031ace5d7c13780de2d93e96eea57fc41ba0203f1e43fb41eccfa29c2d477537d
7
+ data.tar.gz: 42935165577f66ee5ad10125a5becb27627480979789b5b0939f3d6a7123198629e386a760f80f4caaac21b93ee857e3f92d68372b337697c8b40064a36e8eaa
@@ -1 +1 @@
1
- 1.9.3-p392
1
+ 2.0.0-p353
@@ -2,4 +2,5 @@ language: ruby
2
2
  rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
+ - "2.1.0"
5
6
  script: bundle exec rspec spec
data/Gemfile CHANGED
@@ -2,5 +2,20 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'simplecov', :require => false, :group => :test
6
- gem 'json', '~> 1.7.7'
5
+ gem 'bundler', '~> 1.3'
6
+ gem 'hashie'
7
+ gem 'i18n'
8
+ gem 'json', '~> 1.8'
9
+
10
+ group :development, :test do
11
+ gem 'debugger'
12
+ gem 'guard'
13
+ gem 'guard-rspec'
14
+ gem 'guard-spork'
15
+ gem 'rake'
16
+ gem 'rb-readline'
17
+ gem 'redcarpet'
18
+ gem 'rspec'
19
+ gem 'simplecov', require: false
20
+ gem 'yard'
21
+ end
data/Guardfile CHANGED
@@ -1,7 +1,7 @@
1
1
  # A sample Guardfile
2
2
  # More info at https://github.com/guard/guard#readme
3
3
 
4
- guard 'rspec', :all_after_pass => true, :focus_on_failed => true, :all_on_start => true, :cli => "--drb --debug" do
4
+ guard 'rspec', all_after_pass: true, failed_mode: :focus, all_on_start: true, cmd: 'rspec spec --drb --debugger' do
5
5
  watch(%r{^spec/.+_spec\.rb$})
6
6
  watch(%r{^lib/(.+)\.rb$}){ |m| "spec/lib/#{m[1]}_spec.rb" }
7
7
  watch('spec/spec_helper.rb'){ "spec" }
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # cupcakinator [![Build Status](https://travis-ci.org/rubyisbeautiful/cupcakinator.png)](https://travis-ci.org/rubyisbeautiful/cupcakinator)
1
+ # cupcakinator [![Build Status](https://travis-ci.org/rubyisbeautiful/cupcakinator.png)](https://travis-ci.org/rubyisbeautiful/cupcakinator) [![Code Climate](https://codeclimate.com/github/rubyisbeautiful/cupcakinator.png)](https://codeclimate.com/github/rubyisbeautiful/cupcakinator)
2
2
 
3
3
  ## Description
4
4
 
@@ -0,0 +1,12 @@
1
+ en:
2
+ error:
3
+ deprecation:
4
+ include_base: "deprecated: don't include Cupcakinator::Base directly"
5
+ config_not_found: "Can't find Cupcakinator configured config file '%{filename}'\nCupcakinator options:\n%{options}"
6
+ config_invalid: "Cupcakinator configure config file '%{filename}' invalid\nOriginal error: %{message}"
7
+ es:
8
+ error:
9
+ deprecation:
10
+ include_base: 'desaprobado: no incluya directamente Cupcakinator::Base'
11
+ config_not_found: "No se encuentra el archivo de config Cupcakinator '%{filename}'\nopciones de Cupcakinator: \n%{options}"
12
+ config_invalid: "el archivo de config Cupcakinator '%{filename}' es invalido\nError original: %{message}"
@@ -17,20 +17,5 @@ Gem::Specification.new do |gem|
17
17
  gem.version = Cupcakinator::VERSION
18
18
  gem.license = 'MIT'
19
19
 
20
- gem.add_runtime_dependency 'hashie'
21
-
22
- gem.add_development_dependency "bundler", "~> 1.3"
23
- gem.add_development_dependency "debugger"
24
- gem.add_development_dependency "guard"
25
- gem.add_development_dependency "guard-rspec"
26
- gem.add_development_dependency "guard-spork"
27
- gem.add_development_dependency 'rake'
28
- gem.add_development_dependency 'rb-readline'
29
- gem.add_development_dependency 'rspec'
30
- gem.add_development_dependency "yard"
31
- gem.add_development_dependency "redcarpet"
32
-
33
-
34
-
35
20
 
36
21
  end
@@ -1,3 +1,4 @@
1
+ require 'i18n'
1
2
  require 'cupcakinator/version'
2
3
  require 'cupcakinator/base'
3
4
  require 'cupcakinator/config'
@@ -21,9 +22,14 @@ require 'cupcakinator/errors'
21
22
  # {"flavor"=>["chicken", "pork"]}
22
23
  module Cupcakinator
23
24
 
25
+ unless @_i18n_initialized_for_cupcakinator
26
+ locale_file = File.expand_path(File.join(File.dirname(__FILE__), '../config/locales.yml'))
27
+ I18n.load_path << locale_file
28
+ @_i18n_initialized_for_cupcakinator = true
29
+ end
30
+
24
31
  def self.included(other)
25
32
  other.extend Cupcakinator::Base
26
33
  end
27
34
 
28
-
29
35
  end
@@ -6,9 +6,7 @@ module Cupcakinator
6
6
 
7
7
 
8
8
  def self.included(other)
9
- raise "deprecated: don't include Cupcakinator::Base directly"
10
- #puts "included (via Base) in #{other}"
11
- #other.extend ClassMethods
9
+ raise I18n.t('error.deprecation.include_base')
12
10
  end
13
11
 
14
12
 
@@ -75,15 +73,20 @@ module Cupcakinator
75
73
 
76
74
  def _cupcakinator_config
77
75
  if @cupcakinator_config.nil?
78
- filename = File.join(_cupcakinator_options[:dir], _cupcakinator_options[:file])
79
- yaml_config = YAML.load_file(filename)
80
- @cupcakinator_config = Cupcakinator::Config.new(yaml_config)
76
+ load_cupcakinator_config
81
77
  end
82
78
  @cupcakinator_config
79
+ end
80
+
81
+
82
+ def load_cupcakinator_config
83
+ filename = File.join(_cupcakinator_options[:dir], _cupcakinator_options[:file])
84
+ yaml_config = YAML.load_file(filename)
85
+ @cupcakinator_config = Cupcakinator::Config.new(yaml_config)
83
86
  rescue Errno::ENOENT
84
- raise Cupcakinator::ConfigFileNotFoundError.new("Can't find Cupcakinator configured config file #{filename}\nCupcakinator options:\n#{_cupcakinator_options}")
87
+ raise Cupcakinator::ConfigFileNotFoundError.new(filename, _cupcakinator_options)
85
88
  rescue Psych::SyntaxError => e
86
- raise Cupcakinator::ConfigFileInvalidError.new("Cupcakinator configure config file #{filename} invalid\nOriginal error: #{e.message}")
89
+ raise Cupcakinator::ConfigFileInvalidError.new(filename, e.message)
87
90
  end
88
91
 
89
92
 
@@ -1,6 +1,20 @@
1
1
  module Cupcakinator
2
2
 
3
- class ConfigFileNotFoundError < StandardError; end
4
- class ConfigFileInvalidError < StandardError; end
3
+ class ConfigFileNotFoundError < StandardError
4
+
5
+ def initialize(filename, options)
6
+ super I18n.t('error.config_not_found', filename: filename, options: options)
7
+ end
8
+
9
+ end
10
+
11
+
12
+ class ConfigFileInvalidError < StandardError
13
+
14
+ def initialize(filename, message)
15
+ super I18n.t('error.config_invalid', filename: filename, message: message)
16
+ end
17
+
18
+ end
5
19
 
6
20
  end
@@ -1,3 +1,3 @@
1
1
  module Cupcakinator
2
- VERSION = "0.0.4"
2
+ VERSION = '1.0.0'
3
3
  end
@@ -30,7 +30,7 @@ describe Cupcakinator::Base do
30
30
  end
31
31
 
32
32
 
33
- it "should call _cupcakinator_options" do
33
+ it 'should call _cupcakinator_options' do
34
34
  @klass.should_receive(:_cupcakinator_options).at_least(1).and_return({})
35
35
 
36
36
  @klass.cupcakinate method: 'config'
@@ -61,6 +61,42 @@ describe Cupcakinator::Base do
61
61
  CupcakinatorBaseSpecFoo._cupcakinator_config.bacon.class.should eq(Cupcakinator::Config)
62
62
  end
63
63
 
64
+ it 'should not load more than once' do
65
+ h = double
66
+ CupcakinatorBaseSpecFoo.instance_variable_set('@cupcakinator_config', h)
67
+ CupcakinatorBaseSpecFoo._cupcakinator_config.should == h
68
+ CupcakinatorBaseSpecFoo.should_not_receive(:load_cupcakinator_config)
69
+ end
70
+
71
+ end
72
+
73
+
74
+ describe 'load_cupcakinator_config' do
75
+ it 'should raise ConfigFileNotFoundError if config file is not found' do
76
+ class CupcakinatorBaseSpecNoExist
77
+ include Cupcakinator
78
+
79
+ cupcakinate file: 'no_exist.yml'
80
+ end
81
+ YAML.stub(:load_file).with('./no_exist.yml').and_raise(Errno::ENOENT)
82
+ YAML.stub(:load_file).with(anything).and_call_original
83
+
84
+ expect{ CupcakinatorBaseSpecNoExist.load_cupcakinator_config }.to raise_error(Cupcakinator::ConfigFileNotFoundError)
85
+ end
86
+
87
+ it 'should raise ConfigFileInvalidError if config file is not found' do
88
+ dummy = double.as_null_object
89
+
90
+ class CupcakinatorBaseSpecBadFile
91
+ include Cupcakinator
92
+
93
+ cupcakinate file: 'bad_file.yml'
94
+ end
95
+ YAML.stub(:load_file).with('./bad_file.yml').and_raise(Psych::SyntaxError.new(dummy,dummy,dummy,dummy,dummy,dummy))
96
+
97
+ expect{ CupcakinatorBaseSpecBadFile.load_cupcakinator_config }.to raise_error(Cupcakinator::ConfigFileInvalidError)
98
+ end
99
+
64
100
  end
65
101
 
66
102
 
@@ -73,7 +109,7 @@ describe Cupcakinator::Base do
73
109
  end
74
110
 
75
111
  it 'should not raise if NoMethodError when using the configured cupcakinator method' do
76
- expect { subject.el_config }.to_not raise_error(NoMethodError)
112
+ expect { subject.el_config }.not_to raise_error
77
113
  end
78
114
 
79
115
  it 'should delegeate to _cupcakinator_config when using the configured cupcakinator method' do
@@ -98,7 +134,7 @@ describe Cupcakinator::Base do
98
134
  end
99
135
 
100
136
  it 'should not raise if NoMethodError when using the configured cupcakinator method' do
101
- expect { subject.el_config }.to_not raise_error(NoMethodError)
137
+ expect { subject.el_config }.not_to raise_error
102
138
  end
103
139
 
104
140
  it 'should delegeate to _cupcakinator_config when using the configured cupcakinator method' do
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cupcakinator::ConfigFileNotFoundError do
4
+
5
+ it 'should call I18n with args filename and options' do
6
+ I18n.should_receive(:t).with(an_instance_of(String), hash_including(:filename, :options))
7
+ Cupcakinator::ConfigFileNotFoundError.new('foo', 'bar')
8
+ end
9
+
10
+ end
11
+
12
+
13
+ describe Cupcakinator::ConfigFileInvalidError do
14
+
15
+ it 'should call I18n with args filename and message' do
16
+ I18n.should_receive(:t).with(an_instance_of(String), hash_including(:filename, :message))
17
+ Cupcakinator::ConfigFileInvalidError.new('foo', 'bar')
18
+ end
19
+
20
+ end
@@ -40,4 +40,12 @@ describe Cupcakinator do
40
40
 
41
41
  end
42
42
 
43
+
44
+ context 'localization' do
45
+
46
+ it 'should have loaded the locales file' do
47
+ I18n.t('error.deprecation.include_base').should =~ /don't include Cupcakinator::Base directly/
48
+ end
49
+ end
50
+
43
51
  end
@@ -1,6 +1,9 @@
1
1
  require 'rubygems'
2
2
  require 'spork'
3
3
 
4
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
+ require 'cupcakinator'
6
+
4
7
  Spork.prefork do
5
8
  require 'simplecov'
6
9
  SimpleCov.start do
@@ -8,9 +11,6 @@ Spork.prefork do
8
11
  end
9
12
 
10
13
  require 'rspec'
11
-
12
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
13
- require 'cupcakinator'
14
14
  end
15
15
 
16
16
  Spork.each_run do
metadata CHANGED
@@ -1,196 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cupcakinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bryan Taylor
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-24 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: hashie
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: bundler
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '1.3'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '1.3'
46
- - !ruby/object:Gem::Dependency
47
- name: debugger
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: guard
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: guard-rspec
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: guard-spork
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: rake
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: rb-readline
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
140
- - !ruby/object:Gem::Version
141
- version: '0'
142
- - !ruby/object:Gem::Dependency
143
- name: rspec
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ! '>='
148
- - !ruby/object:Gem::Version
149
- version: '0'
150
- type: :development
151
- prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
- requirements:
155
- - - ! '>='
156
- - !ruby/object:Gem::Version
157
- version: '0'
158
- - !ruby/object:Gem::Dependency
159
- name: yard
160
- requirement: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
- requirements:
171
- - - ! '>='
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
- - !ruby/object:Gem::Dependency
175
- name: redcarpet
176
- requirement: !ruby/object:Gem::Requirement
177
- none: false
178
- requirements:
179
- - - ! '>='
180
- - !ruby/object:Gem::Version
181
- version: '0'
182
- type: :development
183
- prerelease: false
184
- version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
- requirements:
187
- - - ! '>='
188
- - !ruby/object:Gem::Version
189
- version: '0'
190
- description: ! ' Add config from YAML to any class '
11
+ date: 2014-01-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ' Add config from YAML to any class '
191
14
  email:
192
- - !binary |-
193
- YmNwdGF5bG9yQGdtYWlsLmNvbQ==
15
+ - bcptaylor@gmail.com
194
16
  executables: []
195
17
  extensions: []
196
18
  extra_rdoc_files: []
@@ -204,6 +26,7 @@ files:
204
26
  - LICENSE
205
27
  - README.md
206
28
  - Rakefile
29
+ - config/locales.yml
207
30
  - cupcakinator.gemspec
208
31
  - lib/cupcakinator.rb
209
32
  - lib/cupcakinator/base.rb
@@ -212,36 +35,37 @@ files:
212
35
  - lib/cupcakinator/options.rb
213
36
  - lib/cupcakinator/version.rb
214
37
  - spec/cupcakinator/base_spec.rb
38
+ - spec/cupcakinator/errors_spec.rb
215
39
  - spec/cupcakinator_spec.rb
216
40
  - spec/el_config.yml
217
41
  - spec/spec_helper.rb
218
42
  homepage: http://github.com/rubyisbeautiful/cupcakinator
219
43
  licenses:
220
44
  - MIT
45
+ metadata: {}
221
46
  post_install_message:
222
47
  rdoc_options: []
223
48
  require_paths:
224
49
  - lib
225
50
  required_ruby_version: !ruby/object:Gem::Requirement
226
- none: false
227
51
  requirements:
228
- - - ! '>='
52
+ - - '>='
229
53
  - !ruby/object:Gem::Version
230
54
  version: '0'
231
55
  required_rubygems_version: !ruby/object:Gem::Requirement
232
- none: false
233
56
  requirements:
234
- - - ! '>='
57
+ - - '>='
235
58
  - !ruby/object:Gem::Version
236
59
  version: '0'
237
60
  requirements: []
238
61
  rubyforge_project:
239
- rubygems_version: 1.8.23
62
+ rubygems_version: 2.0.14
240
63
  signing_key:
241
- specification_version: 3
64
+ specification_version: 4
242
65
  summary: Easy to add config from YAML to any class
243
66
  test_files:
244
67
  - spec/cupcakinator/base_spec.rb
68
+ - spec/cupcakinator/errors_spec.rb
245
69
  - spec/cupcakinator_spec.rb
246
70
  - spec/el_config.yml
247
71
  - spec/spec_helper.rb