Skip to content

Commit

Permalink
Replace JSON with TOML for snapshot
Browse files Browse the repository at this point in the history
But this made unparsable error for 10000+ years

May relate to toml-lang/toml#538 (comment)
  • Loading branch information
kachick committed Mar 10, 2024
1 parent 76dbc4a commit ca5a1f8
Show file tree
Hide file tree
Showing 5 changed files with 36,022 additions and 37 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ group(:development) do
gem('steep', '~> 1.6.0', require: false)
gem('benchmark-ips', '~> 2.13.0', require: false)
gem('stackprof')
gem('perfect_toml', '~> 0.9.0', require: false)
gem('yard', '~> 0.9.36', require: false)
gem('rubocop', '~> 1.61.0', require: false)
gem('rubocop-rake', '~> 0.6.0', require: false)
Expand Down
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["test/many_data/fixtures"]
37 changes: 0 additions & 37 deletions scripts/convert_snapshot_dump_to_json.rb

This file was deleted.

20 changes: 20 additions & 0 deletions scripts/convert_snapshot_dump_to_toml.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# coding: us-ascii
# frozen_string_literal: true

require('bundler/setup')
require_relative('../lib/ulid')
require_relative('../test/many_data/fixtures/example')

require('perfect_toml')

path_prefix = "#{__dir__}/../test/many_data/fixtures/dumped_fixed_examples_"
timestamp = "2024-01-10_07-59"
without_ext = "#{path_prefix}#{timestamp}"
dump_data = File.binread("#{without_ext}.bin")
examples = Marshal.load(dump_data)
toml_prepared = examples.sort_by(&:integer).to_h { |example| [example.string, example.to_h.except(:string, :period) ] }
PerfectTOML.save_file("#{without_ext}.toml", toml_prepared)

if toml_prepared == PerfectTOML.load_file("#{without_ext}.toml")
raise 'there is a bug for serialization or deserialization in snapshots'
end
Loading

0 comments on commit ca5a1f8

Please sign in to comment.