materialist 1.0.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2369c3f2842a7dc8cc9ff3efe2339328b7cf14aa
4
- data.tar.gz: d043d9df4eda5667d6a09b040a485c39e7c16449
3
+ metadata.gz: 52edad7b633726d80df5bf86cb2190a0f68b6094
4
+ data.tar.gz: 2db6abb9165052f9a564751c49ea3c9c6f7c7a34
5
5
  SHA512:
6
- metadata.gz: 78c9b1b5683feadc832ac2184b0b79b1a52f421697b4d921af7e776da7607218093e6a7f9aa12cb5fc2ddf8147c4752c0b4649fc3ea748e408ccc01aec98d9ff
7
- data.tar.gz: 7f9b3b1a197b8c793a040b3d1cb894282bc58446055910c3727d08fea83678de23c7823bcdb613b57b5ec8161c360a00518e96dfc1dd8444641fe6a683399bd9
6
+ metadata.gz: 8ae7bb5132903ff79355624196fdb2e0e087534b29ab7c76734ce014b65959701b414539ce937f0cbe787c4335119778a622a76cf5f0f15599279675e97aefb1
7
+ data.tar.gz: 404ed0434c32eaf7c7353771f05cdf3c907214d7fec93503227eb359beb37ca4bd6ad1e29d140c427e797d186df04f6e798c58a665f50c9743e57ae06877b722
@@ -1,3 +1,3 @@
1
1
  module Materialist
2
- VERSION = '1.0.0'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -190,7 +190,7 @@ module Materialist
190
190
  mapping.inject({}) do |result, m|
191
191
  case m
192
192
  when FieldMapping
193
- result.tap { |r| r[m.as] = serializable_value(resource.body[m.key]) }
193
+ result.tap { |r| r[m.as] = resource.body[m.key] }
194
194
  when LinkHrefMapping
195
195
  result.tap do |r|
196
196
  if resource.body._links.include?(m.key)
@@ -207,11 +207,6 @@ module Materialist
207
207
  end
208
208
  end
209
209
 
210
- def serializable_value(value)
211
- value_is_complex_object = value.is_a?(Hash) || value.is_a?(Array)
212
- value_is_complex_object ? value.to_json : value
213
- end
214
-
215
210
  def resource_at(url)
216
211
  api_client.get(url, options: { enable_caching: false })
217
212
  rescue Routemaster::Errors::ResourceNotFound
@@ -120,8 +120,6 @@ RSpec.describe Materialist::Materializer do
120
120
  let(:city_body) {{ _links: { country: { href: country_url }}, name: 'paris', timezone: 'Europe/Paris' }}
121
121
  let(:source_url) { 'https://service.dev/foobars/1' }
122
122
  let(:source_body) {{ _links: { city: { href: city_url }}, name: 'jack', age: 30 }}
123
- let(:complex_url) { 'https://service.dev/hashes/1' }
124
- let(:complex_body) {{ _links: { city: { href: city_url }}, name: { first_name: 'Mo', last_name: 'Town' }, age: [30,31,44] }}
125
123
 
126
124
  def stub_resource(url, body)
127
125
  stub_request(:get, url).to_return(
@@ -138,7 +136,6 @@ RSpec.describe Materialist::Materializer do
138
136
  stub_resource source_url, source_body
139
137
  stub_resource country_url, country_body
140
138
  stub_resource city_url, city_body
141
- stub_resource complex_url, complex_body
142
139
  end
143
140
 
144
141
  let(:action) { :create }
@@ -161,17 +158,6 @@ RSpec.describe Materialist::Materializer do
161
158
  expect(inserted.name).to eq city_body[:name]
162
159
  end
163
160
 
164
- context "when there are complex value types" do
165
- let(:perform) { FoobarMaterializer.perform(complex_url, action) }
166
-
167
- it "serialises the complex value into json" do
168
- expect{perform}.to change{Foobar.count}.by 1
169
- inserted = Foobar.find_by(source_url: complex_url)
170
- expect(inserted.name).to eq complex_body[:name].to_json
171
- expect(inserted.how_old).to eq complex_body[:age].to_json
172
- end
173
- end
174
-
175
161
  context "when record already exists" do
176
162
  let!(:record) { Foobar.create!(source_url: source_url, name: 'mo') }
177
163
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: materialist
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mo Valipour
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-11 00:00:00.000000000 Z
11
+ date: 2017-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq