linked_rails 0.0.4.pre.g92825d924 → 0.0.4.pre.g7123943aa
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/linked_rails/bulk_controller.rb +5 -1
- data/app/models/linked_rails/manifest.rb +10 -6
- data/app/workers/linked_rails/invalidation_stream_worker.rb +1 -1
- data/lib/linked_rails/model/cacheable.rb +2 -4
- data/lib/linked_rails/storage.rb +8 -7
- data/lib/linked_rails/url.rb +11 -0
- data/lib/linked_rails.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24aa1f95dca21df7152b6be6499f57d84a5fe37ac3944a0275b55d382a02f662
|
4
|
+
data.tar.gz: 1cfe8deb84e11ec8ec5fa0f2b088a60fe3078f8abe07c2c12fb0fd0e210bed9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 668e32f354c65baeafd91e3e4f5521bcef0c9b9194389afca075e0eb0b078e248e6ec3206df63799e0dbce29f7425e9b6c654e2847bfdba5f6a052476175868f
|
7
|
+
data.tar.gz: 75835d167f14a03c94f24bf56fe8c13021ae2250b152637847cf0df295ddda9de827c0ae9a586ec6b1ac7fc8c2e7a62655e1bf00c1907a067a906a2e835b3f00
|
@@ -161,13 +161,17 @@ module LinkedRails
|
|
161
161
|
|
162
162
|
resource_response(
|
163
163
|
iri,
|
164
|
-
body: include
|
164
|
+
body: response_from_resource_body(include, iri, resource, status),
|
165
165
|
cache: resource_cache_control(resource.try(:cacheable?), status, resource_policy),
|
166
166
|
language: I18n.locale,
|
167
167
|
status: status
|
168
168
|
)
|
169
169
|
end
|
170
170
|
|
171
|
+
def response_from_resource_body(include, _iri, resource, status)
|
172
|
+
include && status == 200 ? resource_body(resource) : nil
|
173
|
+
end
|
174
|
+
|
171
175
|
def term_from_vocab(iri)
|
172
176
|
vocab = Vocab.for(iri)
|
173
177
|
tag = iri.to_s.split(vocab.to_s).last
|
@@ -9,9 +9,7 @@ module LinkedRails
|
|
9
9
|
Storage.hset(
|
10
10
|
:persistent,
|
11
11
|
:manifest,
|
12
|
-
|
13
|
-
LinkedRails.iri.to_s => web_manifest.to_json
|
14
|
-
}
|
12
|
+
URL.as_href(LinkedRails.iri) => web_manifest.to_json
|
15
13
|
)
|
16
14
|
end
|
17
15
|
|
@@ -163,13 +161,19 @@ module LinkedRails
|
|
163
161
|
|
164
162
|
class << self
|
165
163
|
def destroy(iri)
|
166
|
-
Storage.hdel(:persistent, :manifest, iri)
|
164
|
+
Storage.hdel(:persistent, :manifest, URL.as_href(iri))
|
167
165
|
end
|
168
166
|
|
169
167
|
def move(from, to)
|
170
|
-
|
168
|
+
Storage.hset(
|
169
|
+
:persistent,
|
170
|
+
:redirect_prefix,
|
171
|
+
URL.as_href(from) => URL.as_href(to)
|
172
|
+
)
|
171
173
|
|
172
|
-
Storage.
|
174
|
+
data = Storage.hget(:persistent, :manifest, URL.as_href(from))
|
175
|
+
|
176
|
+
Storage.hset(:persistent, :manifest, URL.as_href(to), data) if data
|
173
177
|
|
174
178
|
destroy(from)
|
175
179
|
end
|
@@ -17,8 +17,6 @@ module LinkedRails
|
|
17
17
|
true
|
18
18
|
end
|
19
19
|
|
20
|
-
private
|
21
|
-
|
22
20
|
def publish_create
|
23
21
|
publish_message('io.ontola.transactions.Created')
|
24
22
|
end
|
@@ -31,14 +29,14 @@ module LinkedRails
|
|
31
29
|
publish_message('io.ontola.transactions.Deleted')
|
32
30
|
end
|
33
31
|
|
32
|
+
private
|
33
|
+
|
34
34
|
def publish_message(type)
|
35
35
|
LinkedRails::InvalidationStreamWorker.perform_now(type, iri.to_s, self.class.iri.to_s)
|
36
36
|
rescue StandardError
|
37
37
|
LinkedRails::InvalidationStreamWorker.perform_later(type, iri.to_s, self.class.iri.to_s)
|
38
38
|
end
|
39
39
|
|
40
|
-
private
|
41
|
-
|
42
40
|
def should_publish_changes
|
43
41
|
cacheable? && !Rails.env.test?
|
44
42
|
end
|
data/lib/linked_rails/storage.rb
CHANGED
@@ -4,26 +4,27 @@ require 'redis'
|
|
4
4
|
|
5
5
|
module LinkedRails
|
6
6
|
class Storage
|
7
|
-
|
8
|
-
cache:
|
9
|
-
persistent:
|
10
|
-
stream:
|
7
|
+
REDIS_DB = {
|
8
|
+
cache: LinkedRails.cache_redis_database,
|
9
|
+
persistent: LinkedRails.persistent_redis_database,
|
10
|
+
stream: LinkedRails.stream_redis_database
|
11
11
|
}.freeze
|
12
12
|
KEYS = {
|
13
13
|
manifest: 'cache:Manifest',
|
14
|
-
|
14
|
+
redirect_exact: 'cache:Redirect:Exact',
|
15
|
+
redirect_prefix: 'cache:Redirect:Prefix'
|
15
16
|
}.freeze
|
16
17
|
|
17
18
|
class << self
|
18
19
|
%i[xadd].each do |method|
|
19
20
|
define_method(method) do |db, *args|
|
20
|
-
|
21
|
+
Redis.new(db: REDIS_DB.fetch(db)).send(method, *args)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
25
|
%i[hset hdel hget].each do |method|
|
25
26
|
define_method(method) do |db, key, *args|
|
26
|
-
|
27
|
+
Redis.new(db: REDIS_DB.fetch(db)).send(method, KEYS.fetch(key), *args)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
data/lib/linked_rails.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linked_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.pre.
|
4
|
+
version: 0.0.4.pre.g7123943aa
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Dingemans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_response
|
@@ -429,6 +429,7 @@ files:
|
|
429
429
|
- lib/linked_rails/translate.rb
|
430
430
|
- lib/linked_rails/types/iri_type.rb
|
431
431
|
- lib/linked_rails/uri_template.rb
|
432
|
+
- lib/linked_rails/url.rb
|
432
433
|
- lib/linked_rails/version.rb
|
433
434
|
- lib/linked_rails/vocab.rb
|
434
435
|
- lib/nill_class_renderer.rb
|