yamload 0.2.1 → 0.3.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: bdad07d3d1abe5cb0312334e634972c359902f3b
4
- data.tar.gz: 30c31b88583c6c7de5e58dcefb5b129a2bd5ba5b
3
+ metadata.gz: b1408c57699fd2e66c43bb9b8bd8ca269ff8a2cd
4
+ data.tar.gz: 9328413c84beede3c64a92386033b00e8df036ad
5
5
  SHA512:
6
- metadata.gz: 814cadeb568d29740f1755183141009df9f39cd580b56365b252c4c4b318d1f58860bc28e92b7cd3148cb93509775fe24b899916f174764e2f60d62d49570c68
7
- data.tar.gz: ac31c23db46761243374967caf6f312d96df8ab717d75edea31a218bacfa63c229259623785c7f3cfe5b26d1d619073f10b7e3a637f78d1962a292a6a7399007
6
+ metadata.gz: cfcfb7e8493f4e59bc4657521e9dc46c36b4648c97715f787655019882ba319a7e496162c7fdf1b96e6ad8c87130abecb3cbbf9808ed05258f6c8db57b90e991
7
+ data.tar.gz: c494d7c4ca1b619f0955f3b2e2b81901e9a349d936aecb25e91340938c81fc1f57564bc945342bcb56a32c50acb3d10bb854cac01084e7d0f1e949b33b541420
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.4.0
data/.travis.yml CHANGED
@@ -1,10 +1,13 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
3
  - 2.1
5
4
  - 2.2
6
- script: "bundle exec rake coverage"
5
+ - 2.3.0
6
+ script: "bundle exec rake spec"
7
7
  notifications:
8
8
  email:
9
9
  - support@travellink.com.au
10
- flowdock: e69dcafad1fea15c6b8c76e9ced965af
10
+ flowdock:
11
+ secure: UInYCeoRfF7FEnNgW38nZDk3SXWfWN5rm+tKDWX/eWGIIUuynspe6A8776w+wG+9jSuzGt9J3WEIxxognkYiWmud96NYiKZIQDLx/6ql15A9jEvWwqnWbnaL4F368ujhwLo6V42Z6wRfTUqNeRQKki2WCw0NVmT6Y1bdTeNNy70=
12
+ sudo: false
13
+ cache: bundler
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## [Unreleased]
2
+
3
+ ## 0.3.0 (2017-07-31)
4
+
5
+ Removed:
6
+ - [TT-2967] Remove deprecated `Yamload::Loader#loaded_hash`
7
+ - [TT-2967] Remove schema validation
8
+
9
+ Changed:
10
+ - [TT-1790] Update ClassyHash to version 0.2.0
11
+
1
12
  ## 0.2.0 (2015-02-20)
2
13
 
3
14
  Features:
data/README.md CHANGED
@@ -8,7 +8,6 @@
8
8
 
9
9
  * YAML files loading
10
10
  * Recursive conversion to immutable objects
11
- * Schema validation
12
11
  * Default values
13
12
 
14
13
  ## Installation
@@ -50,20 +49,6 @@ loader.obj.attribute
50
49
  # => true
51
50
  ```
52
51
 
53
- Define a schema for the configuration
54
- ```ruby
55
- # Load config/test.yml
56
- loader = Yamload::Loader.new(:test)
57
- loader.schema = { 'test' => String }
58
- loader.valid?
59
- # => true
60
- loader.validate!
61
- # => nil
62
- loader.error
63
- # => nil
64
- ```
65
- See [Classy Hash](https://github.com/deseretbook/classy_hash) for documentation on schema definitions
66
-
67
52
  Define defaults
68
53
  ```ruby
69
54
  loader.defaults = { 'test' => true , 'coverage' => { 'minimum' => 0.95 } }
data/Rakefile CHANGED
@@ -4,9 +4,3 @@ require 'rspec/core/rake_task'
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task default: :spec
7
-
8
- desc 'Generate SimpleCov test coverage and open in your browser'
9
- task :coverage do
10
- ENV['COVERAGE'] = 'true'
11
- Rake::Task['spec'].invoke
12
- end
@@ -3,7 +3,6 @@ require 'ice_nine'
3
3
  require 'yamload/loading'
4
4
  require 'yamload/conversion'
5
5
  require 'yamload/defaults'
6
- require 'yamload/validation'
7
6
 
8
7
  module Yamload
9
8
  class Loader
@@ -15,12 +14,6 @@ module Yamload
15
14
  @loader.exist?
16
15
  end
17
16
 
18
- # <b>DEPRECATED:</b> Please use <tt>content</tt> instead.
19
- def loaded_hash
20
- warn '[DEPRECATION] `loaded_hash` is deprecated. Please use `content` instead.'
21
- content
22
- end
23
-
24
17
  def content
25
18
  @content ||= IceNine.deep_freeze(content_with_defaults)
26
19
  end
@@ -43,26 +36,6 @@ module Yamload
43
36
  defaults_merger.defaults
44
37
  end
45
38
 
46
- def schema=(schema)
47
- validator.schema = schema
48
- end
49
-
50
- def schema
51
- validator.schema
52
- end
53
-
54
- def valid?
55
- validation_result.valid?
56
- end
57
-
58
- def validate!
59
- fail SchemaError, validation_result.error unless validation_result.valid?
60
- end
61
-
62
- def error
63
- validation_result.error
64
- end
65
-
66
39
  private
67
40
 
68
41
  def content_with_defaults
@@ -72,15 +45,5 @@ module Yamload
72
45
  def defaults_merger
73
46
  @defaults_merger ||= Defaults::Hash.new
74
47
  end
75
-
76
- def validator
77
- @validator ||= Validation::Hash.new
78
- end
79
-
80
- def validation_result
81
- validator.validate(content)
82
- end
83
48
  end
84
-
85
- class SchemaError < StandardError; end
86
49
  end
@@ -1,3 +1,3 @@
1
1
  module Yamload
2
- VERSION = '0.2.1'
2
+ VERSION = '0.3.0'
3
3
  end
data/spec/loader_spec.rb CHANGED
@@ -53,15 +53,6 @@ describe Yamload::Loader do
53
53
  .to raise_error ArgumentError, "#{expected_content} is not a hash"
54
54
  }
55
55
  end
56
-
57
- context 'when a schema is defined' do
58
- let(:schema) { { test: true } }
59
- before { loader.schema = schema }
60
- specify {
61
- expect { loader.valid? }
62
- .to raise_error ArgumentError, "#{expected_content} is not a hash"
63
- }
64
- end
65
56
  end
66
57
 
67
58
  context 'with a file defining a string' do
@@ -79,15 +70,6 @@ describe Yamload::Loader do
79
70
  .to raise_error ArgumentError, "#{expected_content} is not a hash"
80
71
  }
81
72
  end
82
-
83
- context 'when a schema is defined' do
84
- let(:schema) { { test: true } }
85
- before { loader.schema = schema }
86
- specify {
87
- expect { loader.valid? }
88
- .to raise_error ArgumentError, "#{expected_content} is not a hash"
89
- }
90
- end
91
73
  end
92
74
 
93
75
  context 'with a file defining a hash' do
@@ -130,10 +112,6 @@ describe Yamload::Loader do
130
112
  }
131
113
  }
132
114
 
133
- specify 'deprecated `loaded_hash` still works' do
134
- expect(loader.loaded_hash).to eq loader.content
135
- end
136
-
137
115
  specify { expect(content).to eq expected_content }
138
116
 
139
117
  let(:content_obj) { loader.obj }
@@ -163,7 +141,7 @@ describe Yamload::Loader do
163
141
  let(:new_user) { double('new user') }
164
142
  specify 'the hash should be immutable' do
165
143
  expect { content['users'] << new_user }
166
- .to raise_error RuntimeError, "can't modify frozen Array"
144
+ .to raise_error RuntimeError, /can't modify frozen Array/i
167
145
  expect(content['users']).not_to include new_user
168
146
  end
169
147
  end
@@ -172,81 +150,11 @@ describe Yamload::Loader do
172
150
  let(:new_user) { double('new user') }
173
151
  specify 'the object should be immutable' do
174
152
  expect { content_obj.users << new_user }
175
- .to raise_error RuntimeError, "can't modify frozen Array"
153
+ .to raise_error RuntimeError, /can't modify frozen Array/i
176
154
  expect(content_obj.users).not_to include new_user
177
155
  end
178
156
  end
179
157
 
180
- context 'when no schema is defined' do
181
- specify { expect(loader).to be_valid }
182
- specify { expect(loader.error).to be_nil }
183
- specify { expect { loader.validate! }.not_to raise_error }
184
- end
185
-
186
- context 'when the schema is not a hash' do
187
- let(:schema) { 'not a hash' }
188
- specify {
189
- expect { loader.schema = schema }
190
- .to raise_error ArgumentError, "#{schema} is not a hash"
191
- }
192
- end
193
-
194
- context 'when a schema is defined' do
195
- let(:schema) {
196
- {
197
- 'test' => TrueClass,
198
- 'users' => [
199
- [
200
- {
201
- 'first_name' => String,
202
- 'last_name' => String,
203
- 'address' => {
204
- 'address_line_1' => String,
205
- 'address_line_2' => [:optional, String, NilClass],
206
- 'city' => String,
207
- 'state' => String,
208
- 'post_code' => Integer,
209
- 'country' => String
210
- },
211
- 'email' => String
212
- }
213
- ]
214
- ],
215
- 'settings' => {
216
- 'remote_access' => TrueClass
217
- }
218
- }
219
- }
220
-
221
- before do
222
- loader.schema = schema
223
- end
224
-
225
- specify { expect(loader.schema).to eq schema }
226
- specify { expect(loader).to be_valid }
227
- specify { expect(loader.error).to be_nil }
228
- specify { expect { loader.validate! }.not_to raise_error }
229
-
230
- context 'when the schema is not matched' do
231
- let(:schema) {
232
- {
233
- 'users' => [
234
- [
235
- {
236
- 'expected_attribute' => String
237
- }
238
- ]
239
- ]
240
- }
241
- }
242
-
243
- let(:expected_error) { '"users"[0]["expected_attribute"] is not present' }
244
- specify { expect(loader).not_to be_valid }
245
- specify { expect(loader.error).to eq expected_error }
246
- specify { expect { loader.validate! }.to raise_error Yamload::SchemaError, expected_error }
247
- end
248
- end
249
-
250
158
  context 'when the defaults object is not a hash' do
251
159
  let(:defaults) { 'not a hash' }
252
160
  specify {
data/spec/spec_helper.rb CHANGED
@@ -1,31 +1,6 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
 
3
- MINIMUM_COVERAGE = 95
4
-
5
- if ENV['COVERAGE']
6
- require 'simplecov'
7
- require 'simplecov-rcov'
8
- require 'coveralls'
9
- Coveralls.wear!
10
-
11
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
12
- SimpleCov::Formatter::RcovFormatter,
13
- Coveralls::SimpleCov::Formatter
14
- ]
15
- SimpleCov.start do
16
- add_filter '/vendor/'
17
- add_filter '/spec/'
18
- add_group 'lib', 'lib'
19
- end
20
- SimpleCov.at_exit do
21
- SimpleCov.result.format!
22
- percent = SimpleCov.result.covered_percent
23
- unless percent >= MINIMUM_COVERAGE
24
- puts "Coverage must be above #{MINIMUM_COVERAGE}%. It is #{format('%.2f', percent)}%"
25
- Kernel.exit(1)
26
- end
27
- end
28
- end
3
+ require 'support/coverage_loader'
29
4
 
30
5
  require 'yamload'
31
6
 
@@ -0,0 +1,4 @@
1
+ require 'simplecov-rcov'
2
+ require 'coveralls'
3
+ require 'coverage/kit'
4
+ Coverage::Kit.setup(minimum_coverage: 100)
data/yamload.gemspec CHANGED
@@ -22,13 +22,13 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency 'anima', '~> 0.2'
24
24
  spec.add_dependency 'facets', '~> 3.0'
25
- spec.add_dependency 'classy_hash', '~> 0.1'
26
25
 
27
26
  spec.add_development_dependency 'bundler', '~> 1.7'
28
27
  spec.add_development_dependency 'rake', '~> 10.0'
29
28
  spec.add_development_dependency 'rspec', '~> 3.2'
30
- spec.add_development_dependency 'simplecov', '~> 0.9'
29
+ spec.add_development_dependency 'coverage-kit'
31
30
  spec.add_development_dependency 'simplecov-rcov', '~> 0.2'
32
31
  spec.add_development_dependency 'coveralls'
33
32
  spec.add_development_dependency 'rubocop'
33
+ spec.add_development_dependency 'travis'
34
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yamload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Berardi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-27 00:00:00.000000000 Z
12
+ date: 2017-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: anima
@@ -39,20 +39,6 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '3.0'
42
- - !ruby/object:Gem::Dependency
43
- name: classy_hash
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '0.1'
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '0.1'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: bundler
58
44
  requirement: !ruby/object:Gem::Requirement
@@ -96,19 +82,19 @@ dependencies:
96
82
  - !ruby/object:Gem::Version
97
83
  version: '3.2'
98
84
  - !ruby/object:Gem::Dependency
99
- name: simplecov
85
+ name: coverage-kit
100
86
  requirement: !ruby/object:Gem::Requirement
101
87
  requirements:
102
- - - "~>"
88
+ - - ">="
103
89
  - !ruby/object:Gem::Version
104
- version: '0.9'
90
+ version: '0'
105
91
  type: :development
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
- - - "~>"
95
+ - - ">="
110
96
  - !ruby/object:Gem::Version
111
- version: '0.9'
97
+ version: '0'
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: simplecov-rcov
114
100
  requirement: !ruby/object:Gem::Requirement
@@ -151,6 +137,20 @@ dependencies:
151
137
  - - ">="
152
138
  - !ruby/object:Gem::Version
153
139
  version: '0'
140
+ - !ruby/object:Gem::Dependency
141
+ name: travis
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ type: :development
148
+ prerelease: false
149
+ version_requirements: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
154
  description: YAML files loader with validation
155
155
  email:
156
156
  - berardialessandro@gmail.com
@@ -179,9 +179,6 @@ files:
179
179
  - lib/yamload/loader.rb
180
180
  - lib/yamload/loading.rb
181
181
  - lib/yamload/loading/yaml.rb
182
- - lib/yamload/validation.rb
183
- - lib/yamload/validation/hash.rb
184
- - lib/yamload/validation/result.rb
185
182
  - lib/yamload/version.rb
186
183
  - spec/conversion_spec.rb
187
184
  - spec/fixtures/array.yml
@@ -191,6 +188,7 @@ files:
191
188
  - spec/fixtures/test.yml
192
189
  - spec/loader_spec.rb
193
190
  - spec/spec_helper.rb
191
+ - spec/support/coverage_loader.rb
194
192
  - yamload.gemspec
195
193
  homepage: ''
196
194
  licenses:
@@ -212,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
210
  version: '0'
213
211
  requirements: []
214
212
  rubyforge_project:
215
- rubygems_version: 2.4.5
213
+ rubygems_version: 2.6.8
216
214
  signing_key:
217
215
  specification_version: 4
218
216
  summary: YAML files loader
@@ -225,3 +223,4 @@ test_files:
225
223
  - spec/fixtures/test.yml
226
224
  - spec/loader_spec.rb
227
225
  - spec/spec_helper.rb
226
+ - spec/support/coverage_loader.rb
@@ -1,7 +0,0 @@
1
- module Yamload
2
- module Validation
3
- end
4
- end
5
-
6
- require 'yamload/validation/hash'
7
- require 'yamload/validation/result'
@@ -1,28 +0,0 @@
1
- require 'classy_hash'
2
-
3
- module Yamload
4
- module Validation
5
- class Hash
6
- attr_reader :schema
7
-
8
- def initialize(schema = nil)
9
- self.schema = schema
10
- end
11
-
12
- def schema=(schema)
13
- unless schema.is_a?(::Hash) || schema.nil?
14
- fail ArgumentError, "#{schema} is not a hash"
15
- end
16
- @schema = schema
17
- end
18
-
19
- def validate(hash)
20
- fail ArgumentError, "#{hash} is not a hash" unless hash.is_a?(::Hash)
21
- ClassyHash.validate(hash, @schema) unless @schema.nil?
22
- Result.new(true)
23
- rescue RuntimeError => e
24
- Result.new(false, e.message)
25
- end
26
- end
27
- end
28
- end
@@ -1,16 +0,0 @@
1
- module Yamload
2
- module Validation
3
- class Result
4
- attr_reader :error
5
-
6
- def initialize(valid, error = nil)
7
- @valid = valid
8
- @error = error
9
- end
10
-
11
- def valid?
12
- @valid
13
- end
14
- end
15
- end
16
- end