lucarecord 0.5.4 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7a1835b0493134002d92d7a9b8f8fb6a55305f470636c448da8848f9b6afdaa
4
- data.tar.gz: 9ec15acf15451babe4280c098e670f68a377e9be9af8e312f3b0b558476da995
3
+ metadata.gz: 4574038ef165ecd098bd37897f77a16edb5917aa6c157ce45a005598bc540af2
4
+ data.tar.gz: a2f22d1d3c9899e3c84c7662cb8859794541e31cbd116eae343deb4d4db3e415
5
5
  SHA512:
6
- metadata.gz: 7741483aa8e7e6ca1fb01325f546e703b4a530d48b7d68823f127402c39a092d01ee1bcc6a2f319794bd0830a7095957405b833f02c11e480fec6df399f37997
7
- data.tar.gz: 90934508dd586dc6582be9366b22d9a60958ce247c0d971d36207016b5ec5b69ee7375f6613cc7e37fe920fd135c2fd85dd5482458763e9372b7ae0c39bf78e7
6
+ metadata.gz: 05dccaddb053508040dfab00cd9451b20b10d3a9b78a5317609ab8e71a548109cee9c4ff2579132f2e7380bb470d8639e6ddfb80ffdb23e324c2971e89d596d0
7
+ data.tar.gz: e33237c779d1450bd6c1b9a1c208382a8eda87848da74117b36bc973b93c44b965e1970d8eea60eb0d83698361406700c4dbe1480d511bc0130ece78cf7c6cf3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## LucaRecord 0.5.5
2
+
3
+ * support JSON for `LucaRecord::Base.load_data()` w/ `@record_type = 'json'`
4
+
1
5
  ## LucaRecord 0.5.4
2
6
 
3
7
  * add `upsert()`
@@ -4,6 +4,7 @@ require 'bigdecimal'
4
4
  require 'csv'
5
5
  require 'date'
6
6
  require 'fileutils'
7
+ require 'json'
7
8
  require 'yaml'
8
9
  require 'pathname'
9
10
  require 'luca_support/code'
@@ -427,14 +428,16 @@ module LucaRecord # :nodoc:
427
428
  # If specific decode is needed, override this method in each class.
428
429
  #
429
430
  def load_data(io, path = nil)
430
- if @record_type
431
- case @record_type
432
- when 'json'
433
- # TODO: implement JSON parse
434
- end
435
- else
436
- LucaSupport::Code.decimalize(YAML.safe_load(io.read, permitted_classes: [Date])).tap { |obj| validate_keys(obj) }
437
- end
431
+ raw_obj = if @record_type
432
+ case @record_type
433
+ when 'json'
434
+ JSON.parse(io.read)
435
+ end
436
+ else
437
+ YAML.safe_load(io.read, permitted_classes: [Date])
438
+ end
439
+ LucaSupport::Code.decimalize(raw_obj)
440
+ .tap { |obj| validate_keys(obj) }
438
441
  end
439
442
 
440
443
  def validate_keys(obj)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LucaRecord
4
- VERSION = '0.5.4'
4
+ VERSION = '0.5.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucarecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuma Takahiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-11 00:00:00.000000000 Z
11
+ date: 2023-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler