hashie 3.6.0 → 4.0.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 +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +95 -7
- data/UPGRADING.md +78 -2
- data/hashie.gemspec +2 -1
- data/lib/hashie.rb +20 -19
- data/lib/hashie/dash.rb +2 -1
- data/lib/hashie/extensions/active_support/core_ext/hash.rb +14 -0
- data/lib/hashie/extensions/coercion.rb +23 -16
- data/lib/hashie/extensions/dash/indifferent_access.rb +20 -1
- data/lib/hashie/extensions/dash/property_translation.rb +5 -2
- data/lib/hashie/extensions/deep_fetch.rb +4 -2
- data/lib/hashie/extensions/deep_find.rb +12 -3
- data/lib/hashie/extensions/deep_locate.rb +22 -7
- data/lib/hashie/extensions/indifferent_access.rb +1 -3
- data/lib/hashie/extensions/key_conflict_warning.rb +55 -0
- data/lib/hashie/extensions/mash/define_accessors.rb +90 -0
- data/lib/hashie/extensions/mash/keep_original_keys.rb +2 -1
- data/lib/hashie/extensions/mash/safe_assignment.rb +3 -1
- data/lib/hashie/extensions/method_access.rb +5 -2
- data/lib/hashie/extensions/parsers/yaml_erb_parser.rb +9 -4
- data/lib/hashie/extensions/strict_key_access.rb +8 -4
- data/lib/hashie/hash.rb +16 -9
- data/lib/hashie/mash.rb +99 -43
- data/lib/hashie/railtie.rb +7 -0
- data/lib/hashie/rash.rb +1 -1
- data/lib/hashie/version.rb +1 -1
- data/spec/hashie/dash_spec.rb +18 -8
- data/spec/hashie/extensions/coercion_spec.rb +17 -8
- data/spec/hashie/extensions/deep_find_spec.rb +12 -6
- data/spec/hashie/extensions/deep_locate_spec.rb +2 -1
- data/spec/hashie/extensions/deep_merge_spec.rb +6 -2
- data/spec/hashie/extensions/ignore_undeclared_spec.rb +2 -1
- data/spec/hashie/extensions/mash/define_accessors_spec.rb +90 -0
- data/spec/hashie/extensions/method_access_spec.rb +8 -1
- data/spec/hashie/extensions/strict_key_access_spec.rb +9 -10
- data/spec/hashie/extensions/symbolize_keys_spec.rb +3 -1
- data/spec/hashie/hash_spec.rb +45 -6
- data/spec/hashie/mash_spec.rb +314 -8
- data/spec/hashie/trash_spec.rb +9 -3
- data/spec/integration/elasticsearch/integration_spec.rb +3 -2
- data/spec/integration/rails/app.rb +5 -12
- data/spec/integration/rails/integration_spec.rb +22 -1
- metadata +8 -4
data/spec/hashie/trash_spec.rb
CHANGED
@@ -188,7 +188,9 @@ describe Hashie::Trash do
|
|
188
188
|
end
|
189
189
|
|
190
190
|
it 'transforms the value when given in constructor' do
|
191
|
-
expect(
|
191
|
+
expect(
|
192
|
+
TrashLambdaTestWithProperties.new(first_name: 'Michael').first_name
|
193
|
+
).to eq 'Michael'.reverse
|
192
194
|
end
|
193
195
|
|
194
196
|
context 'when :from option is given' do
|
@@ -297,7 +299,9 @@ describe Hashie::Trash do
|
|
297
299
|
property :copy_of_id, from: :id, required: true, message: 'must be set'
|
298
300
|
end
|
299
301
|
|
300
|
-
expect { with_required.new }.to raise_error(
|
302
|
+
expect { with_required.new }.to raise_error(
|
303
|
+
ArgumentError, "The property 'copy_of_id' must be set"
|
304
|
+
)
|
301
305
|
end
|
302
306
|
|
303
307
|
it 'does not set properties that do not exist' do
|
@@ -308,7 +312,9 @@ describe Hashie::Trash do
|
|
308
312
|
subject = from_non_property.new(value: 0)
|
309
313
|
|
310
314
|
expect(subject).not_to respond_to(:value)
|
311
|
-
expect { subject[:value] }.to raise_error(
|
315
|
+
expect { subject[:value] }.to raise_error(
|
316
|
+
NoMethodError, "The property 'value' is not defined for ."
|
317
|
+
)
|
312
318
|
expect(subject.to_h[:value]).to eq(nil)
|
313
319
|
expect(subject.copy_of_value).to eq(0)
|
314
320
|
end
|
@@ -23,7 +23,7 @@ RSpec.describe 'elaasticsearch-model' do
|
|
23
23
|
object = MyModel.new
|
24
24
|
stub_elasticsearch_client
|
25
25
|
|
26
|
-
expect { object.__elasticsearch__.index_document }.to raise_error(
|
26
|
+
expect { object.__elasticsearch__.index_document }.to raise_error(NameError)
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'does not raise an error when the model has an id' do
|
@@ -35,6 +35,7 @@ RSpec.describe 'elaasticsearch-model' do
|
|
35
35
|
|
36
36
|
def stub_elasticsearch_client
|
37
37
|
response = double('Response', body: '{}')
|
38
|
-
allow_any_instance_of(Elasticsearch::Transport::Client).to
|
38
|
+
allow_any_instance_of(Elasticsearch::Transport::Client).to\
|
39
|
+
receive(:perform_request) { response }
|
39
40
|
end
|
40
41
|
end
|
@@ -14,7 +14,7 @@ module RailsApp
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
PAGE = <<-HTML.freeze
|
18
18
|
<!DOCTYPE html>
|
19
19
|
<html>
|
20
20
|
<head>
|
@@ -22,24 +22,17 @@ LAYOUT = <<-HTML.freeze
|
|
22
22
|
<%= csrf_meta_tags %>
|
23
23
|
</head>
|
24
24
|
<body>
|
25
|
-
|
25
|
+
<h1>Hello, world!</h1>
|
26
26
|
</body>
|
27
27
|
</html>
|
28
28
|
HTML
|
29
29
|
|
30
|
-
INDEX = '<h1>Hello, world!</h1>'.freeze
|
31
|
-
|
32
30
|
class ApplicationController < ActionController::Base
|
33
31
|
include Rails.application.routes.url_helpers
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
'layouts/application.html.erb' => LAYOUT,
|
39
|
-
'application/index.html.erb' => INDEX
|
40
|
-
)]
|
41
|
-
|
42
|
-
def index; end
|
33
|
+
def index
|
34
|
+
render inline: PAGE
|
35
|
+
end
|
43
36
|
end
|
44
37
|
|
45
38
|
Bundler.require(:default, Rails.env)
|
@@ -14,11 +14,32 @@ RSpec.describe 'rails', type: :request do
|
|
14
14
|
$stdout = original_stdout
|
15
15
|
end
|
16
16
|
|
17
|
-
it 'does not log anything to STDOUT when initializing
|
17
|
+
it 'does not log anything to STDOUT when initializing' do
|
18
18
|
expect(stdout.string).to eq('')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'sets the Hashie logger to the Rails logger' do
|
19
22
|
expect(Hashie.logger).to eq(Rails.logger)
|
20
23
|
end
|
21
24
|
|
25
|
+
context '#except' do
|
26
|
+
subject { Hashie::Mash.new(x: 1, y: 2) }
|
27
|
+
|
28
|
+
it 'returns an instance of the class it was called on' do
|
29
|
+
class HashieKlass < Hashie::Mash; end
|
30
|
+
hashie_klass = HashieKlass.new(subject)
|
31
|
+
expect(hashie_klass.except('x')).to be_a HashieKlass
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'works with string keys' do
|
35
|
+
expect(subject.except('x')).to eq Hashie::Mash.new(y: 2)
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'works with symbol keys' do
|
39
|
+
expect(subject.except(:x)).to eq Hashie::Mash.new(y: 2)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
22
43
|
it 'works' do
|
23
44
|
get '/'
|
24
45
|
assert_select 'h1', 'Hello, world!'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/hashie/array.rb
|
74
74
|
- lib/hashie/clash.rb
|
75
75
|
- lib/hashie/dash.rb
|
76
|
+
- lib/hashie/extensions/active_support/core_ext/hash.rb
|
76
77
|
- lib/hashie/extensions/array/pretty_inspect.rb
|
77
78
|
- lib/hashie/extensions/coercion.rb
|
78
79
|
- lib/hashie/extensions/dash/coercion.rb
|
@@ -84,7 +85,9 @@ files:
|
|
84
85
|
- lib/hashie/extensions/deep_merge.rb
|
85
86
|
- lib/hashie/extensions/ignore_undeclared.rb
|
86
87
|
- lib/hashie/extensions/indifferent_access.rb
|
88
|
+
- lib/hashie/extensions/key_conflict_warning.rb
|
87
89
|
- lib/hashie/extensions/key_conversion.rb
|
90
|
+
- lib/hashie/extensions/mash/define_accessors.rb
|
88
91
|
- lib/hashie/extensions/mash/keep_original_keys.rb
|
89
92
|
- lib/hashie/extensions/mash/safe_assignment.rb
|
90
93
|
- lib/hashie/extensions/mash/symbolize_keys.rb
|
@@ -120,6 +123,7 @@ files:
|
|
120
123
|
- spec/hashie/extensions/indifferent_access_spec.rb
|
121
124
|
- spec/hashie/extensions/indifferent_access_with_rails_hwia_spec.rb
|
122
125
|
- spec/hashie/extensions/key_conversion_spec.rb
|
126
|
+
- spec/hashie/extensions/mash/define_accessors_spec.rb
|
123
127
|
- spec/hashie/extensions/mash/keep_original_keys_spec.rb
|
124
128
|
- spec/hashie/extensions/mash/safe_assignment_spec.rb
|
125
129
|
- spec/hashie/extensions/mash/symbolize_keys_spec.rb
|
@@ -169,8 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
173
|
- !ruby/object:Gem::Version
|
170
174
|
version: '0'
|
171
175
|
requirements: []
|
172
|
-
|
173
|
-
rubygems_version: 2.7.6
|
176
|
+
rubygems_version: 3.0.4
|
174
177
|
signing_key:
|
175
178
|
specification_version: 4
|
176
179
|
summary: Your friendly neighborhood hash library.
|
@@ -185,6 +188,7 @@ test_files:
|
|
185
188
|
- spec/hashie/extensions/deep_locate_spec.rb
|
186
189
|
- spec/hashie/extensions/coercion_spec.rb
|
187
190
|
- spec/hashie/extensions/mash/safe_assignment_spec.rb
|
191
|
+
- spec/hashie/extensions/mash/define_accessors_spec.rb
|
188
192
|
- spec/hashie/extensions/mash/symbolize_keys_spec.rb
|
189
193
|
- spec/hashie/extensions/mash/keep_original_keys_spec.rb
|
190
194
|
- spec/hashie/extensions/key_conversion_spec.rb
|