futurism 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -17
- data/lib/futurism.rb +1 -0
- data/lib/futurism/channel.rb +2 -24
- data/lib/futurism/channel.rb~ +5 -1
- data/lib/futurism/helpers.rb +1 -1
- data/lib/futurism/resolver/resources.rb +68 -0
- data/lib/futurism/resolver/resources.rb~ +73 -0
- data/lib/futurism/version.rb +1 -1
- data/lib/futurism/version.rb~ +3 -0
- metadata +5 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75dd023300659792f3dd9e114727b0003204ed6b2e9e990413fcc1ca82971fba
|
4
|
+
data.tar.gz: b73280cb140625612fc5e7188e301f98e5be0eb19e7359c7786fae8b4a8f4b8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9285da73bb00137f7aea08b2171d370b032681abd79b8d37e652b1aef546159a2d568ecc695ecaeb0a7f3a8f4a74abb0a6a310dca9969021923d4590c0fd03b
|
7
|
+
data.tar.gz: ae425d91dcae19d847105b5633a0f0b434166d5cb45f9aed14bfccb2a07cc9661594c2a814d072b541b30d7b401c6273919e6c199ffcdb38c146d6fc8f8a6a74
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Futurism
|
2
2
|
[![Twitter follow](https://img.shields.io/twitter/follow/julian_rubisch?style=social)](https://twitter.com/julian_rubisch)
|
3
3
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
4
|
-
[![All Contributors](https://img.shields.io/badge/all_contributors-
|
4
|
+
[![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-)
|
5
5
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
6
6
|
Lazy-load Rails partials via CableReady
|
7
7
|
|
@@ -33,7 +33,7 @@ Lazy-load Rails partials via CableReady
|
|
33
33
|
|
34
34
|
## Facts
|
35
35
|
- only one dependency: CableReady
|
36
|
-
- bundle size (without CableReady) is around [~
|
36
|
+
- bundle size (without CableReady) is around [~2.46kB](https://bundlephobia.com/result?p=@minthesize/futurism@0.7.2)
|
37
37
|
|
38
38
|
### Browser Support
|
39
39
|
|
@@ -302,27 +302,31 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
302
302
|
<!-- markdownlint-disable -->
|
303
303
|
<table>
|
304
304
|
<tr>
|
305
|
-
<td align="center"><a href="http://www.julianrubisch.at"><img src="https://avatars0.githubusercontent.com/u/4352208?v=4" width="100px;" alt=""/><br /><sub><b>Julian Rubisch</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=julianrubisch" title="Code">💻</a></td>
|
306
|
-
<td align="center"><a href="https://github.com/darkrubyist"><img src="https://avatars2.githubusercontent.com/u/11207292?v=4" width="100px;" alt=""/><br /><sub><b>darkrubyist</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=darkrubyist" title="Code">💻</a> <a href="https://github.com/julianrubisch/futurism/commits?author=darkrubyist" title="Documentation">📖</a></td>
|
307
|
-
<td align="center"><a href="https://ParamagicDev.github.io/portfolio"><img src="https://avatars2.githubusercontent.com/u/26425882?v=4" width="100px;" alt=""/><br /><sub><b>Konnor Rogers</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=ParamagicDev" title="Code">💻</a></td>
|
308
|
-
<td align="center"><a href="https://www.andrewm.codes"><img src="https://avatars1.githubusercontent.com/u/18423853?v=4" width="100px;" alt=""/><br /><sub><b>Andrew Mason</b></sub></a><br /><a href="#maintenance-andrewmcodes" title="Maintenance">🚧</a></td>
|
309
|
-
<td align="center"><a href="http://gorails.com"><img src="https://avatars1.githubusercontent.com/u/67093?v=4" width="100px;" alt=""/><br /><sub><b>Chris Oliver</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=excid3" title="Code">💻</a> <a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Aexcid3" title="Reviewed Pull Requests">👀</a></td>
|
310
|
-
<td align="center"><a href="https://github.com/leastbad"><img src="https://avatars2.githubusercontent.com/u/38150464?v=4" width="100px;" alt=""/><br /><sub><b>leastbad</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=leastbad" title="Code">💻</a> <a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Aleastbad" title="Reviewed Pull Requests">👀</a></td>
|
311
|
-
<td align="center"><a href="http://code.digimonkey.com"><img src="https://avatars0.githubusercontent.com/u/74207?v=4" width="100px;" alt=""/><br /><sub><b>M. E. Patterson</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/issues?q=author%3Amepatterson" title="Bug reports">🐛</a></td>
|
305
|
+
<td align="center"><a href="http://www.julianrubisch.at"><img src="https://avatars0.githubusercontent.com/u/4352208?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Julian Rubisch</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=julianrubisch" title="Code">💻</a></td>
|
306
|
+
<td align="center"><a href="https://github.com/darkrubyist"><img src="https://avatars2.githubusercontent.com/u/11207292?v=4?s=100" width="100px;" alt=""/><br /><sub><b>darkrubyist</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=darkrubyist" title="Code">💻</a> <a href="https://github.com/julianrubisch/futurism/commits?author=darkrubyist" title="Documentation">📖</a></td>
|
307
|
+
<td align="center"><a href="https://ParamagicDev.github.io/portfolio"><img src="https://avatars2.githubusercontent.com/u/26425882?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Konnor Rogers</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=ParamagicDev" title="Code">💻</a></td>
|
308
|
+
<td align="center"><a href="https://www.andrewm.codes"><img src="https://avatars1.githubusercontent.com/u/18423853?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andrew Mason</b></sub></a><br /><a href="#maintenance-andrewmcodes" title="Maintenance">🚧</a></td>
|
309
|
+
<td align="center"><a href="http://gorails.com"><img src="https://avatars1.githubusercontent.com/u/67093?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Chris Oliver</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=excid3" title="Code">💻</a> <a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Aexcid3" title="Reviewed Pull Requests">👀</a></td>
|
310
|
+
<td align="center"><a href="https://github.com/leastbad"><img src="https://avatars2.githubusercontent.com/u/38150464?v=4?s=100" width="100px;" alt=""/><br /><sub><b>leastbad</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=leastbad" title="Code">💻</a> <a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Aleastbad" title="Reviewed Pull Requests">👀</a></td>
|
311
|
+
<td align="center"><a href="http://code.digimonkey.com"><img src="https://avatars0.githubusercontent.com/u/74207?v=4?s=100" width="100px;" alt=""/><br /><sub><b>M. E. Patterson</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/issues?q=author%3Amepatterson" title="Bug reports">🐛</a></td>
|
312
312
|
</tr>
|
313
313
|
<tr>
|
314
|
-
<td align="center"><a href="http://fractaledmind.com"><img src="https://avatars3.githubusercontent.com/u/5077225?v=4" width="100px;" alt=""/><br /><sub><b>Stephen Margheim</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=fractaledmind" title="Code">💻</a></td>
|
315
|
-
<td align="center"><a href="http://hass.codes"><img src="https://avatars2.githubusercontent.com/u/1064205?v=4" width="100px;" alt=""/><br /><sub><b>Hassanin Ahmed</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=sas1ni69" title="Code">💻</a></td>
|
316
|
-
<td align="center"><a href="https://marcoroth.dev"><img src="https://avatars2.githubusercontent.com/u/6411752?v=4" width="100px;" alt=""/><br /><sub><b>Marco Roth</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=marcoroth" title="Code">💻</a></td>
|
317
|
-
<td align="center"><a href="https://viedit.com"><img src="https://avatars1.githubusercontent.com/u/49990587?v=4" width="100px;" alt=""/><br /><sub><b>Viedit com</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=vieditcom" title="Documentation">📖</a></td>
|
318
|
-
<td align="center"><a href="http://scottbarrow.ca"><img src="https://avatars2.githubusercontent.com/u/5571736?v=4" width="100px;" alt=""/><br /><sub><b>Scott Barrow</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=scottbarrow" title="Code">💻</a></td>
|
319
|
-
<td align="center"><a href="http://domchristie.co.uk"><img src="https://avatars0.githubusercontent.com/u/111734?v=4" width="100px;" alt=""/><br /><sub><b>Dom Christie</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Adomchristie" title="Reviewed Pull Requests">👀</a></td>
|
320
|
-
<td align="center"><a href="http://www.rickychilcott.com"><img src="https://avatars1.githubusercontent.com/u/445759?v=4" width="100px;" alt=""/><br /><sub><b>Ricky Chilcott</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Arickychilcott" title="Reviewed Pull Requests">👀</a></td>
|
314
|
+
<td align="center"><a href="http://fractaledmind.com"><img src="https://avatars3.githubusercontent.com/u/5077225?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephen Margheim</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=fractaledmind" title="Code">💻</a></td>
|
315
|
+
<td align="center"><a href="http://hass.codes"><img src="https://avatars2.githubusercontent.com/u/1064205?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hassanin Ahmed</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=sas1ni69" title="Code">💻</a></td>
|
316
|
+
<td align="center"><a href="https://marcoroth.dev"><img src="https://avatars2.githubusercontent.com/u/6411752?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Marco Roth</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=marcoroth" title="Code">💻</a></td>
|
317
|
+
<td align="center"><a href="https://viedit.com"><img src="https://avatars1.githubusercontent.com/u/49990587?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Viedit com</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=vieditcom" title="Documentation">📖</a></td>
|
318
|
+
<td align="center"><a href="http://scottbarrow.ca"><img src="https://avatars2.githubusercontent.com/u/5571736?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Scott Barrow</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=scottbarrow" title="Code">💻</a></td>
|
319
|
+
<td align="center"><a href="http://domchristie.co.uk"><img src="https://avatars0.githubusercontent.com/u/111734?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Dom Christie</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Adomchristie" title="Reviewed Pull Requests">👀</a></td>
|
320
|
+
<td align="center"><a href="http://www.rickychilcott.com"><img src="https://avatars1.githubusercontent.com/u/445759?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ricky Chilcott</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/pulls?q=is%3Apr+reviewed-by%3Arickychilcott" title="Reviewed Pull Requests">👀</a></td>
|
321
|
+
</tr>
|
322
|
+
<tr>
|
323
|
+
<td align="center"><a href="https://github.com/mansakondo"><img src="https://avatars.githubusercontent.com/u/47113995?v=4?s=100" width="100px;" alt=""/><br /><sub><b>mansakondo</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=mansakondo" title="Code">💻</a></td>
|
321
324
|
</tr>
|
322
325
|
</table>
|
323
326
|
|
324
|
-
<!-- markdownlint-
|
327
|
+
<!-- markdownlint-restore -->
|
325
328
|
<!-- prettier-ignore-end -->
|
329
|
+
|
326
330
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
327
331
|
|
328
332
|
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
|
data/lib/futurism.rb
CHANGED
@@ -3,6 +3,7 @@ require "action_cable"
|
|
3
3
|
require "cable_ready"
|
4
4
|
require "futurism/engine"
|
5
5
|
require "futurism/message_verifier"
|
6
|
+
require "futurism/resolver/resources"
|
6
7
|
require "futurism/resolver/controller"
|
7
8
|
require "futurism/resolver/controller/renderer"
|
8
9
|
require "futurism/channel"
|
data/lib/futurism/channel.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Futurism
|
2
2
|
class Channel < ActionCable::Channel::Base
|
3
3
|
include CableReady::Broadcaster
|
4
|
-
include Futurism::MessageVerifier
|
5
4
|
|
6
5
|
def stream_name
|
7
6
|
ids = connection.identifiers.map { |identifier| send(identifier).try(:id) || send(identifier) }
|
@@ -18,19 +17,8 @@ module Futurism
|
|
18
17
|
def receive(data)
|
19
18
|
resources = data.fetch_values("signed_params", "sgids", "signed_controllers", "urls") { |_key| Array.new(data["signed_params"].length, nil) }.transpose
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
selector << "[data-sgid='#{sgid}']" if sgid.present?
|
24
|
-
|
25
|
-
controller = Resolver::Controller.from(signed_string: signed_controller)
|
26
|
-
renderer = Resolver::Controller::Renderer.for(controller: controller,
|
27
|
-
connection: connection,
|
28
|
-
url: url,
|
29
|
-
params: @params)
|
30
|
-
|
31
|
-
resource = lookup_resource(signed_params: signed_params, sgid: sgid)
|
32
|
-
html = renderer.render(resource)
|
33
|
-
|
20
|
+
resolver = Resolver::Resources.new(resource_definitions: resources, connection: connection, params: @params)
|
21
|
+
resolver.resolve do |selector, html|
|
34
22
|
cable_ready[stream_name].outer_html(
|
35
23
|
selector: selector,
|
36
24
|
html: html
|
@@ -39,15 +27,5 @@ module Futurism
|
|
39
27
|
|
40
28
|
cable_ready.broadcast
|
41
29
|
end
|
42
|
-
|
43
|
-
private
|
44
|
-
|
45
|
-
def lookup_resource(signed_params:, sgid:)
|
46
|
-
return GlobalID::Locator.locate_signed(sgid) if sgid.present?
|
47
|
-
|
48
|
-
message_verifier
|
49
|
-
.verify(signed_params)
|
50
|
-
.deep_transform_values { |value| value.is_a?(String) && value.start_with?("gid://") ? GlobalID::Locator.locate(value) : value }
|
51
|
-
end
|
52
30
|
end
|
53
31
|
end
|
data/lib/futurism/channel.rb~
CHANGED
@@ -18,7 +18,11 @@ module Futurism
|
|
18
18
|
def receive(data)
|
19
19
|
resources = data.fetch_values("signed_params", "sgids", "signed_controllers", "urls") { |_key| Array.new(data["signed_params"].length, nil) }.transpose
|
20
20
|
|
21
|
-
resources.
|
21
|
+
resources_with_sgids, resources_without_sgids = resources.partition { |signed_params, sgid, *| sgid.present? }
|
22
|
+
|
23
|
+
GlobalID::Locator.locate_many_signed resources_with_sgids.map(&:second)
|
24
|
+
|
25
|
+
resources_without_sgids.each do |signed_params, sgid, signed_controller, url|
|
22
26
|
selector = "[data-signed-params='#{signed_params}']"
|
23
27
|
selector << "[data-sgid='#{sgid}']" if sgid.present?
|
24
28
|
|
data/lib/futurism/helpers.rb
CHANGED
@@ -26,7 +26,7 @@ module Futurism
|
|
26
26
|
if collection.nil?
|
27
27
|
Element.new(extends: extends, placeholder: placeholder, options: options).render
|
28
28
|
else
|
29
|
-
collection_class_name = collection.klass.name
|
29
|
+
collection_class_name = collection.try(:klass).try(:name) || collection.first.class.to_s
|
30
30
|
as = options.delete(:as) || collection_class_name.downcase
|
31
31
|
collection.each_with_index.map { |record, index|
|
32
32
|
Element.new(extends: extends, placeholder: placeholder, options: options.deep_merge(locals: {as.to_sym => record, "#{as}_counter".to_sym => index})).render
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Futurism
|
2
|
+
module Resolver
|
3
|
+
class Resources
|
4
|
+
include Futurism::MessageVerifier
|
5
|
+
|
6
|
+
# resource definitions are an array of [signed_params, sgid, signed_controller, url]
|
7
|
+
def initialize(resource_definitions:, connection:, params:)
|
8
|
+
@connection = connection
|
9
|
+
@params = params
|
10
|
+
@resources_with_sgids, @resources_without_sgids = resource_definitions
|
11
|
+
.partition { |signed_params, sgid, *| sgid.present? }
|
12
|
+
.map { |partition| partition.map { |definition| ResourceDefinition.new(definition) } }
|
13
|
+
end
|
14
|
+
|
15
|
+
def resolve
|
16
|
+
resolved_models.zip(@resources_with_sgids).each do |model, resource_definition|
|
17
|
+
html = renderer_for(resource_definition: resource_definition).render(model)
|
18
|
+
|
19
|
+
yield(resource_definition.selector, html)
|
20
|
+
end
|
21
|
+
|
22
|
+
@resources_without_sgids.each do |resource_definition|
|
23
|
+
resource = lookup_resource(resource_definition)
|
24
|
+
html = renderer_for(resource_definition: resource_definition).render(resource)
|
25
|
+
|
26
|
+
yield(resource_definition.selector, html)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
class ResourceDefinition
|
33
|
+
attr_reader :signed_params, :sgid, :signed_controller, :url
|
34
|
+
|
35
|
+
def initialize(resource_definition)
|
36
|
+
@signed_params, @sgid, @signed_controller, @url = resource_definition
|
37
|
+
end
|
38
|
+
|
39
|
+
def selector
|
40
|
+
selector = "[data-signed-params='#{@signed_params}']"
|
41
|
+
selector << "[data-sgid='#{@sgid}']" if @sgid.present?
|
42
|
+
selector
|
43
|
+
end
|
44
|
+
|
45
|
+
def controller
|
46
|
+
Resolver::Controller.from(signed_string: @signed_controller)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def renderer_for(resource_definition:)
|
51
|
+
Resolver::Controller::Renderer.for(controller: resource_definition.controller,
|
52
|
+
connection: @connection,
|
53
|
+
url: resource_definition.url,
|
54
|
+
params: @params)
|
55
|
+
end
|
56
|
+
|
57
|
+
def resolved_models
|
58
|
+
GlobalID::Locator.locate_many_signed @resources_with_sgids.map(&:sgid)
|
59
|
+
end
|
60
|
+
|
61
|
+
def lookup_resource(resource_definition)
|
62
|
+
message_verifier
|
63
|
+
.verify(resource_definition.signed_params)
|
64
|
+
.deep_transform_values { |value| value.is_a?(String) && value.start_with?("gid://") ? GlobalID::Locator.locate(value) : value }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Futurism
|
2
|
+
module Resolver
|
3
|
+
class Resources
|
4
|
+
include Futurism::MessageVerifier
|
5
|
+
|
6
|
+
# resource definitions are an array of [signed_params, sgid, signed_controller, url]
|
7
|
+
def initialize(resource_definitions:, connection:, params:)
|
8
|
+
@connection = connection
|
9
|
+
@params = params
|
10
|
+
@resources_with_sgids, @resources_without_sgids = resource_definitions
|
11
|
+
.partition { |signed_params, sgid, *| sgid.present? }
|
12
|
+
.map { |definition| ResourceDefinition.new(definition) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def resolve
|
16
|
+
resolved_models.zip(@resources_with_sgids).each do |model, resource_definition|
|
17
|
+
signed_params, sgid, signed_controller, url = resource_definition
|
18
|
+
|
19
|
+
selector = selector_for(signed_params: signed_params, sgid: sgid)
|
20
|
+
|
21
|
+
controller = Resolver::Controller.from(signed_string: signed_controller)
|
22
|
+
renderer = Resolver::Controller::Renderer.for(controller: controller,
|
23
|
+
connection: @connection,
|
24
|
+
url: url,
|
25
|
+
params: @params)
|
26
|
+
|
27
|
+
html = renderer.render(model)
|
28
|
+
|
29
|
+
yield(selector, html)
|
30
|
+
end
|
31
|
+
|
32
|
+
@resources_without_sgids.each do |signed_params, sgid, signed_controller, url|
|
33
|
+
selector = selector_for(signed_params: signed_params, sgid: sgid)
|
34
|
+
|
35
|
+
controller = Resolver::Controller.from(signed_string: signed_controller)
|
36
|
+
renderer = Resolver::Controller::Renderer.for(controller: controller,
|
37
|
+
connection: @connection,
|
38
|
+
url: url,
|
39
|
+
params: @params)
|
40
|
+
|
41
|
+
resource = lookup_resource(signed_params: signed_params)
|
42
|
+
html = renderer.render(resource)
|
43
|
+
|
44
|
+
yield(selector, html)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
class ResourceDefinition
|
51
|
+
def initialize(resource_definition)
|
52
|
+
@signed_params, @sgid, @signed_controller, @url = resource_definition
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def resolved_models
|
57
|
+
GlobalID::Locator.locate_many_signed @resources_with_sgids.map(&:second)
|
58
|
+
end
|
59
|
+
|
60
|
+
def lookup_resource(signed_params:)
|
61
|
+
message_verifier
|
62
|
+
.verify(signed_params)
|
63
|
+
.deep_transform_values { |value| value.is_a?(String) && value.start_with?("gid://") ? GlobalID::Locator.locate(value) : value }
|
64
|
+
end
|
65
|
+
|
66
|
+
def selector_for(signed_params:, sgid:)
|
67
|
+
selector = "[data-signed-params='#{signed_params}']"
|
68
|
+
selector << "[data-sgid='#{sgid}']" if sgid.present?
|
69
|
+
selector
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/futurism/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: futurism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Rubisch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: appraisal
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,8 +160,11 @@ files:
|
|
174
160
|
- lib/futurism/resolver/controller.rb~
|
175
161
|
- lib/futurism/resolver/controller/renderer.rb
|
176
162
|
- lib/futurism/resolver/controller/renderer.rb~
|
163
|
+
- lib/futurism/resolver/resources.rb
|
164
|
+
- lib/futurism/resolver/resources.rb~
|
177
165
|
- lib/futurism/shims/deep_transform_values.rb
|
178
166
|
- lib/futurism/version.rb
|
167
|
+
- lib/futurism/version.rb~
|
179
168
|
- lib/tasks/futurism_tasks.rake
|
180
169
|
- lib/tasks/futurism_tasks.rake~
|
181
170
|
homepage: https://github.com/julianrubisch/futurism
|