wcc-contentful 1.5.0.rc1 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fd731fc709f8ecfcd4ee730a6bc52e693bdd5f160ba00ad4cb5a50978c8a735
|
4
|
+
data.tar.gz: 20b9b0b06f31eace48c3ababb1c4cbbbc6d2a8143bc29677957305c4ce4dfe23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d2200e5b8bbb1c4a1b52a9163fa06c48d90049cc03715359610ab2e3b62d776635d174636b275188489da2cea857ca5a001426489513b15b2d31de749340b16
|
7
|
+
data.tar.gz: afb2143f431c139dabfa7139eedb27984f0846e6c377efb2cdea8d61336b1532e97ebba18483ea53ff7826e95b1304afeff99805c5ed750e37b93001cfb9067b
|
@@ -39,11 +39,11 @@ class WCC::Contentful::RichTextRenderer
|
|
39
39
|
end
|
40
40
|
|
41
41
|
attr_reader :document
|
42
|
-
attr_accessor :
|
42
|
+
attr_accessor :configuration, :store, :model_namespace
|
43
43
|
|
44
|
-
def initialize(document,
|
44
|
+
def initialize(document, configuration: nil, store: nil, model_namespace: nil)
|
45
45
|
@document = document
|
46
|
-
@
|
46
|
+
@configuration = configuration if configuration.present?
|
47
47
|
@store = store if store.present?
|
48
48
|
@model_namespace = model_namespace if model_namespace.present?
|
49
49
|
end
|
@@ -274,9 +274,9 @@ class WCC::Contentful::RichTextRenderer
|
|
274
274
|
return false unless uri&.host.present?
|
275
275
|
|
276
276
|
app_uri =
|
277
|
-
if
|
277
|
+
if configuration&.app_url.present?
|
278
278
|
begin
|
279
|
-
URI(
|
279
|
+
URI(configuration.app_url)
|
280
280
|
rescue StandardError
|
281
281
|
nil
|
282
282
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Constructs new connected RichTextRenderer instances w/ needed dependencies
|
4
|
+
class RichTextRendererFactory
|
5
|
+
def initialize(implementation_class, services: WCC::Contentful::Services.instance)
|
6
|
+
@implementation_class = implementation_class
|
7
|
+
@services = services
|
8
|
+
end
|
9
|
+
|
10
|
+
def new(document)
|
11
|
+
@implementation_class.new(document).tap do |renderer|
|
12
|
+
# Inject any dependencies that the renderer needs (except itself to avoid infinite recursion)
|
13
|
+
@services.inject_into(renderer, except: [:rich_text_renderer])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def call(document)
|
18
|
+
new(document).call
|
19
|
+
end
|
20
|
+
end
|
@@ -11,6 +11,10 @@ module WCC::Contentful
|
|
11
11
|
|
12
12
|
attr_reader :configuration
|
13
13
|
|
14
|
+
def model_namespace
|
15
|
+
@model_namespace || WCC::Contentful::Model
|
16
|
+
end
|
17
|
+
|
14
18
|
def initialize(configuration, model_namespace: nil)
|
15
19
|
raise ArgumentError, 'Not yet configured!' unless configuration
|
16
20
|
|
@@ -131,20 +135,7 @@ module WCC::Contentful
|
|
131
135
|
def rich_text_renderer
|
132
136
|
@rich_text_renderer ||=
|
133
137
|
if implementation_class = configuration&.rich_text_renderer
|
134
|
-
|
135
|
-
config = configuration
|
136
|
-
model_namespace = @model_namespace || WCC::Contentful::Model
|
137
|
-
|
138
|
-
# Wrap the implementation in a subclass that injects the services
|
139
|
-
Class.new(implementation_class) do
|
140
|
-
define_method :initialize do |document, *args, **kwargs|
|
141
|
-
# Implementation might choose to override these, so call super last
|
142
|
-
@store = store
|
143
|
-
@config = config
|
144
|
-
@model_namespace = model_namespace
|
145
|
-
super(document, *args, **kwargs)
|
146
|
-
end
|
147
|
-
end
|
138
|
+
RichTextRendererFactory.new(implementation_class, services: self)
|
148
139
|
else
|
149
140
|
# Create a renderer that renders a more helpful error message, but delay the error message until #to_html
|
150
141
|
# is actually invoked in case the user never actually uses the renderer.
|
data/lib/wcc/contentful.rb
CHANGED
@@ -22,6 +22,7 @@ require 'wcc/contentful/model_singleton_methods'
|
|
22
22
|
require 'wcc/contentful/model_builder'
|
23
23
|
require 'wcc/contentful/rich_text'
|
24
24
|
require 'wcc/contentful/rich_text_renderer'
|
25
|
+
require 'wcc/contentful/rich_text_renderer_factory'
|
25
26
|
require 'wcc/contentful/sync_engine'
|
26
27
|
require 'wcc/contentful/events'
|
27
28
|
require 'wcc/contentful/middleware'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wcc-contentful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.0
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Watermark Dev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -454,6 +454,7 @@ files:
|
|
454
454
|
- lib/wcc/contentful/rich_text.rb
|
455
455
|
- lib/wcc/contentful/rich_text/node.rb
|
456
456
|
- lib/wcc/contentful/rich_text_renderer.rb
|
457
|
+
- lib/wcc/contentful/rich_text_renderer_factory.rb
|
457
458
|
- lib/wcc/contentful/rspec.rb
|
458
459
|
- lib/wcc/contentful/services.rb
|
459
460
|
- lib/wcc/contentful/simple_client.rb
|
@@ -511,9 +512,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
511
512
|
version: '2.7'
|
512
513
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
513
514
|
requirements:
|
514
|
-
- - "
|
515
|
+
- - ">="
|
515
516
|
- !ruby/object:Gem::Version
|
516
|
-
version:
|
517
|
+
version: '0'
|
517
518
|
requirements: []
|
518
519
|
rubygems_version: 3.3.7
|
519
520
|
signing_key:
|