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: 81257133691833969ac9f77447b91d2698aa0738964b56f80e8533dd403e90d1
4
- data.tar.gz: 424597dcc95a76513d70226d82aafbea7baf614dcc7c5ee55c405e2dc75d4337
3
+ metadata.gz: 3fd731fc709f8ecfcd4ee730a6bc52e693bdd5f160ba00ad4cb5a50978c8a735
4
+ data.tar.gz: 20b9b0b06f31eace48c3ababb1c4cbbbc6d2a8143bc29677957305c4ce4dfe23
5
5
  SHA512:
6
- metadata.gz: 23e37d1e5e4271c0f0a13f8e0aa495473b55164b855b58df1638de5fc88f50e00499a4726908f1bb59856075833ab275fa3a893233fc484ff6c839fd42f023b0
7
- data.tar.gz: 139b207faa2d1f6a3ae44ddff0421d4572f7b93aab04c2fc63bd6136e05faa72886d639ac023c0009af0934a74d8c70b79d7ce23876903706dd9702c04fb5f8a
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 :config, :store, :model_namespace
42
+ attr_accessor :configuration, :store, :model_namespace
43
43
 
44
- def initialize(document, config: nil, store: nil, model_namespace: nil)
44
+ def initialize(document, configuration: nil, store: nil, model_namespace: nil)
45
45
  @document = document
46
- @config = config if config.present?
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 config&.app_url.present?
277
+ if configuration&.app_url.present?
278
278
  begin
279
- URI(config.app_url)
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
- store = self.store
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.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module WCC
4
4
  module Contentful
5
- VERSION = '1.5.0.rc1'
5
+ VERSION = '1.5.0'
6
6
  end
7
7
  end
@@ -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.rc1
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-07 00:00:00.000000000 Z
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: 1.3.1
517
+ version: '0'
517
518
  requirements: []
518
519
  rubygems_version: 3.3.7
519
520
  signing_key: