Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Style/Lambda:
Style/MultilineBlockChain:
Enabled: false

Style/OneClassPerFile:
Enabled: false

Style/StringLiterals:
Enabled: false

Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion lib/simple_master/loader/marshal_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/simple_master/master/queryable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion lib/simple_master/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SimpleMaster
VERSION = "1.0.0"
VERSION = "1.0.1"
end
15 changes: 15 additions & 0 deletions spec/simple_master/loader/marshal_loader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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