Skip to content

Commit 08b96ce

Browse files
committed
Fix namespacing for Client Class - no longer read as a module
1 parent 5d3cc98 commit 08b96ce

File tree

8 files changed

+79
-83
lines changed

8 files changed

+79
-83
lines changed

bin/console

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env ruby
22

33
require 'bundler/setup'
4-
require 'cortex/snippets/snippets-client'
4+
require 'cortex-snippets-client'
55

66
# You can add fixtures and/or initialization code here to make experimenting
77
# with your gem easier. You can also use a different console, if you like.

cortex-snippets-client-ruby.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# coding: utf-8
22
lib = File.expand_path('../lib', __FILE__)
33
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4-
require 'cortex/snippets/client/version'
4+
require 'cortex/snippets/version'
55

66
Gem::Specification.new do |spec|
77
spec.name = 'cortex-snippets-client'
8-
spec.version = Cortex::Snippets::Client::VERSION
8+
spec.version = Cortex::Snippets::VERSION
99
spec.authors = ['CareerBuilder Employer Site & Content Products']
1010
spec.email = ['EmployerSiteContentProducts@cb.com']
1111
spec.license = 'Apache-2.0'
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
1919
spec.require_paths = ['lib']
2020

2121
spec.add_dependency 'cortex-client', '~> 0.10'
22-
spec.add_dependency 'addressable', '~> 2.5'
22+
spec.add_dependency 'addressable', '~> 2.4'
2323

2424
spec.add_development_dependency 'rake', '~> 12.0'
2525
spec.add_development_dependency 'rspec', '~> 3.5'

lib/cortex-snippets-client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
require 'cortex/snippets/client'
2-
require 'cortex/snippets/client/version'
2+
require 'cortex/snippets/version'

lib/cortex/snippets/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require 'cortex/snippets/client/webpage'
1+
require 'cortex/snippets/webpage'
22
require 'addressable/uri'
33

44
module Cortex
@@ -9,7 +9,7 @@ def initialize(cortex_client)
99
end
1010

1111
def snippet(options = {}, &block)
12-
snippets = current_webpage(@cortex_client).snippets || []
12+
snippets = current_webpage.snippets || []
1313
snippet = snippets.find { |snippet| snippet[:document][:name] == options[:id] }
1414

1515
if snippet.nil? || snippet[:document][:body].nil? || snippet[:document][:body].empty?

lib/cortex/snippets/client/version.rb

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/cortex/snippets/client/webpage.rb

Lines changed: 0 additions & 69 deletions
This file was deleted.

lib/cortex/snippets/version.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Cortex
2+
module Snippets
3+
VERSION = '1.0.0'
4+
end
5+
end

lib/cortex/snippets/webpage.rb

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)