cortex-snippets-client 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: 5a0a5085dbcbd4d1d792cff72f4e0b60dd38eee3
4
- data.tar.gz: 550740427579f08cbc93f0e33f52c3cc44985bec
3
+ metadata.gz: 980ca1cf8a4a809700bd23f98eb56d93a94c4a9a
4
+ data.tar.gz: 29f400a93acc70da930d3ba86261bf96d970ab3e
5
5
  SHA512:
6
- metadata.gz: 086cb48328524926153665e802951de93679a79e798f133c62271e7576551dd72b989993e022812eb54745a0b534a9540b3d00ba251e5adb68ce7a3640c84416
7
- data.tar.gz: bbd67ff27361d4157645fad1ba4e7659de1f86ec740f5a37f4a32a6e211fb93c092b2b35856f3e2c1bbb51ca6719d69e7d9095e2fb4fd3c225cbc1ce1ba526ed
6
+ metadata.gz: 0a7910dffcbeb3613271945dc0743af96a04711ae24f02343287c9ef31dc7879754d2e9567b044e5dd90378aacaa9ec45db288bd9c63e7e0ffea11db40190606
7
+ data.tar.gz: d4e20d5920e05e0c7d0b440e705cc5ea1a450abefc932c490d222eda5c6fe75aa82e1adeaf5639e4958f5bc5002abcf3b0deb72cb398d4de5137fe991134e69b
data/CHANGELOG.md CHANGED
@@ -3,6 +3,7 @@ Version History
3
3
  * All Version bumps are required to update this file as well!!
4
4
  ----
5
5
 
6
+ * 1.0.1 - Fix namespacing bug for Cortex::Snippets::Client
6
7
  * 1.0.0 - Multi-tenancy Rebuild, now takes in Cortex Client
7
8
  * 0.8.1 - Dependency upgrades, etc
8
9
  * 0.8.0 - Add Dynamic Yield Metadata
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'bundler/setup'
4
- require 'cortex/snippets/snippets-client'
4
+ require 'cortex-snippets-client'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'cortex/snippets/client/version'
4
+ require 'cortex/snippets/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'cortex-snippets-client'
8
- spec.version = Cortex::Snippets::Client::VERSION
8
+ spec.version = Cortex::Snippets::VERSION
9
9
  spec.authors = ['CareerBuilder Employer Site & Content Products']
10
10
  spec.email = ['EmployerSiteContentProducts@cb.com']
11
11
  spec.license = 'Apache-2.0'
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency 'rake', '~> 12.0'
25
25
  spec.add_development_dependency 'rspec', '~> 3.5'
26
+ spec.add_development_dependency 'pry'
26
27
  end
@@ -1,4 +1,4 @@
1
- require 'cortex/snippets/client/webpage'
1
+ require 'cortex/snippets/webpage'
2
2
  require 'addressable/uri'
3
3
 
4
4
  module Cortex
@@ -9,7 +9,7 @@ module Cortex
9
9
  end
10
10
 
11
11
  def snippet(options = {}, &block)
12
- snippets = current_webpage(@cortex_client).snippets || []
12
+ snippets = current_webpage.snippets || []
13
13
  snippet = snippets.find { |snippet| snippet[:document][:name] == options[:id] }
14
14
 
15
15
  if snippet.nil? || snippet[:document][:body].nil? || snippet[:document][:body].empty?
@@ -23,7 +23,7 @@ module Cortex
23
23
  if defined?(Rails)
24
24
  url = sanitized_webpage_url(request.original_url)
25
25
  Rails.cache.fetch("webpages/#{@cortex_client.access_token.client.id}/#{url}", race_condition_ttl: 10) do
26
- Cortex::Snippets::Client::Webpage.new(@cortex_client, url)
26
+ Cortex::Snippets::Webpage.new(@cortex_client, url)
27
27
  end
28
28
  else
29
29
  raise 'Your Web framework is not supported. Supported frameworks: Rails'
@@ -0,0 +1,5 @@
1
+ module Cortex
2
+ module Snippets
3
+ VERSION = '1.0.1'
4
+ end
5
+ end
@@ -0,0 +1,67 @@
1
+ module Cortex
2
+ module Snippets
3
+ class Webpage
4
+ def initialize(cortex_client, url)
5
+ @webpage = cortex_client.webpages.get_feed(url).contents
6
+ end
7
+
8
+ def seo_title
9
+ @webpage[:seo_title]
10
+ end
11
+
12
+ def seo_description
13
+ @webpage[:seo_description]
14
+ end
15
+
16
+ def seo_keywords
17
+ @webpage[:seo_keyword_list]
18
+ end
19
+
20
+ def seo_robots
21
+ robot_information = []
22
+ index_options = [:noindex, :nofollow, :noodp, :nosnippet, :noarchive, :noimageindex]
23
+
24
+ index_options.each do |index_option|
25
+ robot_information << index_option if @webpage[index_option]
26
+ end
27
+
28
+ robot_information
29
+ end
30
+
31
+ def noindex
32
+ @webpage[:noindex]
33
+ end
34
+
35
+ def nofollow
36
+ @webpage[:nofollow]
37
+ end
38
+
39
+ def noodp
40
+ @webpage[:noodp]
41
+ end
42
+
43
+ def nosnippet
44
+ @webpage[:nosnippet]
45
+ end
46
+
47
+ def noarchive
48
+ @webpage[:noarchive]
49
+ end
50
+
51
+ def noimageindex
52
+ @webpage[:noimageindex]
53
+ end
54
+
55
+ def dynamic_yield
56
+ {
57
+ sku: @webpage[:dynamic_yield_sku],
58
+ category: @webpage[:dynamic_yield_category]
59
+ }
60
+ end
61
+
62
+ def snippets
63
+ @webpage[:snippets]
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,2 +1,2 @@
1
1
  require 'cortex/snippets/client'
2
- require 'cortex/snippets/client/version'
2
+ require 'cortex/snippets/version'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cortex-snippets-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - CareerBuilder Employer Site & Content Products
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - EmployerSiteContentProducts@cb.com
@@ -86,8 +100,8 @@ files:
86
100
  - cortex-snippets-client-ruby.gemspec
87
101
  - lib/cortex-snippets-client.rb
88
102
  - lib/cortex/snippets/client.rb
89
- - lib/cortex/snippets/client/version.rb
90
- - lib/cortex/snippets/client/webpage.rb
103
+ - lib/cortex/snippets/version.rb
104
+ - lib/cortex/snippets/webpage.rb
91
105
  homepage: https://github.com/cortex-cms/cortex-snippets-client-ruby
92
106
  licenses:
93
107
  - Apache-2.0
@@ -108,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
122
  version: '0'
109
123
  requirements: []
110
124
  rubyforge_project:
111
- rubygems_version: 2.5.1
125
+ rubygems_version: 2.6.8
112
126
  signing_key:
113
127
  specification_version: 4
114
128
  summary: Provides loading of Cortex snippets for Ruby applications, with some Rails
@@ -1,7 +0,0 @@
1
- module Cortex
2
- module Snippets
3
- module Client
4
- VERSION = '1.0.0'
5
- end
6
- end
7
- end
@@ -1,69 +0,0 @@
1
- module Cortex
2
- module Snippets
3
- module Client
4
- class Webpage
5
- def initialize(cortex_client, url)
6
- @webpage = cortex_client.webpages.get_feed(url).contents
7
- end
8
-
9
- def seo_title
10
- @webpage[:seo_title]
11
- end
12
-
13
- def seo_description
14
- @webpage[:seo_description]
15
- end
16
-
17
- def seo_keywords
18
- @webpage[:seo_keyword_list]
19
- end
20
-
21
- def seo_robots
22
- robot_information = []
23
- index_options = [:noindex, :nofollow, :noodp, :nosnippet, :noarchive, :noimageindex]
24
-
25
- index_options.each do |index_option|
26
- robot_information << index_option if @webpage[index_option]
27
- end
28
-
29
- robot_information
30
- end
31
-
32
- def noindex
33
- @webpage[:noindex]
34
- end
35
-
36
- def nofollow
37
- @webpage[:nofollow]
38
- end
39
-
40
- def noodp
41
- @webpage[:noodp]
42
- end
43
-
44
- def nosnippet
45
- @webpage[:nosnippet]
46
- end
47
-
48
- def noarchive
49
- @webpage[:noarchive]
50
- end
51
-
52
- def noimageindex
53
- @webpage[:noimageindex]
54
- end
55
-
56
- def dynamic_yield
57
- {
58
- sku: @webpage[:dynamic_yield_sku],
59
- category: @webpage[:dynamic_yield_category]
60
- }
61
- end
62
-
63
- def snippets
64
- @webpage[:snippets]
65
- end
66
- end
67
- end
68
- end
69
- end