editmode 0.0.10.15 → 0.0.10.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: feb3922328fd985e4aec3156ba98021dbd194c3fdf58a9b51b63de2b7f7dc535
4
- data.tar.gz: f52847ef24647300e4bde80f71a90f557e67e7caa40b55ded07fe1276ca759e2
3
+ metadata.gz: 6436b313b030cf81d23b8272298001445eb96fe03cdece2493ab493b7b03353b
4
+ data.tar.gz: d277cd2ca885fd8e082f17cde5afaab63db7cef4e67a7f131785a29d0c013006
5
5
  SHA512:
6
- metadata.gz: 573b7952ccdb805057e3cdeffe11f9d19af12fc578d166916a95f14e0d3508b868b8c4f37348a2550bc1563abba2bd218b53d416f628c9422a19db6c08e656c2
7
- data.tar.gz: 3a690c5d2a0427596f29fdf1154f1715da067611c27ad95dbe86a8ef4c5a296e5cbc6c96e170ce0442f9f32c9fea835233ab276a5cc28be98e7f7caa2e84c8ee
6
+ metadata.gz: 920b13e489ef97f223550ec25d9fe0ee6015d97cd442c448317a01ecc4d11d3c22c5bb56ae89c2e107978d4fe570385c81fb97515dcded68c70f5767808e214f
7
+ data.tar.gz: a1c1d9d60c1bfbe1f8b6bccf715aca23d03fcf14a60e3eeeb55c88a34e1110ed65f4affb37bd12d8cbdfcefd18e05f2709f744555eec7ded5bbce89a0a14f1ba
@@ -33,7 +33,6 @@ module Editmode
33
33
 
34
34
  def chunk_value(identifier, **options)
35
35
  begin
36
- options.merge!(project_id: project_id)
37
36
  Editmode::ChunkValue.new(identifier, **options )
38
37
  rescue => er
39
38
  raise er
@@ -4,12 +4,11 @@ module Editmode
4
4
 
5
5
  attr_accessor :identifier, :variable_values, :branch_id,
6
6
  :variable_fallbacks, :chunk_type, :project_id,
7
- :content
7
+ :response, :content
8
8
 
9
9
  def initialize(identifier, **options)
10
10
  @identifier = identifier
11
11
  @branch_id = options[:branch_id].presence
12
- @project_id = options[:project_id].presence
13
12
  @variable_values = options[:values].presence || {}
14
13
  get_content
15
14
  end
@@ -18,7 +17,8 @@ module Editmode
18
17
  # Field ID can be a slug or field_name
19
18
  if chunk_type == 'collection_item'
20
19
  if field.present?
21
- field_content = content.detect {|f| f["custom_field_identifier"] == field || f["custom_field_name"] == field }
20
+ field.downcase!
21
+ field_content = content.detect {|f| f["custom_field_identifier"].downcase == field || f["custom_field_name"].downcase == field }
22
22
  if field_content.present?
23
23
  result = field_content['content']
24
24
  result = variable_parse!(result, variable_fallbacks, variable_values)
@@ -39,28 +39,24 @@ module Editmode
39
39
  branch_params = branch_id.present? ? "branch_id=#{branch_id}" : ""
40
40
  url = "#{api_root_url}/chunks/#{identifier}?#{branch_params}"
41
41
 
42
- cache_identifier = "chunk_#{identifier}#{branch_id}"
42
+ cache_identifier = "chunk_value_#{identifier}#{branch_id}"
43
43
  cached_content_present = Rails.cache.exist?(cache_identifier)
44
- cached_content_present = Rails.cache.exist?("chunk_#{project_id}_variables") if cached_content_present
45
44
 
46
45
  if !cached_content_present
47
- response = HTTParty.get(url)
48
- response_received = true if response.code == 200
46
+ http_response = HTTParty.get(url)
47
+ response_received = true if http_response.code == 200
49
48
  end
50
49
 
51
50
  if !cached_content_present && !response_received
52
51
  raise no_response_received(identifier)
53
52
  else
54
- @content = Rails.cache.fetch(cache_identifier) do
55
- response['content']
53
+ @response = Rails.cache.fetch(cache_identifier) do
54
+ http_response
56
55
  end
57
56
 
58
- @chunk_type = Rails.cache.fetch("#{cache_identifier}_type") do
59
- response['chunk_type']
60
- end
61
-
62
- # Since variables are defined in the project level,
63
- # We use project_id as cache identifier
57
+ @content = response['content']
58
+ @chunk_type = response['chunk_type']
59
+ @project_id = response['project_id']
64
60
  @variable_fallbacks = Rails.cache.fetch("chunk_#{project_id}_variables") do
65
61
  response['variable_fallbacks']
66
62
  end
@@ -1,3 +1,3 @@
1
1
  module Editmode
2
- VERSION = "0.0.10.15"
2
+ VERSION = "0.0.10.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: editmode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10.15
4
+ version: 0.0.10.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Ennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-30 00:00:00.000000000 Z
11
+ date: 2020-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler