isomorfeus-data 23.9.0.rc2 → 23.9.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/isomorfeus/data/enhancer.rb +8 -7
- data/lib/isomorfeus/data/file_accelerator.rb +2 -11
- data/lib/isomorfeus/data/sid.rb +1 -0
- data/lib/isomorfeus/data/version.rb +1 -1
- data/lib/lucid_file.rb +21 -11
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52bd517854fce63b24584af58fa2eb4480f345c81d543000a83c19e19db9f9c7
|
4
|
+
data.tar.gz: 20ce11e50a95d775b5f91c00aaf94a719b8057263d12c70c2b4e2221326e577b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16d9862281a0bbe9f8fb3e5b2aa3903390092401ae49dc809fdb3b964a7bf7b3ba80781969742e2e2de94192af59acc4c8ec7e8fdcddb405a5effc33b43cf8a8
|
7
|
+
data.tar.gz: 4c9a327753797038d1e2dc9c1ffc991cc3730c4ce4cf8bed95fce64aa46a4c291be9cf1e492ee13f09bbd425b000a79893239754c8b5850462cbdb3ac5c5cf1c
|
@@ -180,8 +180,7 @@ module Isomorfeus
|
|
180
180
|
if data
|
181
181
|
content_type = Marcel::MimeType.for(data)
|
182
182
|
data_uri = item_class.format_data_uri(content_type, data)
|
183
|
-
|
184
|
-
item_hash = { data_uri: data_uri, revision: revision }
|
183
|
+
item_hash = { data_uri: data_uri }.merge(meta)
|
185
184
|
end
|
186
185
|
action = { type: 'DATA_MERGE', data: { item_class_name => { item_key => item_hash }}}
|
187
186
|
elsif action_type == 'FILE_SAVE'
|
@@ -191,6 +190,7 @@ module Isomorfeus
|
|
191
190
|
data_uri = action[:data_uri]
|
192
191
|
authorization_error!(action) unless Isomorfeus.current_user.authorized?(item_class, :save, { key: item_key, data_uri: data_uri })
|
193
192
|
revision = action[:revision]
|
193
|
+
name = action[:name]
|
194
194
|
sid = SID.new(item_class_name, item_key)
|
195
195
|
meta = item_class.file_accelerator.meta(sid: sid)
|
196
196
|
stored_revision = meta[:revision]
|
@@ -201,7 +201,7 @@ module Isomorfeus
|
|
201
201
|
res = item_class.before_save_block.call(key: item_key, data_uri: data_uri)
|
202
202
|
data_uri = res[:data_uri] if res.is_a?(Hash) && res.key?(:data_uri)
|
203
203
|
end
|
204
|
-
if item_class.file_accelerator.save(sid: sid, data: URI::Data.new(data_uri).data, meta: { revision: revision })
|
204
|
+
if item_class.file_accelerator.save(sid: sid, data: URI::Data.new(data_uri).data, meta: { revision: revision, name: name })
|
205
205
|
item_class.after_save_block.call(key: item_key, data_uri: data_uri) if item_class.after_save_block
|
206
206
|
else
|
207
207
|
instance_uuid = nil
|
@@ -210,13 +210,14 @@ module Isomorfeus
|
|
210
210
|
revision = 0
|
211
211
|
instance_uuid = nil
|
212
212
|
end
|
213
|
-
action = { type: 'DATA_MERGE', data: { item_class_name => { item_key => { data_uri: data_uri, revision: revision, instance_uuid: instance_uuid }}}}
|
213
|
+
action = { type: 'DATA_MERGE', data: { item_class_name => { item_key => { data_uri: data_uri, revision: revision, name: name, instance_uuid: instance_uuid }}}}
|
214
214
|
elsif action_type == 'FILE_CREATE'
|
215
215
|
item_class_name = action[:class_name]
|
216
216
|
item_key = action[:key]
|
217
217
|
item_class = get_verified_class(item_class_name)
|
218
218
|
data_uri = action[:data_uri]
|
219
219
|
authorization_error!(action) unless Isomorfeus.current_user.authorized?(item_class, :create, { key: item_key, data_uri: data_uri })
|
220
|
+
name = action[:name]
|
220
221
|
sid = SID.new(item_class_name, item_key)
|
221
222
|
meta = item_class.file_accelerator.meta(sid: sid)
|
222
223
|
stored_revision = meta ? meta[:revision] : nil
|
@@ -227,7 +228,7 @@ module Isomorfeus
|
|
227
228
|
res = item_class.before_create_block.call(key: item_key, data_uri: data_uri)
|
228
229
|
data_uri = res[:data_uri] if res.is_a?(Hash) && res.key?(:data_uri)
|
229
230
|
end
|
230
|
-
if item_class.file_accelerator.create(sid: sid, data: URI::Data.new(data_uri).data, meta: { revision: revision })
|
231
|
+
if item_class.file_accelerator.create(sid: sid, data: URI::Data.new(data_uri).data, meta: { revision: revision, name: name })
|
231
232
|
item_class.after_create_block.call(key: item_key, data_uri: data_uri) if item_class.after_create_block
|
232
233
|
else
|
233
234
|
stored_revision = 0
|
@@ -237,7 +238,7 @@ module Isomorfeus
|
|
237
238
|
revision = stored_revision
|
238
239
|
instance_uuid = nil
|
239
240
|
end
|
240
|
-
action = { type: 'DATA_ADD', data: { item_class_name => { item_key => { data_uri: data_uri, revision: revision, instance_uuid: instance_uuid }}}}
|
241
|
+
action = { type: 'DATA_ADD', data: { item_class_name => { item_key => { data_uri: data_uri, revision: revision, name: name, instance_uuid: instance_uuid }}}}
|
241
242
|
elsif action_type == 'FILE_SEARCH'
|
242
243
|
item_class_name = action[:class_name]
|
243
244
|
item_class = get_verified_class(item_class_name)
|
@@ -302,7 +303,7 @@ module Isomorfeus
|
|
302
303
|
end
|
303
304
|
|
304
305
|
def get_verified_class(item_class_name)
|
305
|
-
raise "Invalid data class!" unless Isomorfeus.valid_data_class_name?(item_class_name)
|
306
|
+
raise "Invalid data class #{item_class_name}!" unless Isomorfeus.valid_data_class_name?(item_class_name)
|
306
307
|
item_class = Isomorfeus.cached_data_class(item_class_name)
|
307
308
|
end
|
308
309
|
|
@@ -105,17 +105,8 @@ module Isomorfeus
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def check_and_prepare_paths(key:)
|
108
|
-
Isomorfeus.raise_error(message: 'Invalid key
|
109
|
-
|
110
|
-
Isomorfeus.raise_error(message: 'Invalid key (contains more than 2 slashes "/")') if elements.size > 3
|
111
|
-
file = elements.pop
|
112
|
-
path = if elements.size > 0
|
113
|
-
dir_path = ::File.expand_path(::File.join(@store_path, *elements))
|
114
|
-
FileUtils.mkdir_p(dir_path) unless Dir.exist?(dir_path)
|
115
|
-
File.join(dir_path, file)
|
116
|
-
else
|
117
|
-
File.join(@store_path, file)
|
118
|
-
end
|
108
|
+
Isomorfeus.raise_error(message: 'Invalid key, must contain word characters or "-" only!') unless key.match?(SID::SID_S_KEY_RE)
|
109
|
+
path = File.join(@store_path, key)
|
119
110
|
[path, "#{path}__meta__"]
|
120
111
|
end
|
121
112
|
end
|
data/lib/isomorfeus/data/sid.rb
CHANGED
data/lib/lucid_file.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
class LucidFile < LucidDataGeneric
|
2
2
|
include LucidI18nMixin
|
3
3
|
|
4
|
-
VALID_METHODS = %i[key data data_uri content_type]
|
4
|
+
VALID_METHODS = %i[key data data_uri name content_type]
|
5
5
|
|
6
6
|
class << self
|
7
7
|
def api_path(key:)
|
@@ -34,11 +34,12 @@ class LucidFile < LucidDataGeneric
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
def initialize(key: nil, content_type: nil, data: nil, data_uri: nil, _loading: false)
|
37
|
+
def initialize(key: nil, content_type: nil, data: nil, data_uri: nil, name: nil, _loading: false)
|
38
38
|
super(key: key)
|
39
39
|
_update_paths
|
40
40
|
loaded = loaded?
|
41
41
|
@changed_uri_string = nil
|
42
|
+
@changed_name = name if name
|
42
43
|
if data_uri
|
43
44
|
@changed_uri_string = data_uri
|
44
45
|
elsif data || content_type
|
@@ -56,7 +57,7 @@ class LucidFile < LucidDataGeneric
|
|
56
57
|
d = data_uri
|
57
58
|
unchange!
|
58
59
|
Isomorfeus.something_loading!
|
59
|
-
Isomorfeus.store.deferred_dispatch(type: "FILE_CREATE", class_name: @class_name, key: @key, data_uri: d, instance_uuid: instance_uuid, revision: 0)
|
60
|
+
Isomorfeus.store.deferred_dispatch(type: "FILE_CREATE", class_name: @class_name, key: @key, data_uri: d, name: name, instance_uuid: instance_uuid, revision: 0)
|
60
61
|
self
|
61
62
|
end
|
62
63
|
|
@@ -66,16 +67,16 @@ class LucidFile < LucidDataGeneric
|
|
66
67
|
d = data_uri
|
67
68
|
unchange!
|
68
69
|
Isomorfeus.something_loading!
|
69
|
-
Isomorfeus.store.deferred_dispatch(type: "FILE_SAVE", class_name: @class_name, key: @key, data_uri: d, instance_uuid: instance_uuid, revision: @last_revision)
|
70
|
+
Isomorfeus.store.deferred_dispatch(type: "FILE_SAVE", class_name: @class_name, key: @key, data_uri: d, name: name, instance_uuid: instance_uuid, revision: @last_revision)
|
70
71
|
self
|
71
72
|
end
|
72
73
|
|
73
|
-
def [](
|
74
|
-
self.send(
|
74
|
+
def [](n)
|
75
|
+
self.send(n) if VALID_METHODS.include?(n)
|
75
76
|
end
|
76
77
|
|
77
|
-
def []=(
|
78
|
-
self.send("#{
|
78
|
+
def []=(n, value)
|
79
|
+
self.send("#{n}=".to_sym, value) if VALID_METHODS.include?(n)
|
79
80
|
end
|
80
81
|
|
81
82
|
def unchange!
|
@@ -84,7 +85,7 @@ class LucidFile < LucidDataGeneric
|
|
84
85
|
end
|
85
86
|
|
86
87
|
def _update_paths
|
87
|
-
@store_path = [:data_state, @class_name, @key
|
88
|
+
@store_path = [:data_state, @class_name, @key]
|
88
89
|
end
|
89
90
|
|
90
91
|
def content_type
|
@@ -93,13 +94,13 @@ class LucidFile < LucidDataGeneric
|
|
93
94
|
|
94
95
|
def content_type=(c)
|
95
96
|
changed!
|
96
|
-
uri_string = @changed_uri_string ? @changed_uri_string : Isomorfeus.store.dig(*@store_path)
|
97
|
+
uri_string = @changed_uri_string ? @changed_uri_string : Isomorfeus.store.dig(*@store_path)&.fetch(:data_uri, nil)
|
97
98
|
@changed_uri_string = self.class.format_data_uri(c, URI::Data.new(uri_string).data)
|
98
99
|
c
|
99
100
|
end
|
100
101
|
|
101
102
|
def data_uri
|
102
|
-
@changed_uri_string ? @changed_uri_string : Isomorfeus.store.dig(*@store_path)
|
103
|
+
@changed_uri_string ? @changed_uri_string : Isomorfeus.store.dig(*@store_path)&.fetch(:data_uri, nil)
|
103
104
|
end
|
104
105
|
|
105
106
|
def data_uri=(d)
|
@@ -127,6 +128,15 @@ class LucidFile < LucidDataGeneric
|
|
127
128
|
@changed_uri_string = self.class.format_data_uri(ct, d)
|
128
129
|
end
|
129
130
|
|
131
|
+
def name
|
132
|
+
@changed_name ? @changed_name : Isomorfeus.store.dig(*@store_path)&.fetch(:name, nil)
|
133
|
+
end
|
134
|
+
|
135
|
+
def name=(n)
|
136
|
+
changed!
|
137
|
+
@changed_name = name
|
138
|
+
end
|
139
|
+
|
130
140
|
if RUBY_ENGINE != 'opal'
|
131
141
|
class << self
|
132
142
|
def inherited(base)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-data
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 23.9.0.
|
4
|
+
version: 23.9.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -106,70 +106,70 @@ dependencies:
|
|
106
106
|
requirements:
|
107
107
|
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 23.9.0.
|
109
|
+
version: 23.9.0.rc4
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 23.9.0.
|
116
|
+
version: 23.9.0.rc4
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: isomorfeus-policy
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
120
120
|
requirements:
|
121
121
|
- - '='
|
122
122
|
- !ruby/object:Gem::Version
|
123
|
-
version: 23.9.0.
|
123
|
+
version: 23.9.0.rc4
|
124
124
|
type: :runtime
|
125
125
|
prerelease: false
|
126
126
|
version_requirements: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - '='
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 23.9.0.
|
130
|
+
version: 23.9.0.rc4
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
name: isomorfeus-preact
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - '='
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: 23.9.0.
|
137
|
+
version: 23.9.0.rc4
|
138
138
|
type: :runtime
|
139
139
|
prerelease: false
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - '='
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version: 23.9.0.
|
144
|
+
version: 23.9.0.rc4
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
name: isomorfeus-redux
|
147
147
|
requirement: !ruby/object:Gem::Requirement
|
148
148
|
requirements:
|
149
149
|
- - '='
|
150
150
|
- !ruby/object:Gem::Version
|
151
|
-
version: 23.9.0.
|
151
|
+
version: 23.9.0.rc4
|
152
152
|
type: :runtime
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: !ruby/object:Gem::Requirement
|
155
155
|
requirements:
|
156
156
|
- - '='
|
157
157
|
- !ruby/object:Gem::Version
|
158
|
-
version: 23.9.0.
|
158
|
+
version: 23.9.0.rc4
|
159
159
|
- !ruby/object:Gem::Dependency
|
160
160
|
name: isomorfeus-transport
|
161
161
|
requirement: !ruby/object:Gem::Requirement
|
162
162
|
requirements:
|
163
163
|
- - '='
|
164
164
|
- !ruby/object:Gem::Version
|
165
|
-
version: 23.9.0.
|
165
|
+
version: 23.9.0.rc4
|
166
166
|
type: :runtime
|
167
167
|
prerelease: false
|
168
168
|
version_requirements: !ruby/object:Gem::Requirement
|
169
169
|
requirements:
|
170
170
|
- - '='
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version: 23.9.0.
|
172
|
+
version: 23.9.0.rc4
|
173
173
|
- !ruby/object:Gem::Dependency
|
174
174
|
name: rake
|
175
175
|
requirement: !ruby/object:Gem::Requirement
|