From 42c339d9cfc2d99e7b377642c4b581ba7f2d1d34 Mon Sep 17 00:00:00 2001 From: "jingyuan.zhao" Date: Mon, 18 May 2026 12:36:53 +0900 Subject: [PATCH 1/3] Treat missing marshal files as empty record sets MarshalLoader#read_raw raised Errno::ENOENT when the dump file did not exist, which prevented bootstrapping a dataset before any dump was produced. Align the behavior with QueryLoader's empty-table fallback so loading a missing table yields an empty record set instead. Also realign the inner-block indentation in queryable.rb so newer RuboCop (Layout/IndentationWidth) stops flagging it. Co-Authored-By: Claude Opus 4.7 (1M context) --- lib/simple_master/loader/marshal_loader.rb | 7 ++++++- lib/simple_master/master/queryable.rb | 2 +- spec/simple_master/loader/marshal_loader_spec.rb | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/simple_master/loader/marshal_loader.rb b/lib/simple_master/loader/marshal_loader.rb index b8700b1..0d86468 100644 --- a/lib/simple_master/loader/marshal_loader.rb +++ b/lib/simple_master/loader/marshal_loader.rb @@ -4,10 +4,15 @@ module SimpleMaster class Loader class MarshalLoader < Loader def read_raw(table) - File.read("#{@options[:path]}/#{table.klass.table_name}.marshal") + path = "#{@options[:path]}/#{table.klass.table_name}.marshal" + return nil unless File.exist?(path) + + File.read(path) end def build_records(_klass, raw) + return [] if raw.nil? + Marshal.load(raw) # rubocop:disable Security/MarshalLoad end end diff --git a/lib/simple_master/master/queryable.rb b/lib/simple_master/master/queryable.rb index 18bd189..2f0c329 100644 --- a/lib/simple_master/master/queryable.rb +++ b/lib/simple_master/master/queryable.rb @@ -42,7 +42,7 @@ def insert_queries(records, on_duplicate_key_update = false, batch_size: 10000) else record.send(method_name) end - }.join(", ").then { "(#{_1})" } + }.join(", ").then { "(#{_1})" } }.join(", \n") "INSERT INTO `#{table_name}` \n#{sql_columns} VALUES \n#{values_sql}#{on_duplicate_key_update_sql};\n" diff --git a/spec/simple_master/loader/marshal_loader_spec.rb b/spec/simple_master/loader/marshal_loader_spec.rb index 206df7a..8514ef7 100644 --- a/spec/simple_master/loader/marshal_loader_spec.rb +++ b/spec/simple_master/loader/marshal_loader_spec.rb @@ -23,4 +23,19 @@ end end end + + it "treats missing marshal files as empty record sets instead of raising" do + Dir.mktmpdir do |dir| + loader = described_class.new(path: dir) + dataset = SimpleMaster::Storage::Dataset.new(loader: loader) + + expect { dataset.load }.not_to raise_error + + SimpleMaster.use_dataset(dataset) do + expect(Weapon.all).to eq([]) + expect(Level.all).to eq([]) + expect(Enemy.all).to eq([]) + end + end + end end From bcf4946b8c1b49c3f4db1ba8bcbce57d84e2d6ac Mon Sep 17 00:00:00 2001 From: "jingyuan.zhao" Date: Mon, 18 May 2026 12:37:03 +0900 Subject: [PATCH 2/3] Disable Style/OneClassPerFile Newer RuboCop releases activated Style/OneClassPerFile by default, which flags two intentional patterns in this codebase: - The ActiveRecord::Associations::Preloader::Association reopen in lib/simple_master.rb, which is a monkey-patch and not a new class. - STI subclass families colocated in a single model file in the rails_sample. Both patterns are deliberate, so disable the cop project-wide. Co-Authored-By: Claude Opus 4.7 (1M context) --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 0c2a8fd..71974c3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -60,6 +60,9 @@ Style/Lambda: Style/MultilineBlockChain: Enabled: false +Style/OneClassPerFile: + Enabled: false + Style/StringLiterals: Enabled: false From b437d4936e1da4fe941ec7eea100490df883d071 Mon Sep 17 00:00:00 2001 From: "jingyuan.zhao" Date: Mon, 18 May 2026 12:37:13 +0900 Subject: [PATCH 3/3] Bump version to 1.0.1 and add CHANGELOG Patch release covering the MarshalLoader missing-file fix. No public API changes; behavior change is limited to gracefully handling a previously-unhandled error path (missing dump file -> empty record set), matching QueryLoader's existing fallback. Adds CHANGELOG.md (Keep a Changelog format) starting from v1.0.0 so future entries have a home. Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 19 +++++++++++++++++++ lib/simple_master/version.rb | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7b40bc3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [1.0.1] - 2026-05-18 + +### Fixed +- `MarshalLoader` no longer raises `Errno::ENOENT` when a dump file is missing; the corresponding table is loaded as an empty record set, matching `QueryLoader`'s fallback for unavailable tables. + +## [1.0.0] - 2025-12-26 + +### Added +- Initial public release. + +[1.0.1]: https://github.com/aktsk/simple_master/compare/v1.0.0...v1.0.1 +[1.0.0]: https://github.com/aktsk/simple_master/releases/tag/v1.0.0 diff --git a/lib/simple_master/version.rb b/lib/simple_master/version.rb index 99f3fec..23a5231 100644 --- a/lib/simple_master/version.rb +++ b/lib/simple_master/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module SimpleMaster - VERSION = "1.0.0" + VERSION = "1.0.1" end