futurism 0.5.2 → 0.5.4
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/README.md +10 -0
- data/lib/futurism.rb +2 -0
- data/lib/futurism.rb~ +12 -1
- data/lib/futurism/helpers.rb +8 -0
- data/lib/futurism/helpers.rb~ +13 -2
- data/lib/futurism/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e79c03c8d157585784ab3e4f48d2660100acad4e317aa378cdfa94a0c5a3fb9
|
4
|
+
data.tar.gz: 5036367ba790b660ef6230e6155192cfedd65973fa65e00fd7b53f071f8a6ae8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf2acd22c20fd40897b6caed2ad897eec3cc98f7ea1fbd9ab31ea19cf276cfa2f94f04ef87a16fe8c68ec03dab1e4e5832a1f4026fe269c58b8114dd1aecb54a
|
7
|
+
data.tar.gz: bda0591fb9174ebd6499839be5bfdb8512d8c7c110b9af837f6d8425eb6e9180384234fd493df1945fe51c021c2a0ab0e8ee5537238babd00617ca9bf4a16d8b
|
data/README.md
CHANGED
@@ -25,6 +25,7 @@ Lazy-load Rails partials via CableReady
|
|
25
25
|
- [Installation](#installation)
|
26
26
|
- [Manual Installation](#manual-installation)
|
27
27
|
- [Authentication](#authentication)
|
28
|
+
- [Testing](#testing)
|
28
29
|
- [Gotchas](#gotchas)
|
29
30
|
- [Contributing](#contributing)
|
30
31
|
- [License](#license)
|
@@ -213,6 +214,15 @@ end
|
|
213
214
|
|
214
215
|
The [Stimulus Reflex Docs](https://docs.stimulusreflex.com/authentication) have an excellent section about all sorts of authentication.
|
215
216
|
|
217
|
+
## Testing
|
218
|
+
In Rails system tests there is a chance that flaky errors will occur due to Capybara not waiting for the placeholder elements to be replaced. To overcome this, add the flag
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
Futurism.skip_in_test = true
|
222
|
+
```
|
223
|
+
|
224
|
+
to an initializer, for example `config/initializers/futurism.rb`.
|
225
|
+
|
216
226
|
## Gotchas
|
217
227
|
|
218
228
|
### ActiveStorage URLs aren't correct in development
|
data/lib/futurism.rb
CHANGED
data/lib/futurism.rb~
CHANGED
@@ -1,5 +1,16 @@
|
|
1
|
+
require "rails"
|
2
|
+
require "action_cable"
|
3
|
+
require "cable_ready"
|
1
4
|
require "futurism/engine"
|
5
|
+
require "futurism/channel"
|
6
|
+
require "futurism/helpers"
|
2
7
|
|
3
8
|
module Futurism
|
4
|
-
|
9
|
+
extend ActiveSupport::Autoload
|
10
|
+
|
11
|
+
autoload :Helpers, "futurism/helpers"
|
12
|
+
|
13
|
+
ActiveSupport.on_load(:action_view) {
|
14
|
+
include Futurism::Helpers
|
15
|
+
}
|
5
16
|
end
|
data/lib/futurism/helpers.rb
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
module Futurism
|
2
2
|
module Helpers
|
3
3
|
def futurize(records_or_string = nil, extends:, **options, &block)
|
4
|
+
if Rails.env.test? && Futurism.skip_in_test
|
5
|
+
if records_or_string.nil?
|
6
|
+
return render **options
|
7
|
+
else
|
8
|
+
return render records_or_string, **options
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
4
12
|
placeholder = capture(&block)
|
5
13
|
|
6
14
|
if records_or_string.is_a?(ActiveRecord::Base) || records_or_string.is_a?(ActiveRecord::Relation)
|
data/lib/futurism/helpers.rb~
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
module Futurism
|
2
2
|
module Helpers
|
3
3
|
def futurize(records_or_string = nil, extends:, **options, &block)
|
4
|
+
if Rails.env.test? && Futurism.skip_in_test
|
5
|
+
if records_or_string.nil?
|
6
|
+
render options
|
7
|
+
else
|
8
|
+
render records_or_string, options
|
9
|
+
end
|
10
|
+
return
|
11
|
+
end
|
12
|
+
|
4
13
|
placeholder = capture(&block)
|
5
14
|
|
6
15
|
if records_or_string.is_a?(ActiveRecord::Base) || records_or_string.is_a?(ActiveRecord::Relation)
|
@@ -36,11 +45,12 @@ module Futurism
|
|
36
45
|
class Element
|
37
46
|
include ActionView::Helpers
|
38
47
|
|
39
|
-
attr_reader :extends, :placeholder, :html_options, :data_attributes, :model, :options
|
48
|
+
attr_reader :extends, :placeholder, :html_options, :data_attributes, :model, :options, :eager
|
40
49
|
|
41
50
|
def initialize(extends:, placeholder:, options:)
|
42
51
|
@extends = extends
|
43
52
|
@placeholder = placeholder
|
53
|
+
@eager = options.delete(:eager)
|
44
54
|
@html_options = options.delete(:html_options) || {}
|
45
55
|
@data_attributes = html_options.fetch(:data, {}).except(:sgid, :signed_params)
|
46
56
|
@model = options.delete(:model)
|
@@ -50,7 +60,8 @@ module Futurism
|
|
50
60
|
def dataset
|
51
61
|
data_attributes.merge({
|
52
62
|
signed_params: signed_params,
|
53
|
-
sgid: model && model.to_sgid.to_s
|
63
|
+
sgid: model && model.to_sgid.to_s,
|
64
|
+
eager: eager.presence
|
54
65
|
})
|
55
66
|
end
|
56
67
|
|
data/lib/futurism/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: futurism
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Rubisch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appraisal
|