foobara-local-files-crud-driver 0.0.5 → 0.0.7
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/CHANGELOG.md +8 -0
- data/src/foobara/local_files_crud_driver.rb +29 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bde293f681140c57ca101373a28a20987460cc1923a4e84568d7cca322797c4
|
4
|
+
data.tar.gz: 0fa8d9bdba2788c651e318ab0527f33811fffd8499da9c5f16cafe74956715ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ce0c4090053c01aa1b9b26285268d34924d4a0f7b05c7b0df840b9ba4587d3564ab9bc344dee9dd91d6bee4fefc7fa1be71b4b2ad0e84098c58fb2b886b52e4
|
7
|
+
data.tar.gz: f1d22a4b49d7d18aec84b117c5dbf4b043f44f2d176a4de213aaafc01babea800640ea9c778394984dacca3b77e8e5ec78be63a3030a81fd325b7d0e26cd0229
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [0.0.7] - 2025-03-15
|
2
|
+
|
3
|
+
- Make sure instances of Time and Date are written out in YAML-loadable ways
|
4
|
+
|
5
|
+
## [0.0.6] - 2025-03-15
|
6
|
+
|
7
|
+
- Safety improvement: do not truncate file if we fail to generate record yaml
|
8
|
+
|
1
9
|
## [0.0.5] - 2025-01-07
|
2
10
|
|
3
11
|
- Bump Ruby to 3.4.1
|
@@ -64,7 +64,8 @@ module Foobara
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def insert(attributes)
|
67
|
-
attributes =
|
67
|
+
attributes = prepare_attributes_for_write(attributes)
|
68
|
+
|
68
69
|
record_id = record_id_for(attributes)
|
69
70
|
|
70
71
|
unless record_id
|
@@ -91,6 +92,8 @@ module Foobara
|
|
91
92
|
end
|
92
93
|
|
93
94
|
def update(attributes)
|
95
|
+
attributes = prepare_attributes_for_write(attributes)
|
96
|
+
|
94
97
|
with_writeable_raw_data do |raw_data|
|
95
98
|
attributes = Util.deep_dup(attributes)
|
96
99
|
|
@@ -135,6 +138,23 @@ module Foobara
|
|
135
138
|
|
136
139
|
private
|
137
140
|
|
141
|
+
def prepare_attributes_for_write(value)
|
142
|
+
case value
|
143
|
+
when ::Time
|
144
|
+
value.to_f
|
145
|
+
when ::Date
|
146
|
+
value.to_s
|
147
|
+
when ::Array
|
148
|
+
value.map { |element| prepare_attributes_for_write(element) }
|
149
|
+
when ::Hash
|
150
|
+
value.to_h do |key, value|
|
151
|
+
[prepare_attributes_for_write(key), prepare_attributes_for_write(value)]
|
152
|
+
end
|
153
|
+
else
|
154
|
+
value
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
138
158
|
def data_path
|
139
159
|
crud_driver.data_path
|
140
160
|
end
|
@@ -173,16 +193,21 @@ module Foobara
|
|
173
193
|
with_readable_raw_data(mode: "r+", lock: File::LOCK_EX) do |raw_data, f|
|
174
194
|
if f
|
175
195
|
retval = yield raw_data, f
|
196
|
+
file_contents = YAML.dump(raw_data)
|
176
197
|
f.truncate(0)
|
177
198
|
f.rewind
|
178
|
-
f.write(
|
199
|
+
f.write(file_contents)
|
179
200
|
else
|
180
201
|
FileUtils.mkdir_p File.dirname(data_path)
|
181
202
|
|
182
|
-
File.open(data_path, "
|
203
|
+
File.open(data_path, "a+") do |f|
|
183
204
|
f.flock(File::LOCK_EX)
|
205
|
+
f.rewind
|
184
206
|
retval = yield raw_data, f
|
185
|
-
|
207
|
+
file_contents = YAML.dump(raw_data)
|
208
|
+
f.truncate(0)
|
209
|
+
f.rewind
|
210
|
+
f.write(file_contents)
|
186
211
|
end
|
187
212
|
end
|
188
213
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foobara-local-files-crud-driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Georgi
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-03-23 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: foobara
|
@@ -57,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
57
|
- !ruby/object:Gem::Version
|
58
58
|
version: '0'
|
59
59
|
requirements: []
|
60
|
-
rubygems_version: 3.6.
|
60
|
+
rubygems_version: 3.6.6
|
61
61
|
specification_version: 4
|
62
62
|
summary: Stores all record data in a yaml file in a local directory
|
63
63
|
test_files: []
|