lutaml-store 0.1.1 → 0.2.1
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 +4 -4
- data/.rubocop_todo.yml +11 -371
- data/README.adoc +233 -1124
- data/lib/lutaml/store/adapter/base.rb +4 -0
- data/lib/lutaml/store/adapter/memory.rb +8 -0
- data/lib/lutaml/store/attribute_updater.rb +12 -3
- data/lib/lutaml/store/basic_store.rb +4 -0
- data/lib/lutaml/store/cache_store.rb +10 -7
- data/lib/lutaml/store/database_store.rb +1 -1
- data/lib/lutaml/store/format/yamls.rb +2 -2
- data/lib/lutaml/store/format.rb +19 -0
- data/lib/lutaml/store/http_cache.rb +7 -14
- data/lib/lutaml/store/model_registration.rb +5 -2
- data/lib/lutaml/store/model_registry.rb +22 -17
- data/lib/lutaml/store/package_definition.rb +62 -0
- data/lib/lutaml/store/package_store.rb +133 -0
- data/lib/lutaml/store/package_transport/base.rb +48 -0
- data/lib/lutaml/store/package_transport/directory_transport.rb +196 -0
- data/lib/lutaml/store/package_transport/zip_transport.rb +178 -0
- data/lib/lutaml/store/package_transport.rb +23 -0
- data/lib/lutaml/store/version.rb +1 -1
- data/lib/lutaml/store.rb +3 -0
- metadata +29 -70
- data/.github/workflows/main.yml +0 -27
- data/.gitignore +0 -12
- data/CORRECTED_HTTP_CACHE_IMPLEMENTATION.md +0 -209
- data/CORRECTED_HTTP_CACHE_PLAN.md +0 -164
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -220
- data/TODO.impl/0-lutaml-store-self-quality.md +0 -112
- data/TODO.impl/1-lutaml-hal-migration.md +0 -60
- data/TODO.impl/2-glossarist-migration.md +0 -359
- data/TODO.impl/3-lutaml-jsonschema-migration.md +0 -273
- data/bin/console +0 -11
- data/bin/setup +0 -8
- data/demo/Gemfile +0 -15
- data/demo/Gemfile.lock +0 -61
- data/demo/README.adoc +0 -301
- data/demo/data/vcards/co/contact_10_thompson.data +0 -1
- data/demo/data/vcards/co/contact_10_thompson.meta +0 -1
- data/demo/data/vcards/co/contact_1_doe.data +0 -1
- data/demo/data/vcards/co/contact_1_doe.meta +0 -1
- data/demo/data/vcards/co/contact_2_smith.data +0 -1
- data/demo/data/vcards/co/contact_2_smith.meta +0 -1
- data/demo/data/vcards/co/contact_3_johnson.data +0 -1
- data/demo/data/vcards/co/contact_3_johnson.meta +0 -1
- data/demo/data/vcards/co/contact_4_garcia.data +0 -1
- data/demo/data/vcards/co/contact_4_garcia.meta +0 -1
- data/demo/data/vcards/co/contact_5_wilson.data +0 -1
- data/demo/data/vcards/co/contact_5_wilson.meta +0 -1
- data/demo/data/vcards/co/contact_6_brown.data +0 -1
- data/demo/data/vcards/co/contact_6_brown.meta +0 -1
- data/demo/data/vcards/co/contact_7_davis.data +0 -1
- data/demo/data/vcards/co/contact_7_davis.meta +0 -1
- data/demo/data/vcards/co/contact_8_anderson.data +0 -1
- data/demo/data/vcards/co/contact_8_anderson.meta +0 -1
- data/demo/data/vcards/co/contact_9_taylor.data +0 -1
- data/demo/data/vcards/co/contact_9_taylor.meta +0 -1
- data/demo/data/vcards.db +0 -0
- data/demo/pottery_class_demo.rb +0 -164
- data/demo/vcard_models.rb +0 -140
- data/demo/vcard_store_demo.rb +0 -526
- data/lutaml-store.gemspec +0 -35
- data/plan.adoc +0 -606
- data/spec/lutaml/store/adapter_interface_spec.rb +0 -89
- data/spec/lutaml/store/anti_pattern_guard_spec.rb +0 -35
- data/spec/lutaml/store/anti_pattern_spec.rb +0 -78
- data/spec/lutaml/store/autoload_spec.rb +0 -34
- data/spec/lutaml/store/cache_store_spec.rb +0 -271
- data/spec/lutaml/store/compression_spec.rb +0 -78
- data/spec/lutaml/store/config_enhanced_spec.rb +0 -158
- data/spec/lutaml/store/corrected_http_cache_integration_spec.rb +0 -336
- data/spec/lutaml/store/custom_serializer_spec.rb +0 -108
- data/spec/lutaml/store/database_store_spec.rb +0 -279
- data/spec/lutaml/store/file_io_spec.rb +0 -219
- data/spec/lutaml/store/format_round_trip_spec.rb +0 -110
- data/spec/lutaml/store/format_spec.rb +0 -70
- data/spec/lutaml/store/http_cache_entry_spec.rb +0 -203
- data/spec/lutaml/store/http_cache_hal_integration_spec.rb +0 -404
- data/spec/lutaml/store/http_cache_spec.rb +0 -422
- data/spec/lutaml/store/http_header_processor_spec.rb +0 -290
- data/spec/lutaml/store/import_spec.rb +0 -90
- data/spec/lutaml/store/integrity_spec.rb +0 -157
- data/spec/lutaml/store/key_collision_serializer_spec.rb +0 -98
- data/spec/lutaml/store/load_save_spec.rb +0 -107
- data/spec/lutaml/store/lutaml_model_integration_spec.rb +0 -291
- data/spec/lutaml/store/model_serializer_spec.rb +0 -140
- data/spec/lutaml/store/store_spec.rb +0 -182
- data/spec/lutaml/store_spec.rb +0 -21
- data/spec/spec_helper.rb +0 -16
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Store
|
|
5
|
+
module PackageTransport
|
|
6
|
+
class DirectoryTransport < Base
|
|
7
|
+
def read(path, package_store, format: nil)
|
|
8
|
+
definition = package_store.definition
|
|
9
|
+
global_format = format
|
|
10
|
+
|
|
11
|
+
read_metadata(path, package_store)
|
|
12
|
+
|
|
13
|
+
definition.model_entries.each do |entry|
|
|
14
|
+
fmt_name = global_format || entry.default_format
|
|
15
|
+
read_model_entry(path, entry, package_store, fmt_name)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
definition.asset_entries.each do |entry|
|
|
19
|
+
read_asset_entry(path, entry, package_store)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def write(path, package_store, formats: {})
|
|
24
|
+
definition = package_store.definition
|
|
25
|
+
FileUtils.mkdir_p(path)
|
|
26
|
+
|
|
27
|
+
write_metadata(path, package_store)
|
|
28
|
+
|
|
29
|
+
definition.model_entries.each do |entry|
|
|
30
|
+
fmt_name = effective_format(entry, formats)
|
|
31
|
+
fmt = resolve_format(fmt_name)
|
|
32
|
+
write_model_entry(path, entry, package_store, fmt)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
definition.asset_entries.each do |entry|
|
|
36
|
+
write_asset_entry(path, entry, package_store)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
def read_metadata(path, package_store)
|
|
43
|
+
definition = package_store.definition
|
|
44
|
+
return unless definition.metadata_model && definition.metadata_file
|
|
45
|
+
|
|
46
|
+
file_path = File.join(path, definition.metadata_file)
|
|
47
|
+
return unless File.exist?(file_path)
|
|
48
|
+
|
|
49
|
+
fmt = format_for_file(definition.metadata_file)
|
|
50
|
+
raw = File.read(file_path, encoding: "utf-8")
|
|
51
|
+
metadata = fmt.deserialize(raw, definition.metadata_model)
|
|
52
|
+
package_store.metadata = metadata
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def write_metadata(path, package_store)
|
|
56
|
+
return unless package_store.metadata
|
|
57
|
+
|
|
58
|
+
definition = package_store.definition
|
|
59
|
+
fmt = format_for_file(definition.metadata_file)
|
|
60
|
+
content = fmt.serialize(package_store.metadata)
|
|
61
|
+
file_path = File.join(path, definition.metadata_file)
|
|
62
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
|
63
|
+
File.write(file_path, content, encoding: "utf-8")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def read_model_entry(base_path, entry, package_store, fmt_name)
|
|
67
|
+
if entry.file
|
|
68
|
+
read_single_file_model(base_path, entry, package_store, fmt_name)
|
|
69
|
+
else
|
|
70
|
+
read_directory_models(base_path, entry, package_store, fmt_name)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def read_single_file_model(base_path, entry, package_store, fmt_name)
|
|
75
|
+
file_path = File.join(base_path, entry.file)
|
|
76
|
+
return unless File.exist?(file_path)
|
|
77
|
+
|
|
78
|
+
fmt = resolve_format(fmt_name)
|
|
79
|
+
raw = File.read(file_path, encoding: "utf-8")
|
|
80
|
+
model = fmt.deserialize(raw, entry.model)
|
|
81
|
+
package_store.add_model(model)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def read_directory_models(base_path, entry, package_store, fmt_name)
|
|
85
|
+
dir = entry.dir ? File.join(base_path, entry.dir) : base_path
|
|
86
|
+
return unless Dir.exist?(dir)
|
|
87
|
+
|
|
88
|
+
fmt = resolve_format(fmt_name)
|
|
89
|
+
glob = File.join(dir, fmt.glob_pattern)
|
|
90
|
+
|
|
91
|
+
Dir.glob(glob).sort.each do |file_path|
|
|
92
|
+
next unless File.file?(file_path)
|
|
93
|
+
|
|
94
|
+
raw = File.read(file_path, encoding: "utf-8")
|
|
95
|
+
next if raw.strip.empty?
|
|
96
|
+
|
|
97
|
+
begin
|
|
98
|
+
case entry.layout
|
|
99
|
+
when :grouped
|
|
100
|
+
fmt.deserialize_many(raw, entry.model).each do |m|
|
|
101
|
+
set_key_from_filename(m, file_path, entry)
|
|
102
|
+
package_store.add_model(m)
|
|
103
|
+
end
|
|
104
|
+
else
|
|
105
|
+
model = fmt.deserialize(raw, entry.model)
|
|
106
|
+
set_key_from_filename(model, file_path, entry)
|
|
107
|
+
package_store.add_model(model)
|
|
108
|
+
end
|
|
109
|
+
rescue StandardError => e
|
|
110
|
+
warn "PackageStore: failed to load #{file_path}: #{e.message}"
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def write_model_entry(base_path, entry, package_store, fmt)
|
|
116
|
+
models = package_store.models_for(entry.model)
|
|
117
|
+
return if models.empty?
|
|
118
|
+
|
|
119
|
+
if entry.file
|
|
120
|
+
write_single_file_model(base_path, entry, models, fmt)
|
|
121
|
+
else
|
|
122
|
+
write_directory_models(base_path, entry, models, fmt)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def write_single_file_model(base_path, entry, models, fmt)
|
|
127
|
+
content = entry.layout == :grouped ? fmt.serialize_many(models) : fmt.serialize(models.first)
|
|
128
|
+
file_path = File.join(base_path, entry.file)
|
|
129
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
|
130
|
+
File.write(file_path, content, encoding: "utf-8")
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def write_directory_models(base_path, entry, models, fmt)
|
|
134
|
+
dir = entry.dir ? File.join(base_path, entry.dir) : base_path
|
|
135
|
+
FileUtils.mkdir_p(dir)
|
|
136
|
+
|
|
137
|
+
case entry.layout
|
|
138
|
+
when :grouped
|
|
139
|
+
models.group_by { |m| extract_key(m, entry) }.each do |key, group|
|
|
140
|
+
file_path = File.join(dir, "#{sanitize_filename(key)}#{fmt.extension}")
|
|
141
|
+
File.write(file_path, fmt.serialize_many(group), encoding: "utf-8")
|
|
142
|
+
end
|
|
143
|
+
else
|
|
144
|
+
models.each do |model|
|
|
145
|
+
key = extract_key(model, entry)
|
|
146
|
+
file_path = File.join(dir, "#{sanitize_filename(key)}#{fmt.extension}")
|
|
147
|
+
File.write(file_path, fmt.serialize(model), encoding: "utf-8")
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def read_asset_entry(base_path, entry, package_store)
|
|
153
|
+
full_path = File.join(base_path, entry.path)
|
|
154
|
+
case entry.type
|
|
155
|
+
when :file
|
|
156
|
+
return unless File.exist?(full_path)
|
|
157
|
+
|
|
158
|
+
package_store.add_asset(entry.path, File.binread(full_path))
|
|
159
|
+
when :directory
|
|
160
|
+
return unless Dir.exist?(full_path)
|
|
161
|
+
|
|
162
|
+
Dir.glob(File.join(full_path, "**", "*")).each do |file|
|
|
163
|
+
next unless File.file?(file)
|
|
164
|
+
|
|
165
|
+
relative = file.sub(%r{\A#{Regexp.escape(base_path)}/}, "")
|
|
166
|
+
package_store.add_asset(relative, File.binread(file))
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def write_asset_entry(base_path, entry, package_store)
|
|
172
|
+
case entry.type
|
|
173
|
+
when :file
|
|
174
|
+
content = package_store.asset(entry.path)
|
|
175
|
+
return unless content
|
|
176
|
+
|
|
177
|
+
file_path = File.join(base_path, entry.path)
|
|
178
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
|
179
|
+
File.binwrite(file_path, content)
|
|
180
|
+
when :directory
|
|
181
|
+
package_store.asset_paths
|
|
182
|
+
.select { |p| p.start_with?("#{entry.path}/") }
|
|
183
|
+
.each do |asset_path|
|
|
184
|
+
content = package_store.asset(asset_path)
|
|
185
|
+
next unless content
|
|
186
|
+
|
|
187
|
+
file_path = File.join(base_path, asset_path)
|
|
188
|
+
FileUtils.mkdir_p(File.dirname(file_path))
|
|
189
|
+
File.binwrite(file_path, content)
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "zip"
|
|
4
|
+
|
|
5
|
+
module Lutaml
|
|
6
|
+
module Store
|
|
7
|
+
module PackageTransport
|
|
8
|
+
class ZipTransport < Base
|
|
9
|
+
def read(path, package_store, format: nil)
|
|
10
|
+
definition = package_store.definition
|
|
11
|
+
global_format = format
|
|
12
|
+
|
|
13
|
+
Zip::File.open(path) do |zip_file|
|
|
14
|
+
read_metadata_zip(zip_file, package_store)
|
|
15
|
+
|
|
16
|
+
definition.model_entries.each do |entry|
|
|
17
|
+
fmt_name = global_format || entry.default_format
|
|
18
|
+
read_model_entry_zip(zip_file, entry, package_store, fmt_name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
definition.asset_entries.each do |entry|
|
|
22
|
+
read_asset_entry_zip(zip_file, entry, package_store)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def write(path, package_store, formats: {})
|
|
28
|
+
definition = package_store.definition
|
|
29
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
30
|
+
|
|
31
|
+
Zip::File.open(path, create: true) do |zip_file|
|
|
32
|
+
write_metadata_zip(zip_file, package_store)
|
|
33
|
+
|
|
34
|
+
definition.model_entries.each do |entry|
|
|
35
|
+
fmt_name = effective_format(entry, formats)
|
|
36
|
+
fmt = resolve_format(fmt_name)
|
|
37
|
+
write_model_entry_zip(zip_file, entry, package_store, fmt)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
write_assets_zip(zip_file, package_store)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
private
|
|
45
|
+
|
|
46
|
+
def read_metadata_zip(zip_file, package_store)
|
|
47
|
+
definition = package_store.definition
|
|
48
|
+
return unless definition.metadata_model && definition.metadata_file
|
|
49
|
+
|
|
50
|
+
entry = zip_file.find_entry(definition.metadata_file)
|
|
51
|
+
return unless entry
|
|
52
|
+
|
|
53
|
+
fmt = format_for_file(definition.metadata_file)
|
|
54
|
+
raw = entry.get_input_stream.read
|
|
55
|
+
metadata = fmt.deserialize(raw, definition.metadata_model)
|
|
56
|
+
package_store.metadata = metadata
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def write_metadata_zip(zip_file, package_store)
|
|
60
|
+
return unless package_store.metadata
|
|
61
|
+
|
|
62
|
+
definition = package_store.definition
|
|
63
|
+
fmt = format_for_file(definition.metadata_file)
|
|
64
|
+
content = fmt.serialize(package_store.metadata)
|
|
65
|
+
zip_file.get_output_stream(definition.metadata_file) { |f| f.write(content) }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def read_model_entry_zip(zip_file, entry, package_store, fmt_name)
|
|
69
|
+
fmt = resolve_format(fmt_name)
|
|
70
|
+
|
|
71
|
+
if entry.file
|
|
72
|
+
read_single_file_zip(zip_file, entry, package_store, fmt)
|
|
73
|
+
else
|
|
74
|
+
read_directory_zip(zip_file, entry, package_store, fmt)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def read_single_file_zip(zip_file, entry, package_store, fmt)
|
|
79
|
+
zip_entry = zip_file.find_entry(entry.file)
|
|
80
|
+
return unless zip_entry
|
|
81
|
+
|
|
82
|
+
raw = zip_entry.get_input_stream.read
|
|
83
|
+
model = fmt.deserialize(raw, entry.model)
|
|
84
|
+
package_store.add_model(model)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def read_directory_zip(zip_file, entry, package_store, fmt)
|
|
88
|
+
prefix = entry.dir ? "#{entry.dir}/" : ""
|
|
89
|
+
|
|
90
|
+
zip_file.entries.each do |zip_entry|
|
|
91
|
+
next unless zip_entry.name.start_with?(prefix)
|
|
92
|
+
next unless matches_format?(zip_entry.name, fmt)
|
|
93
|
+
next if zip_entry.name == prefix || zip_entry.name.end_with?("/")
|
|
94
|
+
|
|
95
|
+
raw = zip_entry.get_input_stream.read
|
|
96
|
+
next if raw.strip.empty?
|
|
97
|
+
|
|
98
|
+
begin
|
|
99
|
+
loaded = fmt.deserialize_many(raw, entry.model)
|
|
100
|
+
loaded = [loaded] unless loaded.is_a?(Array)
|
|
101
|
+
loaded.each do |m|
|
|
102
|
+
set_key_from_zip_path(m, zip_entry.name, entry, prefix)
|
|
103
|
+
package_store.add_model(m)
|
|
104
|
+
end
|
|
105
|
+
rescue StandardError => e
|
|
106
|
+
warn "PackageStore: failed to load #{zip_entry.name}: #{e.message}"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def write_model_entry_zip(zip_file, entry, package_store, fmt)
|
|
112
|
+
models = package_store.models_for(entry.model)
|
|
113
|
+
return if models.empty?
|
|
114
|
+
|
|
115
|
+
if entry.file
|
|
116
|
+
content = entry.layout == :grouped ? fmt.serialize_many(models) : fmt.serialize(models.first)
|
|
117
|
+
zip_file.get_output_stream(entry.file) { |f| f.write(content) }
|
|
118
|
+
else
|
|
119
|
+
write_directory_models_zip(zip_file, entry, models, fmt)
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def write_directory_models_zip(zip_file, entry, models, fmt)
|
|
124
|
+
prefix = entry.dir ? "#{entry.dir}/" : ""
|
|
125
|
+
|
|
126
|
+
case entry.layout
|
|
127
|
+
when :grouped
|
|
128
|
+
models.group_by { |m| extract_key(m, entry) }.each do |key, group|
|
|
129
|
+
filename = "#{prefix}#{sanitize_filename(key)}#{fmt.extension}"
|
|
130
|
+
zip_file.get_output_stream(filename) { |f| f.write(fmt.serialize_many(group)) }
|
|
131
|
+
end
|
|
132
|
+
else
|
|
133
|
+
models.each do |model|
|
|
134
|
+
key = extract_key(model, entry)
|
|
135
|
+
filename = "#{prefix}#{sanitize_filename(key)}#{fmt.extension}"
|
|
136
|
+
zip_file.get_output_stream(filename) { |f| f.write(fmt.serialize(model)) }
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def read_asset_entry_zip(zip_file, entry, package_store)
|
|
142
|
+
case entry.type
|
|
143
|
+
when :file
|
|
144
|
+
zip_entry = zip_file.find_entry(entry.path)
|
|
145
|
+
package_store.add_asset(entry.path, zip_entry.get_input_stream.read) if zip_entry
|
|
146
|
+
when :directory
|
|
147
|
+
prefix = entry.path.end_with?("/") ? entry.path : "#{entry.path}/"
|
|
148
|
+
zip_file.entries.each do |zip_entry|
|
|
149
|
+
next unless zip_entry.name.start_with?(prefix)
|
|
150
|
+
next if zip_entry.name == prefix || zip_entry.name.end_with?("/")
|
|
151
|
+
|
|
152
|
+
package_store.add_asset(zip_entry.name, zip_entry.get_input_stream.read)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def write_assets_zip(zip_file, package_store)
|
|
158
|
+
package_store.asset_paths.each do |asset_path|
|
|
159
|
+
content = package_store.asset(asset_path)
|
|
160
|
+
zip_file.get_output_stream(asset_path) { |f| f.write(content) } if content
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def set_key_from_zip_path(model, zip_path, entry, prefix)
|
|
165
|
+
return if model.public_send(entry.key)
|
|
166
|
+
|
|
167
|
+
filename = zip_path.sub(prefix, "")
|
|
168
|
+
set_key_from_filename(model, filename, entry)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def matches_format?(name, fmt)
|
|
172
|
+
ext = File.extname(name)
|
|
173
|
+
ext == fmt.extension || (fmt.extension == ".yaml" && ext == ".yml")
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lutaml
|
|
4
|
+
module Store
|
|
5
|
+
module PackageTransport
|
|
6
|
+
autoload :Base, "lutaml/store/package_transport/base"
|
|
7
|
+
autoload :DirectoryTransport, "lutaml/store/package_transport/directory_transport"
|
|
8
|
+
autoload :ZipTransport, "lutaml/store/package_transport/zip_transport"
|
|
9
|
+
|
|
10
|
+
TRANSPORTS = {
|
|
11
|
+
directory: "DirectoryTransport",
|
|
12
|
+
zip: "ZipTransport"
|
|
13
|
+
}.freeze
|
|
14
|
+
|
|
15
|
+
def self.resolve(transport)
|
|
16
|
+
entry = TRANSPORTS[transport.to_sym]
|
|
17
|
+
raise ConfigurationError, "Unknown transport: #{transport}" unless entry
|
|
18
|
+
|
|
19
|
+
const_get(entry).new
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/lutaml/store/version.rb
CHANGED
data/lib/lutaml/store.rb
CHANGED
|
@@ -25,6 +25,9 @@ module Lutaml
|
|
|
25
25
|
autoload :CompositeModelHandler, "lutaml/store/composite_model_handler"
|
|
26
26
|
autoload :AttributeUpdater, "lutaml/store/attribute_updater"
|
|
27
27
|
autoload :DatabaseStore, "lutaml/store/database_store"
|
|
28
|
+
autoload :PackageDefinition, "lutaml/store/package_definition"
|
|
29
|
+
autoload :PackageStore, "lutaml/store/package_store"
|
|
30
|
+
autoload :PackageTransport, "lutaml/store/package_transport"
|
|
28
31
|
autoload :Adapter, "lutaml/store/adapter"
|
|
29
32
|
autoload :StorageKey, "lutaml/store/storage_key"
|
|
30
33
|
autoload :Format, "lutaml/store/format"
|
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-store
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ronald Tse
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-06-05 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: lutaml-model
|
|
@@ -23,6 +24,20 @@ dependencies:
|
|
|
23
24
|
- - "~>"
|
|
24
25
|
- !ruby/object:Gem::Version
|
|
25
26
|
version: 0.8.15
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rubyzip
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.3'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.3'
|
|
26
41
|
description: |
|
|
27
42
|
Provides a unified store interface for Lutaml::Model objects with model registry,
|
|
28
43
|
polymorphic support, composite relationships, and multiple storage backends
|
|
@@ -33,52 +48,13 @@ executables: []
|
|
|
33
48
|
extensions: []
|
|
34
49
|
extra_rdoc_files: []
|
|
35
50
|
files:
|
|
36
|
-
- ".github/workflows/main.yml"
|
|
37
|
-
- ".gitignore"
|
|
38
51
|
- ".rspec"
|
|
39
52
|
- ".rubocop.yml"
|
|
40
53
|
- ".rubocop_todo.yml"
|
|
41
54
|
- CLAUDE.md
|
|
42
55
|
- CODE_OF_CONDUCT.md
|
|
43
|
-
- CORRECTED_HTTP_CACHE_IMPLEMENTATION.md
|
|
44
|
-
- CORRECTED_HTTP_CACHE_PLAN.md
|
|
45
|
-
- Gemfile
|
|
46
|
-
- Gemfile.lock
|
|
47
56
|
- README.adoc
|
|
48
57
|
- Rakefile
|
|
49
|
-
- TODO.impl/0-lutaml-store-self-quality.md
|
|
50
|
-
- TODO.impl/1-lutaml-hal-migration.md
|
|
51
|
-
- TODO.impl/2-glossarist-migration.md
|
|
52
|
-
- TODO.impl/3-lutaml-jsonschema-migration.md
|
|
53
|
-
- bin/console
|
|
54
|
-
- bin/setup
|
|
55
|
-
- demo/Gemfile
|
|
56
|
-
- demo/Gemfile.lock
|
|
57
|
-
- demo/README.adoc
|
|
58
|
-
- demo/data/vcards.db
|
|
59
|
-
- demo/data/vcards/co/contact_10_thompson.data
|
|
60
|
-
- demo/data/vcards/co/contact_10_thompson.meta
|
|
61
|
-
- demo/data/vcards/co/contact_1_doe.data
|
|
62
|
-
- demo/data/vcards/co/contact_1_doe.meta
|
|
63
|
-
- demo/data/vcards/co/contact_2_smith.data
|
|
64
|
-
- demo/data/vcards/co/contact_2_smith.meta
|
|
65
|
-
- demo/data/vcards/co/contact_3_johnson.data
|
|
66
|
-
- demo/data/vcards/co/contact_3_johnson.meta
|
|
67
|
-
- demo/data/vcards/co/contact_4_garcia.data
|
|
68
|
-
- demo/data/vcards/co/contact_4_garcia.meta
|
|
69
|
-
- demo/data/vcards/co/contact_5_wilson.data
|
|
70
|
-
- demo/data/vcards/co/contact_5_wilson.meta
|
|
71
|
-
- demo/data/vcards/co/contact_6_brown.data
|
|
72
|
-
- demo/data/vcards/co/contact_6_brown.meta
|
|
73
|
-
- demo/data/vcards/co/contact_7_davis.data
|
|
74
|
-
- demo/data/vcards/co/contact_7_davis.meta
|
|
75
|
-
- demo/data/vcards/co/contact_8_anderson.data
|
|
76
|
-
- demo/data/vcards/co/contact_8_anderson.meta
|
|
77
|
-
- demo/data/vcards/co/contact_9_taylor.data
|
|
78
|
-
- demo/data/vcards/co/contact_9_taylor.meta
|
|
79
|
-
- demo/pottery_class_demo.rb
|
|
80
|
-
- demo/vcard_models.rb
|
|
81
|
-
- demo/vcard_store_demo.rb
|
|
82
58
|
- lib/lutaml/store.rb
|
|
83
59
|
- lib/lutaml/store/adapter.rb
|
|
84
60
|
- lib/lutaml/store/adapter/base.rb
|
|
@@ -110,42 +86,24 @@ files:
|
|
|
110
86
|
- lib/lutaml/store/model_registry.rb
|
|
111
87
|
- lib/lutaml/store/model_serializer.rb
|
|
112
88
|
- lib/lutaml/store/monitor.rb
|
|
89
|
+
- lib/lutaml/store/package_definition.rb
|
|
90
|
+
- lib/lutaml/store/package_store.rb
|
|
91
|
+
- lib/lutaml/store/package_transport.rb
|
|
92
|
+
- lib/lutaml/store/package_transport/base.rb
|
|
93
|
+
- lib/lutaml/store/package_transport/directory_transport.rb
|
|
94
|
+
- lib/lutaml/store/package_transport/zip_transport.rb
|
|
113
95
|
- lib/lutaml/store/storage_key.rb
|
|
114
96
|
- lib/lutaml/store/version.rb
|
|
115
|
-
- lutaml-store.gemspec
|
|
116
|
-
- plan.adoc
|
|
117
97
|
- sig/lutaml/store.rbs
|
|
118
|
-
- spec/lutaml/store/adapter_interface_spec.rb
|
|
119
|
-
- spec/lutaml/store/anti_pattern_guard_spec.rb
|
|
120
|
-
- spec/lutaml/store/anti_pattern_spec.rb
|
|
121
|
-
- spec/lutaml/store/autoload_spec.rb
|
|
122
|
-
- spec/lutaml/store/cache_store_spec.rb
|
|
123
|
-
- spec/lutaml/store/compression_spec.rb
|
|
124
|
-
- spec/lutaml/store/config_enhanced_spec.rb
|
|
125
|
-
- spec/lutaml/store/corrected_http_cache_integration_spec.rb
|
|
126
|
-
- spec/lutaml/store/custom_serializer_spec.rb
|
|
127
|
-
- spec/lutaml/store/database_store_spec.rb
|
|
128
|
-
- spec/lutaml/store/file_io_spec.rb
|
|
129
|
-
- spec/lutaml/store/format_round_trip_spec.rb
|
|
130
|
-
- spec/lutaml/store/format_spec.rb
|
|
131
|
-
- spec/lutaml/store/http_cache_entry_spec.rb
|
|
132
|
-
- spec/lutaml/store/http_cache_hal_integration_spec.rb
|
|
133
|
-
- spec/lutaml/store/http_cache_spec.rb
|
|
134
|
-
- spec/lutaml/store/http_header_processor_spec.rb
|
|
135
|
-
- spec/lutaml/store/import_spec.rb
|
|
136
|
-
- spec/lutaml/store/integrity_spec.rb
|
|
137
|
-
- spec/lutaml/store/key_collision_serializer_spec.rb
|
|
138
|
-
- spec/lutaml/store/load_save_spec.rb
|
|
139
|
-
- spec/lutaml/store/lutaml_model_integration_spec.rb
|
|
140
|
-
- spec/lutaml/store/model_serializer_spec.rb
|
|
141
|
-
- spec/lutaml/store/store_spec.rb
|
|
142
|
-
- spec/lutaml/store_spec.rb
|
|
143
|
-
- spec/spec_helper.rb
|
|
144
98
|
homepage: https://github.com/lutaml/lutaml-store
|
|
145
99
|
licenses:
|
|
146
100
|
- BSD-2-Clause
|
|
147
101
|
metadata:
|
|
102
|
+
homepage_uri: https://github.com/lutaml/lutaml-store
|
|
103
|
+
source_code_uri: https://github.com/lutaml/lutaml-store
|
|
104
|
+
changelog_uri: https://github.com/lutaml/lutaml-store
|
|
148
105
|
rubygems_mfa_required: 'true'
|
|
106
|
+
post_install_message:
|
|
149
107
|
rdoc_options: []
|
|
150
108
|
require_paths:
|
|
151
109
|
- lib
|
|
@@ -160,7 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
160
118
|
- !ruby/object:Gem::Version
|
|
161
119
|
version: '0'
|
|
162
120
|
requirements: []
|
|
163
|
-
rubygems_version: 3.
|
|
121
|
+
rubygems_version: 3.5.22
|
|
122
|
+
signing_key:
|
|
164
123
|
specification_version: 4
|
|
165
124
|
summary: Store-centric database-style API for Lutaml::Model with multi-backend persistence.
|
|
166
125
|
test_files: []
|
data/.github/workflows/main.yml
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
name: Ruby
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
pull_request:
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
build:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
name: Ruby ${{ matrix.ruby }}
|
|
14
|
-
strategy:
|
|
15
|
-
matrix:
|
|
16
|
-
ruby:
|
|
17
|
-
- '3.3.2'
|
|
18
|
-
|
|
19
|
-
steps:
|
|
20
|
-
- uses: actions/checkout@v4
|
|
21
|
-
- name: Set up Ruby
|
|
22
|
-
uses: ruby/setup-ruby@v1
|
|
23
|
-
with:
|
|
24
|
-
ruby-version: ${{ matrix.ruby }}
|
|
25
|
-
bundler-cache: true
|
|
26
|
-
- name: Run the default task
|
|
27
|
-
run: bundle exec rake
|