radiant-feefo-extension 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +109 -0
- data/README.md +4 -0
- data/Rakefile +150 -0
- data/app/controllers/feefo_controller.rb +10 -0
- data/app/models/feefo_review_fetcher.rb +39 -0
- data/app/models/remote_feefo_review_fetcher.rb +29 -0
- data/config/feefo.yml.example +3 -0
- data/config/routes.rb +5 -0
- data/feefo_extension.rb +19 -0
- data/lib/radiant-feefo-extension.rb +3 -0
- data/lib/tasks/radiant-feefo-extension-tasks.rake +10 -0
- data/radiant-feefo-extension.gemspec +58 -0
- data/spec/cassettes/feefo_reviews_with_feedback.yml +147 -0
- data/spec/feefo_review_fetcher_spec.rb +55 -0
- data/spec/spec_helper.rb +10 -0
- metadata +159 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/sealink/radiant_extension_helper.git
|
3
|
+
revision: a83b1e771857a869423dac58eab6fb9598be9429
|
4
|
+
specs:
|
5
|
+
radiant_extension_helper (0.0.1)
|
6
|
+
|
7
|
+
PATH
|
8
|
+
remote: .
|
9
|
+
specs:
|
10
|
+
radiant-feefo-extension (0.0.2)
|
11
|
+
radiant (>= 1.0.0.rc2)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
RedCloth (4.2.9)
|
17
|
+
actionmailer (2.3.18)
|
18
|
+
actionpack (= 2.3.18)
|
19
|
+
actionpack (2.3.18)
|
20
|
+
activesupport (= 2.3.18)
|
21
|
+
rack (~> 1.1.0)
|
22
|
+
activerecord (2.3.18)
|
23
|
+
activesupport (= 2.3.18)
|
24
|
+
activeresource (2.3.18)
|
25
|
+
activesupport (= 2.3.18)
|
26
|
+
activesupport (2.3.18)
|
27
|
+
acts_as_tree (0.1.1)
|
28
|
+
addressable (2.3.6)
|
29
|
+
chunky_png (1.3.3)
|
30
|
+
compass (0.12.7)
|
31
|
+
chunky_png (~> 1.2)
|
32
|
+
fssm (>= 0.2.7)
|
33
|
+
sass (~> 3.2.19)
|
34
|
+
compass-rails (1.0.3)
|
35
|
+
compass (>= 0.12.2, < 0.14)
|
36
|
+
crack (0.4.2)
|
37
|
+
safe_yaml (~> 1.0.0)
|
38
|
+
delocalize (0.2.6)
|
39
|
+
diff-lcs (1.2.5)
|
40
|
+
fssm (0.2.10)
|
41
|
+
haml (3.1.8)
|
42
|
+
highline (1.6.21)
|
43
|
+
json (1.8.1)
|
44
|
+
rack (1.1.6)
|
45
|
+
rack-cache (1.2)
|
46
|
+
rack (>= 0.4)
|
47
|
+
radiant (1.1.4)
|
48
|
+
RedCloth (~> 4.2.0)
|
49
|
+
acts_as_tree (~> 0.1.1)
|
50
|
+
bundler (>= 1.0.0)
|
51
|
+
compass (~> 0.12.2)
|
52
|
+
compass-rails (~> 1.0.3)
|
53
|
+
delocalize (~> 0.2.3)
|
54
|
+
haml (~> 3.1.1)
|
55
|
+
highline (~> 1.6.10)
|
56
|
+
rack (~> 1.1.6)
|
57
|
+
rack-cache (~> 1.2)
|
58
|
+
radius (~> 0.7.3)
|
59
|
+
rails (~> 2.3.18)
|
60
|
+
rake (>= 0.8.7)
|
61
|
+
rdoc (>= 3.9.2)
|
62
|
+
stringex (~> 1.3.0)
|
63
|
+
tzinfo (~> 0.3.31)
|
64
|
+
will_paginate (~> 2.3.11)
|
65
|
+
radius (0.7.4)
|
66
|
+
rails (2.3.18)
|
67
|
+
actionmailer (= 2.3.18)
|
68
|
+
actionpack (= 2.3.18)
|
69
|
+
activerecord (= 2.3.18)
|
70
|
+
activeresource (= 2.3.18)
|
71
|
+
activesupport (= 2.3.18)
|
72
|
+
rake (>= 0.8.3)
|
73
|
+
rake (10.4.0)
|
74
|
+
rdoc (4.1.2)
|
75
|
+
json (~> 1.4)
|
76
|
+
redis (2.2.2)
|
77
|
+
rspec (3.1.0)
|
78
|
+
rspec-core (~> 3.1.0)
|
79
|
+
rspec-expectations (~> 3.1.0)
|
80
|
+
rspec-mocks (~> 3.1.0)
|
81
|
+
rspec-core (3.1.7)
|
82
|
+
rspec-support (~> 3.1.0)
|
83
|
+
rspec-expectations (3.1.2)
|
84
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
+
rspec-support (~> 3.1.0)
|
86
|
+
rspec-mocks (3.1.3)
|
87
|
+
rspec-support (~> 3.1.0)
|
88
|
+
rspec-support (3.1.2)
|
89
|
+
safe_yaml (1.0.4)
|
90
|
+
sass (3.2.19)
|
91
|
+
stringex (1.3.3)
|
92
|
+
tzinfo (0.3.42)
|
93
|
+
vcr (2.9.3)
|
94
|
+
webmock (1.20.4)
|
95
|
+
addressable (>= 2.3.6)
|
96
|
+
crack (>= 0.3.2)
|
97
|
+
will_paginate (2.3.16)
|
98
|
+
|
99
|
+
PLATFORMS
|
100
|
+
ruby
|
101
|
+
|
102
|
+
DEPENDENCIES
|
103
|
+
radiant-feefo-extension!
|
104
|
+
radiant_extension_helper!
|
105
|
+
rake
|
106
|
+
redis
|
107
|
+
rspec
|
108
|
+
vcr
|
109
|
+
webmock
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
desc 'Default: run specs.'
|
47
|
+
task :default => :spec
|
48
|
+
|
49
|
+
require 'rspec/core/rake_task'
|
50
|
+
|
51
|
+
desc "Run specs"
|
52
|
+
RSpec::Core::RakeTask.new do |t|
|
53
|
+
t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
54
|
+
# Put spec opts in a file named .rspec in root
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Generate SimpleCov test coverage and open in your browser"
|
58
|
+
task :coverage do
|
59
|
+
ENV['COVERAGE'] = 'true'
|
60
|
+
Rake::Task['spec'].invoke
|
61
|
+
end
|
62
|
+
|
63
|
+
require 'rdoc/task'
|
64
|
+
RDoc::Task.new do |rdoc|
|
65
|
+
rdoc.rdoc_dir = 'rdoc'
|
66
|
+
rdoc.title = "#{name} #{version}"
|
67
|
+
rdoc.rdoc_files.include('README*')
|
68
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
69
|
+
end
|
70
|
+
|
71
|
+
desc "Open an irb session preloaded with this library"
|
72
|
+
task :console do
|
73
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
74
|
+
end
|
75
|
+
|
76
|
+
#############################################################################
|
77
|
+
#
|
78
|
+
# Custom tasks (add your own tasks here)
|
79
|
+
#
|
80
|
+
#############################################################################
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
#############################################################################
|
85
|
+
#
|
86
|
+
# Packaging tasks
|
87
|
+
#
|
88
|
+
#############################################################################
|
89
|
+
|
90
|
+
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
91
|
+
task :release => :build do
|
92
|
+
unless `git branch` =~ /^\* master$/
|
93
|
+
puts "You must be on the master branch to release!"
|
94
|
+
exit!
|
95
|
+
end
|
96
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
97
|
+
sh "git tag v#{version}"
|
98
|
+
sh "git push origin master"
|
99
|
+
sh "git push origin v#{version}"
|
100
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Build #{gem_file} into the pkg directory"
|
104
|
+
task :build => :gemspec do
|
105
|
+
sh "mkdir -p pkg"
|
106
|
+
sh "gem build #{gemspec_file}"
|
107
|
+
sh "mv #{gem_file} pkg"
|
108
|
+
end
|
109
|
+
|
110
|
+
desc "Generate #{gemspec_file}"
|
111
|
+
task :gemspec => :validate do
|
112
|
+
# read spec file and split out manifest section
|
113
|
+
spec = File.read(gemspec_file)
|
114
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
115
|
+
|
116
|
+
# replace name version and date
|
117
|
+
replace_header(head, :name)
|
118
|
+
replace_header(head, :version)
|
119
|
+
replace_header(head, :date)
|
120
|
+
#comment this out if your rubyforge_project has a different name
|
121
|
+
replace_header(head, :rubyforge_project)
|
122
|
+
|
123
|
+
# determine file list from git ls-files
|
124
|
+
files = `git ls-files`.
|
125
|
+
split("\n").
|
126
|
+
sort.
|
127
|
+
reject { |file| file =~ /^\./ }.
|
128
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
129
|
+
map { |file| " #{file}" }.
|
130
|
+
join("\n")
|
131
|
+
|
132
|
+
# piece file back together and write
|
133
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
134
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
135
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
136
|
+
puts "Updated #{gemspec_file}"
|
137
|
+
end
|
138
|
+
|
139
|
+
desc "Validate #{gemspec_file}"
|
140
|
+
task :validate do
|
141
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
|
142
|
+
unless libfiles.empty?
|
143
|
+
# puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
|
144
|
+
# exit!
|
145
|
+
end
|
146
|
+
unless Dir['VERSION*'].empty?
|
147
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
148
|
+
exit!
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class FeefoReviewFetcher
|
2
|
+
|
3
|
+
attr_reader :code, :feefo_config
|
4
|
+
|
5
|
+
def initialize(code, feefo_config=load_feefo_config)
|
6
|
+
@code = code
|
7
|
+
@feefo_config = feefo_config
|
8
|
+
@redis = Redis.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def fetch_reviews
|
12
|
+
with_caching do
|
13
|
+
RemoteFeefoReviewFetcher.new(code, feefo_config).fetch_reviews
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def load_feefo_config
|
20
|
+
YamlConfiguration.new(Rails.root.join('config/feefo.yml')).data
|
21
|
+
end
|
22
|
+
|
23
|
+
def with_caching
|
24
|
+
fetch_from_cache.presence || yield.tap { |reviews| store_in_cache(reviews) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def fetch_from_cache
|
28
|
+
@redis.get feefo_key(code)
|
29
|
+
end
|
30
|
+
|
31
|
+
def store_in_cache(reviews)
|
32
|
+
@redis.setex feefo_key(code), feefo_config['time_to_cache_reviews'], reviews
|
33
|
+
end
|
34
|
+
|
35
|
+
def feefo_key(code)
|
36
|
+
"feefo_reviews_for_#{code}"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class RemoteFeefoReviewFetcher
|
2
|
+
attr_reader :code
|
3
|
+
|
4
|
+
def initialize(code, config)
|
5
|
+
@code = code
|
6
|
+
@config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
def fetch_reviews
|
10
|
+
params = {
|
11
|
+
logon: @config['account'],
|
12
|
+
vendorref: @code,
|
13
|
+
limit: @config['review_limit'],
|
14
|
+
json: true
|
15
|
+
}
|
16
|
+
|
17
|
+
uri = URI(url)
|
18
|
+
uri.query = URI.encode_www_form(params)
|
19
|
+
|
20
|
+
Net::HTTP.get(uri)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def url
|
27
|
+
'http://www.feefo.com/feefo/xmlfeed.jsp'
|
28
|
+
end
|
29
|
+
end
|
data/config/routes.rb
ADDED
data/feefo_extension.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Uncomment this if you reference any of your controllers in activate
|
2
|
+
# require_dependency 'application'
|
3
|
+
|
4
|
+
class FeefoExtension < Radiant::Extension
|
5
|
+
version "1.0"
|
6
|
+
description "Provides feefo review fetching and caching capabilities."
|
7
|
+
url "http://www.github.com/sealink/radiant-feefo-extension"
|
8
|
+
|
9
|
+
# define_routes do |map|
|
10
|
+
# map.connect 'admin/author/:action', :controller => 'admin/author'
|
11
|
+
# end
|
12
|
+
|
13
|
+
def activate
|
14
|
+
end
|
15
|
+
|
16
|
+
def deactivate
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :feefo do
|
4
|
+
desc "Copies public assets of the extension to the instance public/ directory."
|
5
|
+
task :update => :environment do
|
6
|
+
RadiantExtensionHelper.copy_assets(:quicktravel_config)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "radiant-feefo-extension"
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Stefan Kojic"]
|
12
|
+
s.date = "2014-12-02"
|
13
|
+
s.description = ""
|
14
|
+
s.email = "support@travellink.com.au"
|
15
|
+
s.homepage = "https://github.com/jomz/radiant-feefo-extension"
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.summary = ""
|
18
|
+
|
19
|
+
s.add_development_dependency('rake')
|
20
|
+
s.add_development_dependency('rspec')
|
21
|
+
s.add_development_dependency('vcr')
|
22
|
+
s.add_development_dependency('webmock')
|
23
|
+
s.add_development_dependency('redis')
|
24
|
+
|
25
|
+
if s.respond_to? :specification_version then
|
26
|
+
s.specification_version = 3
|
27
|
+
|
28
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
29
|
+
s.add_runtime_dependency(%q<radiant>, [">= 1.0.0.rc2"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<radiant>, [">= 1.0.0.rc2"])
|
32
|
+
end
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<radiant>, [">= 1.0.0.rc2"])
|
35
|
+
end
|
36
|
+
|
37
|
+
# = MANIFEST =
|
38
|
+
s.files = %w[
|
39
|
+
Gemfile
|
40
|
+
Gemfile.lock
|
41
|
+
README.md
|
42
|
+
Rakefile
|
43
|
+
app/controllers/feefo_controller.rb
|
44
|
+
app/models/feefo_review_fetcher.rb
|
45
|
+
app/models/remote_feefo_review_fetcher.rb
|
46
|
+
config/feefo.yml.example
|
47
|
+
config/routes.rb
|
48
|
+
feefo_extension.rb
|
49
|
+
lib/radiant-feefo-extension.rb
|
50
|
+
lib/tasks/radiant-feefo-extension-tasks.rake
|
51
|
+
radiant-feefo-extension.gemspec
|
52
|
+
spec/cassettes/feefo_reviews_with_feedback.yml
|
53
|
+
spec/feefo_review_fetcher_spec.rb
|
54
|
+
spec/spec_helper.rb
|
55
|
+
]
|
56
|
+
# = MANIFEST =
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://www.feefo.com/feefo/xmlfeed.jsp?json=true&limit=9&logon=www.sealinktravelgroup.com.au/SeaLink%20KI&vendorref=HTCC
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message: OK
|
18
|
+
headers:
|
19
|
+
Server:
|
20
|
+
- Apache-Coyote/1.1
|
21
|
+
Set-Cookie:
|
22
|
+
- JSESSIONID=728C2700C3DB55AE742CBE1D7FCAAE98; Path=/
|
23
|
+
Cache-Control:
|
24
|
+
- max-age=3600
|
25
|
+
Content-Type:
|
26
|
+
- application/json;charset=UTF-8
|
27
|
+
Date:
|
28
|
+
- Tue, 02 Dec 2014 06:26:31 GMT
|
29
|
+
Connection:
|
30
|
+
- close
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ! "{\"FEEDBACKLIST\": {\n \"FEEDBACK\": [\n {\n \"COUNT\":
|
34
|
+
1,\n \"CUSTOMERCOMMENT\": \"A bit long journey but good experience.
|
35
|
+
\ A bit disappointed as not Kangaroo saw!\",\n \"DATE\": \"09-Oct-2014\",\n
|
36
|
+
\ \"DESCRIPTION\": \"1 Day Kangaroo Island Experience\",\n \"FACEBOOKSHARELINK\":
|
37
|
+
\"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D349\",\n
|
38
|
+
\ \"FEEDBACKID\": 349,\n \"HREVIEWDATE\": \"2014-10-09T12:57:04\",\n
|
39
|
+
\ \"HREVIEWRATING\": 4,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
40
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"+\",\n
|
41
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=349\",\n
|
42
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"A bit long journey but good experience.
|
43
|
+
\ A bit disappointed as not Kangaroo saw!\"\n },\n {\n \"COUNT\":
|
44
|
+
2,\n \"CUSTOMERCOMMENT\": \"Our bus trip was brilliant. Our driver
|
45
|
+
was simply terrific, very knowledgeable, affable and relaxed. The sights were
|
46
|
+
great but it would be nice to include the Eucalyptus Oil place perhaps?\",\n
|
47
|
+
\ \"DATE\": \"10-Sep-2014\",\n \"DESCRIPTION\": \"1 Day
|
48
|
+
Kangaroo Island Experience\",\n \"FACEBOOKSHARELINK\": \"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D879\",\n
|
49
|
+
\ \"FEEDBACKID\": 879,\n \"HREVIEWDATE\": \"2014-09-10T06:56:12\",\n
|
50
|
+
\ \"HREVIEWRATING\": 5,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
51
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"++\",\n
|
52
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=879\",\n
|
53
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"Our bus trip was brilliant. Our driver
|
54
|
+
was simply terrific, very knowledgeable, affable and relaxed. The sights were
|
55
|
+
great but it would be nice to include the Eucalyptus Oil place perhaps?\"\n
|
56
|
+
\ },\n {\n \"COUNT\": 3,\n \"CUSTOMERCOMMENT\":
|
57
|
+
\"Our tour guide, Kalen, was terrific. Since he lives on KI he had lots of
|
58
|
+
great stories and information about the island and its inhabitants -- human
|
59
|
+
and otherwise! He stopped the bus or slowed down to show us different animals
|
60
|
+
or traces of them. We saw an echidna and the ant hills that goanas lay their
|
61
|
+
eggs in. He was cheerful and seemed to really enjoy his job. My only complaint
|
62
|
+
would be that I felt a bit rushed at some of the stops because we were a bit
|
63
|
+
pressed for time in order to keep on schedule. But all in all it was a great
|
64
|
+
tour and I would highly recommend it!\",\n \"DATE\": \"10-Sep-2014\",\n
|
65
|
+
\ \"DESCRIPTION\": \"1 Day Kangaroo Island Experience\",\n \"FACEBOOKSHARELINK\":
|
66
|
+
\"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D1023\",\n
|
67
|
+
\ \"FEEDBACKID\": 1023,\n \"HREVIEWDATE\": \"2014-09-09T18:03:17\",\n
|
68
|
+
\ \"HREVIEWRATING\": 5,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
69
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"++\",\n
|
70
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=1023\",\n
|
71
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"Our tour guide, Kalen, was terrific.
|
72
|
+
Since he lives on KI he had lots of great stories and information about the
|
73
|
+
island and its inhabitants -- human and otherwise! He stopped the bus or slowed
|
74
|
+
down to show us different animals or traces of them. We saw an echidna and
|
75
|
+
the ant hills that goanas lay t...\"\n },\n {\n \"COUNT\":
|
76
|
+
4,\n \"CUSTOMERCOMMENT\": \"Good\",\n \"DATE\": \"09-Sep-2014\",\n
|
77
|
+
\ \"DESCRIPTION\": \"1 Day Kangaroo Island Experience\",\n \"FACEBOOKSHARELINK\":
|
78
|
+
\"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D1069\",\n
|
79
|
+
\ \"FEEDBACKID\": 1069,\n \"HREVIEWDATE\": \"2014-09-09T12:30:56\",\n
|
80
|
+
\ \"HREVIEWRATING\": 4,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
81
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"+\",\n
|
82
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=1069\",\n
|
83
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"Good\"\n },\n {\n \"COUNT\":
|
84
|
+
5,\n \"CUSTOMERCOMMENT\": \"Congratulations to your driver on KI
|
85
|
+
for not going without those couple of people that were always late. He was
|
86
|
+
constantly courteous.\",\n \"DATE\": \"09-Sep-2014\",\n \"DESCRIPTION\":
|
87
|
+
\"1 Day Kangaroo Island Experience\",\n \"FACEBOOKSHARELINK\":
|
88
|
+
\"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D1135\",\n
|
89
|
+
\ \"FEEDBACKID\": 1135,\n \"HREVIEWDATE\": \"2014-09-09T08:17:17\",\n
|
90
|
+
\ \"HREVIEWRATING\": 5,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
91
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"++\",\n
|
92
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=1135\",\n
|
93
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"Congratulations to your driver on
|
94
|
+
KI for not going without those couple of people that were always late. He
|
95
|
+
was constantly courteous.\"\n },\n {\n \"COUNT\":
|
96
|
+
6,\n \"CUSTOMERCOMMENT\": \"a bit expensive\",\n \"DATE\":
|
97
|
+
\"09-Sep-2014\",\n \"DESCRIPTION\": \"1 Day Kangaroo Island Experience\",\n
|
98
|
+
\ \"FACEBOOKSHARELINK\": \"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D999\",\n
|
99
|
+
\ \"FEEDBACKID\": 999,\n \"HREVIEWDATE\": \"2014-09-09T03:08:48\",\n
|
100
|
+
\ \"HREVIEWRATING\": 4,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
101
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"+\",\n
|
102
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=999\",\n
|
103
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"a bit expensive\"\n },\n {\n
|
104
|
+
\ \"COUNT\": 7,\n \"CUSTOMERCOMMENT\": \"It was a freezing
|
105
|
+
day, so would have like to board Sealink sooner, not at last minute when we
|
106
|
+
had to line up in the cold.\",\n \"DATE\": \"07-Sep-2014\",\n \"DESCRIPTION\":
|
107
|
+
\"1 Day Kangaroo Island Experience\",\n \"FACEBOOKSHARELINK\":
|
108
|
+
\"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D911\",\n
|
109
|
+
\ \"FEEDBACKID\": 911,\n \"HREVIEWDATE\": \"2014-09-07T12:02:43\",\n
|
110
|
+
\ \"HREVIEWRATING\": 4,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
111
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"+\",\n
|
112
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&servicefeedbackid=911\",\n
|
113
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"It was a freezing day, so would have
|
114
|
+
like to board Sealink sooner, not at last minute when we had to line up in
|
115
|
+
the cold.\"\n },\n {\n \"COUNT\": 8,\n \"CUSTOMERCOMMENT\":
|
116
|
+
\"Tour coach was very comfortable company good.\",\n \"DATE\":
|
117
|
+
\"06-Sep-2014\",\n \"DESCRIPTION\": \"1 Day Kangaroo Island Experience\",\n
|
118
|
+
\ \"FACEBOOKSHARELINK\": \"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D983\",\n
|
119
|
+
\ \"FEEDBACKID\": 983,\n \"HREVIEWDATE\": \"2014-09-06T01:09:15\",\n
|
120
|
+
\ \"HREVIEWRATING\": 5,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
121
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"++\",\n
|
122
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=983\",\n
|
123
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"Tour coach was very comfortable company
|
124
|
+
good.\"\n },\n {\n \"COUNT\": 9,\n \"CUSTOMERCOMMENT\":
|
125
|
+
\"It was good experience\",\n \"DATE\": \"05-Sep-2014\",\n \"DESCRIPTION\":
|
126
|
+
\"1 Day Kangaroo Island Experience\",\n \"FACEBOOKSHARELINK\":
|
127
|
+
\"http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-KI_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D1109\",\n
|
128
|
+
\ \"FEEDBACKID\": 1109,\n \"HREVIEWDATE\": \"2014-09-05T06:52:27\",\n
|
129
|
+
\ \"HREVIEWRATING\": 4,\n \"LINK\": \"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
130
|
+
\ \"PRODUCTCODE\": \"HTCC\",\n \"PRODUCTRATING\": \"+\",\n
|
131
|
+
\ \"READMOREURL\": \"http://www.feefo.com/AU/en/reviews/SeaLink-KI_Tours/?id=987195&productfeedbackid=1109\",\n
|
132
|
+
\ \"SHORTCUSTOMERCOMMENT\": \"It was good experience\"\n }\n
|
133
|
+
\ ],\n \"SUMMARY\": {\n \"AVERAGE\": 98,\n \"BEST\": 100,\n
|
134
|
+
\ \"COUNT\": 61,\n \"FEEDGENERATION\": \"Tue Dec 02 06:26:31
|
135
|
+
GMT 2014\",\n \"LIMIT\": 9,\n \"MODE\": \"product\",\n \"PRODUCTBAD\":
|
136
|
+
0,\n \"PRODUCTEXCELLENT\": 30,\n \"PRODUCTGOOD\": 30,\n \"PRODUCTLINK\":
|
137
|
+
\"http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/\",\n
|
138
|
+
\ \"PRODUCTPOOR\": 1,\n \"SERVICEBAD\": 0,\n \"SERVICEEXCELLENT\":
|
139
|
+
35,\n \"SERVICEGOOD\": 25,\n \"SERVICEPOOR\": 1,\n \"START\":
|
140
|
+
1,\n \"SUPPLIERLOGO\": \"http://www.feefo.com/feefo/getnonpublicfile.jsp?vendorimage=985271&vendorimageext=file.jpg\",\n
|
141
|
+
\ \"TITLE\": \"1 Day Kangaroo Island Experience\",\n \"TOTALPRODUCTCOUNT\":
|
142
|
+
61,\n \"TOTALRESPONSES\": 61,\n \"TOTALSERVICECOUNT\": 61,\n
|
143
|
+
\ \"VENDORLOGON\": \"www.sealinktravelgroup.com.au/SeaLink KI\",\n \"VENDORREF\":
|
144
|
+
\"HTCC\",\n \"WORST\": 0\n }\n}}"
|
145
|
+
http_version:
|
146
|
+
recorded_at: Tue, 02 Dec 2014 06:26:33 GMT
|
147
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'feefo_review_fetcher'
|
3
|
+
require 'remote_feefo_review_fetcher'
|
4
|
+
|
5
|
+
describe "Fetching a set of reviews" do
|
6
|
+
before do
|
7
|
+
Redis.new.flushdb
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:feefo_review_fetcher) do
|
11
|
+
config = {
|
12
|
+
'account' => 'www.sealinktravelgroup.com.au/SeaLink KI',
|
13
|
+
'time_to_cache_reviews' => 25,
|
14
|
+
'review_limit' => 9
|
15
|
+
}
|
16
|
+
FeefoReviewFetcher.new('HTCC', config)
|
17
|
+
end
|
18
|
+
|
19
|
+
subject(:reviews) do
|
20
|
+
VCR.use_cassette('feefo_reviews_with_feedback') do
|
21
|
+
feefo_review_fetcher.fetch_reviews
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return a String' do
|
26
|
+
expect(reviews).to be_an_instance_of(String)
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when converted to json' do
|
30
|
+
subject(:json) { JSON.load(reviews) }
|
31
|
+
|
32
|
+
it { should be_a(Hash) }
|
33
|
+
it { should include 'FEEDBACKLIST' }
|
34
|
+
|
35
|
+
context 'its FEEDBACK list' do
|
36
|
+
let(:feedback) { json['FEEDBACKLIST']['FEEDBACK'] }
|
37
|
+
subject(:feedback_length) { feedback.length }
|
38
|
+
|
39
|
+
it { should eq 9 }
|
40
|
+
|
41
|
+
context 'its first FEEDBACK element' do
|
42
|
+
subject { feedback.first }
|
43
|
+
it { should be_a(Hash) }
|
44
|
+
it { should include 'PRODUCTRATING' }
|
45
|
+
# These guys are optional keys:
|
46
|
+
# it { should include *%w(SERVICERATING CUSTOMERCOMMENT VENDORCOMMENT) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'its SUMMARY' do
|
51
|
+
subject { json['FEEDBACKLIST']['SUMMARY'] }
|
52
|
+
it { should include *%w(COUNT AVERAGE) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: radiant-feefo-extension
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Stefan Kojic
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: vcr
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: webmock
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: redis
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: radiant
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.0.0.rc2
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.0.0.rc2
|
110
|
+
description: ''
|
111
|
+
email: support@travellink.com.au
|
112
|
+
executables: []
|
113
|
+
extensions: []
|
114
|
+
extra_rdoc_files: []
|
115
|
+
files:
|
116
|
+
- Gemfile
|
117
|
+
- Gemfile.lock
|
118
|
+
- README.md
|
119
|
+
- Rakefile
|
120
|
+
- app/controllers/feefo_controller.rb
|
121
|
+
- app/models/feefo_review_fetcher.rb
|
122
|
+
- app/models/remote_feefo_review_fetcher.rb
|
123
|
+
- config/feefo.yml.example
|
124
|
+
- config/routes.rb
|
125
|
+
- feefo_extension.rb
|
126
|
+
- lib/radiant-feefo-extension.rb
|
127
|
+
- lib/tasks/radiant-feefo-extension-tasks.rake
|
128
|
+
- radiant-feefo-extension.gemspec
|
129
|
+
- spec/cassettes/feefo_reviews_with_feedback.yml
|
130
|
+
- spec/feefo_review_fetcher_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: https://github.com/jomz/radiant-feefo-extension
|
133
|
+
licenses: []
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
hash: 3083003707786389768
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.8.25
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: ''
|
159
|
+
test_files: []
|