radiant-ecom_engine-extension 0.3.0.pre.alpha.1 → 0.3.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
  SHA1:
3
- metadata.gz: f6b44e0368dea7205db274f228dc6b7febd12d0c
4
- data.tar.gz: 69d00c0dd61b70e87fee61fdd5f919f863eb1027
3
+ metadata.gz: d35818d562cc2d698212d7093e6daf5a9ac2f23b
4
+ data.tar.gz: c4d962886d7aa23ea22001229b25194209656ac5
5
5
  SHA512:
6
- metadata.gz: 673c9b231b908ee4be9fe1fee4ecdd6d0f76cafc1c8038bdc5ad77fa90922db53ff4ebd49b16d0deda2ae89f8cd79dc8bdfc8e4bd6e13f80e7a6edc6caed56f2
7
- data.tar.gz: 343d56598449f1c96a0a38b892ac1a372ba8abc7b5574b31e2db31fdf8a82936d0b8f5e874ccecbbb11806724125047a7f67877a31c0ac74638ebfd560bd610b
6
+ metadata.gz: 4987b067628212066a4a17a7cbadc40846dcdee9408373c637464650bcec678c1da97a1a559e0c5353312d3201da4dc394333f2cfe2093052b65569242dc91da
7
+ data.tar.gz: 4dfc816b5268388f9d0521f4c035083cce15f9d86479eb7241cf0f95b45f5d6a4a2bec8f706c1d0eed3b8ee29ff8bd5ea80ae2b086610dcef2dc803ca5b582d9
data/CHANGELOG.md CHANGED
@@ -4,7 +4,7 @@
4
4
  +This changelog adheres to [Keep a
5
5
  CHANGELOG](http://keepachangelog.com/).
6
6
 
7
- ## 0.3.0-alpha.1
7
+ ## 0.3.0
8
8
 
9
9
  ### Added
10
10
  - [TT-1945] Add search routes
@@ -0,0 +1,2 @@
1
+ module EcomEngine
2
+ end
@@ -0,0 +1,59 @@
1
+ class EcomEngine::Version
2
+
3
+ def initialize(url)
4
+ @url = url
5
+ end
6
+
7
+ def value
8
+ return cache if cache_exists?
9
+ read_and_cache
10
+ end
11
+
12
+ private
13
+
14
+ def read_and_cache
15
+ read.tap { |value|
16
+ cache_store.write cache_key, value, expires_in: cache_expires_in
17
+ }
18
+ end
19
+
20
+ def read
21
+ response = version_response
22
+ return '' unless response.is_a? Net::HTTPSuccess
23
+ response.body.strip
24
+ end
25
+
26
+ def version_response
27
+ Net::HTTP.get_response URI.parse(version_url)
28
+ end
29
+
30
+ def version_url
31
+ "#{@url}/version.txt"
32
+ end
33
+
34
+ def cache_exists?
35
+ not cache.nil?
36
+ end
37
+
38
+ def cache
39
+ cache_store.read cache_key
40
+ end
41
+
42
+ def cache_store
43
+ Rails.cache
44
+ end
45
+
46
+ def cache_key
47
+ "#{cache_key_prefix}:#{@url}"
48
+ end
49
+
50
+ def cache_key_prefix
51
+ :ecom_engine_version
52
+ end
53
+
54
+ def cache_expires_in
55
+ expires_in = ENV['ECOM_ENGINE_VERSION_CACHE_EXPIRES_IN']
56
+ return expires_in.to_i if expires_in.present?
57
+ 30
58
+ end
59
+ end
@@ -1,12 +1,10 @@
1
1
  module ScriptTags
2
2
  include Radiant::Taggable
3
3
 
4
- desc 'Econ-Engine javascript tag with the key for cache invalidation'
4
+ desc 'Ecom-Engine javascript tag with the key for cache invalidation'
5
5
  tag 'ee_script_tag' do |tag|
6
- version_uri = "#{PageMountCalculator.new(@request).ecom_engine_url}/version.txt"
7
- response = Net::HTTP.get_response(URI.parse(version_uri))
8
- query = ''
9
- query = "?#{CGI::escape(response.body.strip)}" if response.is_a? Net::HTTPSuccess
6
+ version = EcomEngine::Version.new(PageMountCalculator.new(@request).ecom_engine_url)
7
+ query = "?#{CGI::escape(version.value)}"
10
8
  raw %{<script src="/ecom-engine-js/#{tag.attr['src']}#{query}"></script>}
11
9
  end
12
10
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "radiant-ecom_engine-extension"
3
- spec.version = '0.3.0-alpha.1'
3
+ spec.version = '0.3.0'
4
4
  spec.authors = ["Michael Noack"]
5
5
  spec.email = ["support@travellink.com.au"]
6
6
  spec.description = %q{Integrate ecom engine with radiant}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-ecom_engine-extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre.alpha.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Noack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-02 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: radius
@@ -79,6 +79,8 @@ files:
79
79
  - app/views/page_mount/proxy.erb
80
80
  - config/routes.rb
81
81
  - ecom_engine_extension.rb
82
+ - lib/ecom_engine.rb
83
+ - lib/ecom_engine/version.rb
82
84
  - lib/request_proxy.rb
83
85
  - lib/tags/script_tags.rb
84
86
  - radiant-ecom_engine-extension.gemspec
@@ -97,9 +99,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
97
99
  version: '0'
98
100
  required_rubygems_version: !ruby/object:Gem::Requirement
99
101
  requirements:
100
- - - ">"
102
+ - - ">="
101
103
  - !ruby/object:Gem::Version
102
- version: 1.3.1
104
+ version: '0'
103
105
  requirements: []
104
106
  rubyforge_project:
105
107
  rubygems_version: 2.6.11