feefo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5fcf57ef48dcefe4a7558831e36dbfdf1bd06a79
4
+ data.tar.gz: 9b51ea6281c9d558f3a360e344936d58b29408e2
5
+ SHA512:
6
+ metadata.gz: 07d98ef5fd9cd2101a343fa9688cddfd58e3fcf3562b6be8bffd56f63d7f68b871986580d777105c0a599dab3076b1cae330a58775fab3e251189ac7f2937891
7
+ data.tar.gz: d766c7f8f587b75543c25c86242940d83cf4fe5e2679738c4b8b8252b8daeab19debebc5bcf8147740ccb7a1a421b5d7bfdde3a7683f582fd3a586a20a6dcf38
@@ -0,0 +1,5 @@
1
+ coverage
2
+ Gemfile.lock
3
+
4
+ vendor/ruby
5
+ .bundle
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ script: "bundle exec rake"
5
+ notifications:
6
+ email:
7
+ - support@travellink.com.au
8
+ sudo: false
9
+ cache: bundler
@@ -0,0 +1,9 @@
1
+ # Unreleased #
2
+
3
+ # 0.1.0 #
4
+
5
+ * Use coverage kit to enforce maximum coverage
6
+ * Updated params for feed to allow code and category
7
+ * Added a method to build a review image
8
+ * Fix issue with caching forever
9
+ * Fix issue when feedback result blank
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,6 @@
1
+ Feefo
2
+ =====
3
+
4
+ [![Build Status](https://travis-ci.org/sealink/feefo.png?branch=master)](https://travis-ci.org/sealink/feefo)
5
+ [![Coverage Status](https://coveralls.io/repos/sealink/feefo/badge.png)](https://coveralls.io/r/sealink/feefo)
6
+ [![Code Climate](https://codeclimate.com/github/sealink/feefo.png)](https://codeclimate.com/github/sealink/feefo)
@@ -0,0 +1,18 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ desc 'Default: run specs.'
4
+ task :default => :spec
5
+
6
+ require 'rspec/core/rake_task'
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
11
+ # Put spec opts in a file named .rspec in root
12
+ end
13
+
14
+ desc "Generate SimpleCov test coverage and open in your browser"
15
+ task :coverage do
16
+ ENV['COVERAGE'] = 'true'
17
+ Rake::Task['spec'].invoke
18
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'feefo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "feefo"
8
+ spec.version = Feefo::VERSION
9
+ spec.authors = ["Michael Noack"]
10
+ spec.email = ["support@travellink.com.au"]
11
+ spec.description = %q{Methods to fetch and show feefo reviews}
12
+ spec.summary = %q{Methods to fetch and shwo feefo reviews}
13
+ spec.homepage = 'https://github.com/sealink/feefo'
14
+
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'coverage-kit'
26
+ spec.add_development_dependency 'simplecov-rcov'
27
+ spec.add_development_dependency 'coveralls'
28
+ spec.add_development_dependency 'vcr'
29
+ spec.add_development_dependency 'webmock'
30
+ spec.add_development_dependency 'pry'
31
+ spec.add_development_dependency 'travis'
32
+ end
@@ -0,0 +1,4 @@
1
+ logon: 'www.sealinktravelgroup.com.au'
2
+ division: 'SeaLink KI'
3
+ time_to_cache_reviews: 86400 # 1 day
4
+ review_limit: 1000000
@@ -0,0 +1,56 @@
1
+ require 'feefo/remote_review_fetcher'
2
+ require 'feefo/review_fetcher'
3
+ require 'feefo/review'
4
+ require 'feefo/reviews'
5
+ require 'feefo/version'
6
+
7
+ module Feefo
8
+ def self.config
9
+ @config
10
+ end
11
+
12
+ def self.config=(config)
13
+ @config = {
14
+ name: config['name'],
15
+ logon: config['logon'],
16
+ division: config['division'],
17
+ time_to_cache_reviews: config['time_to_cache_reviews'],
18
+ review_limit: config['review_limit']
19
+ }
20
+ end
21
+
22
+ def self.review_base_url
23
+ name = configEncode(:name)
24
+ logon = configEncode(:logon)
25
+ division = configEncode(:division)
26
+ "https://www.feefo.com/reviews/#{name}/?logon=#{logon}/#{division}"
27
+ end
28
+
29
+ def self.review_badge_image(filters)
30
+ logon = configEncode(:logon)
31
+ division = configEncode(:division)
32
+ code = filters[:code]
33
+ category = filters[:category]
34
+ base_image_url = "https://www.feefo.com/feefo/feefologo.jsp?logon=#{logon}/#{division}"
35
+ category_part = category ? "/#{category}" : ''
36
+ code_part = code ? "&vendorref=#{code}" : ''
37
+ image_template = "&template=product-stars-grey-150x38_en.png"
38
+ return '' unless category || code
39
+ base_image_url + category_part + code_part + image_template
40
+ end
41
+
42
+ def self.review_for_code(filters)
43
+ fetcher = ReviewFetcher.new(filters)
44
+ data = JSON.parse(fetcher.fetch_reviews_json)
45
+ Feefo::Reviews.new(data)
46
+ rescue JSON::ParserError => e
47
+ nil
48
+ end
49
+
50
+ private
51
+
52
+ def self.configEncode(key)
53
+ URI.encode(config.fetch(key))
54
+ end
55
+
56
+ end
@@ -0,0 +1,42 @@
1
+ module Feefo
2
+ class RemoteReviewFetcher
3
+ attr_reader :code
4
+
5
+ def initialize(filters, config)
6
+ @code = filters[:code]
7
+ @category = filters[:category]
8
+ @config = config
9
+ end
10
+
11
+ def fetch_reviews
12
+ params = {
13
+ logon: logon,
14
+ vendorref: @code,
15
+ limit: @config[:review_limit],
16
+ json: true,
17
+ mode: 'both' # Needed to get both product and service rating
18
+ }.reject { |k, v| v.nil? }
19
+
20
+ uri = URI(url)
21
+ uri.query = URI.encode_www_form(params)
22
+ http = Net::HTTP.new(uri.host, uri.port)
23
+ http.use_ssl = uri.port == 443
24
+ response = http.get(uri.request_uri)
25
+ response.body
26
+ end
27
+
28
+
29
+ private
30
+
31
+ def logon
32
+ logon = @config[:logon]
33
+ logon += '/' + @config[:division] if @config.key? :division
34
+ logon += '/' + @category if @category
35
+ logon
36
+ end
37
+
38
+ def url
39
+ 'https://www.feefo.com/feefo/xmlfeed.jsp'
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,41 @@
1
+ module Feefo
2
+ class Review
3
+ attr_reader :data
4
+
5
+ def initialize(data)
6
+ @data = data
7
+ end
8
+
9
+ def customer_comment
10
+ data['CUSTOMERCOMMENT']
11
+ end
12
+
13
+ def review_date
14
+ data['HREVIEWDATE']
15
+ end
16
+
17
+ def service_rating
18
+ data['SERVICERATING']
19
+ end
20
+
21
+ def vendor_comment
22
+ data['VENDORCOMMENT']
23
+ end
24
+
25
+ def review_rating
26
+ data['HREVIEWRATING']
27
+ end
28
+
29
+ def description
30
+ data['DESCRIPTION']
31
+ end
32
+
33
+ def link
34
+ data['LINK']
35
+ end
36
+
37
+ def date
38
+ data['DATE']
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,39 @@
1
+ module Feefo
2
+ class ReviewFetcher
3
+ attr_reader :filters, :feefo_config
4
+
5
+ def initialize(filters, feefo_config = Feefo.config, cache = Rails.cache)
6
+ @filters = filters
7
+ @feefo_config = feefo_config
8
+ @cache = cache
9
+ end
10
+
11
+ def fetch_reviews_json
12
+ with_caching do
13
+ RemoteReviewFetcher.new(filters, feefo_config).fetch_reviews
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def with_caching
20
+ fetch_from_cache || yield.tap { |reviews| store_in_cache(reviews) }
21
+ end
22
+
23
+ def fetch_from_cache
24
+ cache.read feefo_key(filters)
25
+ end
26
+
27
+ def store_in_cache(reviews)
28
+ cache.write feefo_key(filters), reviews, expires_in: feefo_config[:time_to_cache_reviews]
29
+ end
30
+
31
+ def feefo_key(filters)
32
+ "feefo_reviews_for_#{filters[:code]}_#{filters[:category]}"
33
+ end
34
+
35
+ def cache
36
+ @cache
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ module Feefo
2
+ class Reviews
3
+ attr_reader :reviews, :summary
4
+
5
+ def initialize(data)
6
+ list = data.fetch('FEEDBACKLIST')
7
+ @reviews = list.fetch('FEEDBACK', []).map { |review| Feefo::Review.new(review) }
8
+ @summary = list.fetch('SUMMARY')
9
+ end
10
+
11
+ def average
12
+ @summary['AVERAGE']
13
+ end
14
+
15
+ def count
16
+ @summary['COUNT']
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Feefo
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'feefo'
3
+
4
+ describe 'Feefo' do
5
+ before do
6
+ Feefo.config = {
7
+ 'logon' => 'www.link.com',
8
+ 'division' => 'My Brand'
9
+ }
10
+ @code = 'abc'
11
+ @category = 'cat'
12
+ end
13
+
14
+ it 'should determine url' do
15
+ expected_url = 'https://www.feefo.com/feefo/feefologo.jsp?logon=www.link.com/My%20Brand/cat&vendorref=abc&template=product-stars-grey-150x38_en.png'
16
+ expect(Feefo.review_badge_image(code: @code, category: @category)).to eq expected_url
17
+ end
18
+ end
@@ -0,0 +1,207 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://www.feefo.com/feefo/xmlfeed.jsp?json=true&limit=9&logon=www.sealinktravelgroup.com.au/SeaLink%20KI&mode=both&vendorref=HTCC
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Server:
22
+ - Apache-Coyote/1.1
23
+ Set-Cookie:
24
+ - JSESSIONID=EEDD7B14F96E1E4B524214ADDDA53A46; Path=/; Secure
25
+ Cache-Control:
26
+ - max-age=3600
27
+ Content-Type:
28
+ - application/json;charset=UTF-8
29
+ Transfer-Encoding:
30
+ - chunked
31
+ Vary:
32
+ - Accept-Encoding
33
+ Date:
34
+ - Wed, 04 May 2016 04:53:09 GMT
35
+ body:
36
+ encoding: ASCII-8BIT
37
+ string: |-
38
+ {"FEEDBACKLIST": {
39
+ "FEEDBACK": [
40
+ {
41
+ "COUNT": 1,
42
+ "CUSTOMERCOMMENT": "Great trip over and back and very enjoyable day tour",
43
+ "DATE": "40 Hour(s) ago",
44
+ "DESCRIPTION": "KI Experience",
45
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101092",
46
+ "FEEDBACKID": 101092,
47
+ "HREVIEWDATE": "2016-05-02T12:43:36",
48
+ "HREVIEWRATING": 5,
49
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
50
+ "PRODUCTCODE": "HTCC",
51
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101092",
52
+ "SERVICERATING": "++",
53
+ "SHORTCUSTOMERCOMMENT": "Great trip over and back and very enjoyable day tour"
54
+ },
55
+ {
56
+ "COUNT": 2,
57
+ "CUSTOMERCOMMENT": "Ferry was on time, staff were most certainly friendly and helpful.....clean and tidy ferry inside.",
58
+ "DATE": "01-May-2016",
59
+ "DESCRIPTION": "KI Experience",
60
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101230",
61
+ "FEEDBACKID": 101230,
62
+ "HREVIEWDATE": "2016-05-01T05:28:36",
63
+ "HREVIEWRATING": 5,
64
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
65
+ "PRODUCTCODE": "HTCC",
66
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101230",
67
+ "SERVICERATING": "++",
68
+ "SHORTCUSTOMERCOMMENT": "Ferry was on time, staff were most certainly friendly and helpful.....clean and tidy ferry inside."
69
+ },
70
+ {
71
+ "COUNT": 3,
72
+ "CUSTOMERCOMMENT": "It was the highlight of our trip to Adelaide. Amazing wildlife and a fantastic guide. It would have been nice to know that there is very limited dinner meal options available (especially for vegetarians).",
73
+ "DATE": "01-May-2016",
74
+ "DESCRIPTION": "KI Experience",
75
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101209",
76
+ "FEEDBACKID": 101209,
77
+ "HREVIEWDATE": "2016-05-01T05:06:22",
78
+ "HREVIEWRATING": 5,
79
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
80
+ "PRODUCTCODE": "HTCC",
81
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101209",
82
+ "SERVICERATING": "++",
83
+ "SHORTCUSTOMERCOMMENT": "It was the highlight of our trip to Adelaide. Amazing wildlife and a fantastic guide. It would have been nice to know that there is very limited dinner meal options available (especially for vegetarians)."
84
+ },
85
+ {
86
+ "COUNT": 4,
87
+ "CUSTOMERCOMMENT": "A wonderful experience",
88
+ "DATE": "01-May-2016",
89
+ "DESCRIPTION": "KI Experience",
90
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101107",
91
+ "FEEDBACKID": 101107,
92
+ "HREVIEWDATE": "2016-04-30T21:35:56",
93
+ "HREVIEWRATING": 4,
94
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
95
+ "PRODUCTCODE": "HTCC",
96
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101107",
97
+ "SERVICERATING": "+",
98
+ "SHORTCUSTOMERCOMMENT": "A wonderful experience"
99
+ },
100
+ {
101
+ "COUNT": 5,
102
+ "CUSTOMERCOMMENT": "Impressed customer service experience thoughout the Kangaroo Island tour including the ferry ride.",
103
+ "DATE": "30-Apr-2016",
104
+ "DESCRIPTION": "KI Experience",
105
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101143",
106
+ "FEEDBACKID": 101143,
107
+ "HREVIEWDATE": "2016-04-30T13:36:26",
108
+ "HREVIEWRATING": 4,
109
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
110
+ "PRODUCTCODE": "HTCC",
111
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101143",
112
+ "SERVICERATING": "+",
113
+ "SHORTCUSTOMERCOMMENT": "Impressed customer service experience thoughout the Kangaroo Island tour including the ferry ride."
114
+ },
115
+ {
116
+ "COUNT": 6,
117
+ "CUSTOMERCOMMENT": "A long day but good tour guides and so much information.The coach was comfortable and lunch at Vivonne bay yummy. There was little time for a pie at 4pm and a snack just before the 7:30pm ferry so no dinner break but a few people were seasick on the trip back so maybe that is the reason. Thankyou for the highlights of Kangaroo Island.",
118
+ "DATE": "30-Apr-2016",
119
+ "DESCRIPTION": "KI Experience",
120
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101077",
121
+ "FEEDBACKID": 101077,
122
+ "HREVIEWDATE": "2016-04-30T09:30:32",
123
+ "HREVIEWRATING": 4,
124
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
125
+ "PRODUCTCODE": "HTCC",
126
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101077",
127
+ "SERVICERATING": "+",
128
+ "SHORTCUSTOMERCOMMENT": "A long day but good tour guides and so much information.The coach was comfortable and lunch at Vivonne bay yummy. There was little time for a pie at 4pm and a snack just before the 7:30pm ferry so no dinner break but a few people were seasick on the trip back so maybe that is the reason. Thankyou..."
129
+ },
130
+ {
131
+ "COUNT": 7,
132
+ "CUSTOMERCOMMENT": "One Day Tour was a wonderful experience, for what it was: a ONE DAY tour. It is definitely an overview of a vast island that has so much to offer. Our driver, guide was extremely knowledgeable and personable, showing us the island through history, culture and personal stories. Lunch buffet was VERY good. Several choices to accommodate varied tastes, as well as options for my guest with food allergies.&#13;<br/>&#13;<br/>You must understand that it is a very large island and requires ALOT of driving time. During our 16hour day, over 10 hours is spent on some form of transportation.&#13;<br/>&#13;<br/>My one suggestion would be to have guides or &quot;spotters&quot; for the brief time at Hansen's Reserve. We were allowed only 30 minutes off the bus to explore and FIND koalas. Of the 4 found, they were VERY high in the trees. Time consuming and didn't allow time for really exploring this reserve and what it truly offers.&#13;<br/>&#13;<br/>All in all, I do recommend this tour, especially for this with minimal time or first time visitors to Australia.",
133
+ "DATE": "30-Apr-2016",
134
+ "DESCRIPTION": "KI Experience",
135
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D99976",
136
+ "FEEDBACKID": 99976,
137
+ "FURTHERCOMMENTSTHREAD": {"POST": {
138
+ "CUSTOMERCOMMENT": "Thank you",
139
+ "DATE": "30-Apr-2016",
140
+ "SERVICERATING": "++"
141
+ }},
142
+ "HREVIEWDATE": "2016-04-29T14:08:50",
143
+ "HREVIEWRATING": 5,
144
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
145
+ "PRODUCTCODE": "HTCC",
146
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=99976",
147
+ "SERVICELATEST": "++",
148
+ "SERVICERATING": "++",
149
+ "SHORTCUSTOMERCOMMENT": "One Day Tour was a wonderful experience, for what it was: a ONE DAY tour. It is definitely an overview of a vast island that has so much to offer. Our driver, guide was extremely knowledgeable and personable, showing us the island through history, culture and personal stories. Lunch buffet was VERY ..."
150
+ },
151
+ {
152
+ "COUNT": 8,
153
+ "CUSTOMERCOMMENT": "The bus was filled with some smelly perfume, which makes passenge feel very sick all the way. Not a pleasant experience on this day trip. Dad will never go by tour again.",
154
+ "DATE": "28-Apr-2016",
155
+ "DESCRIPTION": "KI Experience",
156
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101194",
157
+ "FEEDBACKID": 101194,
158
+ "FURTHERCOMMENTSTHREAD": {"POST": {
159
+ "DATE": "29-Apr-2016",
160
+ "VENDORCOMMENT": "&#13;<br>&#13;<br>Thank you for your feedback and we are very sorry the perfume smell affected your enjoyment of the tour.&#13;<br>&#13;<br>We can only assume it was a fellow passenger&rsquo;s perfume which caused the issue and as I&rsquo;m sure you can appreciate, we can&rsquo;t control this. Our coaches are cleaned with a Eucalyptus-based floor wash and we do not have any automated air-fresheners on board.&#13;<br>&#13;<br>We hope you enjoyed the itinerary and the destinations visited.&#13;<br>&#13;<br>Kind regards,&#13;<br>&#13;<br>Ian Everitt&#13;<br>Sales Centre Manager<br><br>"
161
+ }},
162
+ "HREVIEWDATE": "2016-04-28T09:53:09",
163
+ "HREVIEWRATING": 2,
164
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
165
+ "PRODUCTCODE": "HTCC",
166
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101194",
167
+ "SERVICERATING": "-",
168
+ "SHORTCUSTOMERCOMMENT": "The bus was filled with some smelly perfume, which makes passenge feel very sick all the way. Not a pleasant experience on this day trip. Dad will never go by tour again.",
169
+ "SHORTVENDORCOMMENT": "Thank you for your feedback and we are very sorry the perfume smell affected your enjoyment of the tour.&#13;<br/>&#13;<br/>We can only assume it was a fellow passenger&rsquo;s perfume which caused the issue and as I&rsquo;m sure you can appreciate, we can&rsquo;t control this. Our coaches are cleaned with ...",
170
+ "VENDORCOMMENT": "Thank you for your feedback and we are very sorry the perfume smell affected your enjoyment of the tour.&#13;<br/>&#13;<br/>We can only assume it was a fellow passenger&rsquo;s perfume which caused the issue and as I&rsquo;m sure you can appreciate, we can&rsquo;t control this. Our coaches are cleaned with a Eucalyptus-based floor wash and we do not have any automated air-fresheners on board.&#13;<br/>&#13;<br/>We hope you enjoyed the itinerary and the destinations visited.&#13;<br/>&#13;<br/>Kind regards,&#13;<br/>&#13;<br/>Ian Everitt&#13;<br/>Sales Centre Manager"
171
+ },
172
+ {
173
+ "COUNT": 9,
174
+ "CUSTOMERCOMMENT": "An excellent day and well organised. The only problem which was not as well set up was the dinner before boarding the ferry on the way back. Choices were limited for a busload of people arriving at places all at once. It was not helped that there was only one person on duty at the cafe at the ferry terminal serving customers and making hot drinks.",
175
+ "DATE": "28-Apr-2016",
176
+ "DESCRIPTION": "KI Experience",
177
+ "FACEBOOKSHARELINK": "http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.feefo.com%2FAU%2Fen%2Freviews%2FSeaLink-Kangaroo-Island_Tours%2F%3Fid%3D987195%26servicefeedbackid%3D101011",
178
+ "FEEDBACKID": 101011,
179
+ "HREVIEWDATE": "2016-04-28T04:51:26",
180
+ "HREVIEWRATING": 5,
181
+ "LINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
182
+ "PRODUCTCODE": "HTCC",
183
+ "READMOREURL": "http://www.feefo.com/AU/en/reviews/SeaLink-Kangaroo-Island_Tours/?id=987195&servicefeedbackid=101011",
184
+ "SERVICERATING": "++",
185
+ "SHORTCUSTOMERCOMMENT": "An excellent day and well organised. The only problem which was not as well set up was the dinner before boarding the ferry on the way back. Choices were limited for a busload of people arriving at places all at once. It was not helped that there was only one person on duty at the cafe at the ferry ..."
186
+ }
187
+ ],
188
+ "SUMMARY": {
189
+ "AVERAGE": 97,
190
+ "BEST": 100,
191
+ "COUNT": 352,
192
+ "LIMIT": 9,
193
+ "MODE": "service",
194
+ "PRODUCTLINK": "http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/",
195
+ "START": 1,
196
+ "SUPPLIERLOGO": "http://www.feefo.com/feefo/getnonpublicfile.jsp?vendorimage=987195&vendorimageext=file.png",
197
+ "TITLE": "KI Experience",
198
+ "TOTALPRODUCTCOUNT": 0,
199
+ "TOTALSERVICECOUNT": 352,
200
+ "VENDORLOGON": "www.sealinktravelgroup.com.au/SeaLink KI",
201
+ "VENDORREF": "HTCC",
202
+ "WORST": 0
203
+ }
204
+ }}
205
+ http_version:
206
+ recorded_at: Wed, 04 May 2016 04:53:09 GMT
207
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+ require 'feefo/review_fetcher'
3
+ require 'feefo/remote_review_fetcher'
4
+
5
+ describe "Fetching a set of reviews" do
6
+ let(:cache) { double(read: nil, write: nil) }
7
+
8
+ let(:feefo_review_fetcher) do
9
+ config = {
10
+ logon: 'www.sealinktravelgroup.com.au',
11
+ division: 'SeaLink KI',
12
+ time_to_cache_reviews: 25,
13
+ review_limit: 9
14
+ }
15
+ Feefo::ReviewFetcher.new({code: 'HTCC'}, config, cache)
16
+ end
17
+
18
+ subject(:reviews) do
19
+ VCR.use_cassette('feefo_reviews_with_feedback') do
20
+ feefo_review_fetcher.fetch_reviews_json
21
+ end
22
+ end
23
+
24
+ it 'should return a String' do
25
+ expect(reviews).to be_an_instance_of(String)
26
+ end
27
+
28
+ context 'when converted to json' do
29
+ subject(:json) { JSON.load(reviews) }
30
+
31
+ it { should be_a(Hash) }
32
+ it { should include 'FEEDBACKLIST' }
33
+
34
+ context 'its FEEDBACK list' do
35
+ let(:feedback) { json['FEEDBACKLIST']['FEEDBACK'] }
36
+ subject(:feedback_length) { feedback.length }
37
+
38
+ it { should eq 9 }
39
+
40
+ context 'its first FEEDBACK element' do
41
+ subject { feedback.first }
42
+ it { should be_a(Hash) }
43
+ it { should include 'SERVICERATING' }
44
+ # These guys are optional keys:
45
+ # it { should include *%w(SERVICERATING CUSTOMERCOMMENT VENDORCOMMENT) }
46
+ end
47
+ end
48
+
49
+ context 'its SUMMARY' do
50
+ subject { json['FEEDBACKLIST']['SUMMARY'] }
51
+ it { should include *%w(COUNT AVERAGE) }
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'feefo'
3
+
4
+ describe 'Feefo' do
5
+ before do
6
+ Feefo.config = {
7
+ 'logon' => 'www.link.com',
8
+ 'division' => 'My Brand',
9
+ 'name' => 'My Company'
10
+ }
11
+ end
12
+
13
+ it 'should determine url' do
14
+ expected_url = 'https://www.feefo.com/reviews/My%20Company/?logon=www.link.com/My%20Brand'
15
+ expect(Feefo.review_base_url).to eq expected_url
16
+ end
17
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ describe Feefo::Reviews do
4
+ let(:cache) { double(read: nil, write: nil) }
5
+ let(:feefo_review_fetcher) do
6
+ config = {
7
+ logon: 'www.sealinktravelgroup.com.au',
8
+ division: 'SeaLink KI',
9
+ time_to_cache_reviews: 25,
10
+ review_limit: 9
11
+ }
12
+ Feefo::ReviewFetcher.new({code: 'HTCC'}, config, cache)
13
+ end
14
+ let(:data) do
15
+ VCR.use_cassette('feefo_reviews_with_feedback') do
16
+ JSON.parse(feefo_review_fetcher.fetch_reviews_json)
17
+ end
18
+ end
19
+ subject(:reviews) { Feefo::Reviews.new(data) }
20
+
21
+ it 'should parse reviews' do
22
+ expect(reviews.average).to eq 97
23
+ expect(reviews.count).to eq 352
24
+ end
25
+ let(:hours_ago_regex) { /[0-9]{1,2} Hour\(s\) ago/ }
26
+ let(:time_regex) { /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}/ }
27
+ let(:date_regex) { /[0-9]{1,2}-[A-Z][a-z][a-z]-[0-9]{4}/ }
28
+
29
+ context 'latest reviews' do
30
+ subject(:review) { reviews.reviews.first }
31
+ it 'should have the various aspects' do
32
+ expect(review.customer_comment).to be_a(String)
33
+ expect(review.vendor_comment).to be nil
34
+ expect(review.description).to eq 'KI Experience'
35
+ expect(review.service_rating).to eq '++'
36
+ expect(review.review_date).to match time_regex
37
+ expect(review.review_rating).to eq 5
38
+ expect(review.link).to eq 'http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/'
39
+ expect(review.date).to match hours_ago_regex
40
+ expect(review.data).to be_a(Hash)
41
+ end
42
+ end
43
+
44
+ context 'oldest reviews' do
45
+ subject(:review) { reviews.reviews.last }
46
+ it 'should have the various aspects' do
47
+ expect(review.customer_comment).to be_a(String)
48
+ expect(review.vendor_comment).to be nil
49
+ expect(review.description).to eq 'KI Experience'
50
+ expect(review.service_rating).to eq '++'
51
+ expect(review.review_date).to match time_regex
52
+ expect(review.review_rating).to eq 5
53
+ expect(review.link).to eq 'http://www.sealink.com.au/kangaroo-island-tours/1-day-tours/kangaroo-island-highlights-day-tour/'
54
+ expect(review.date).to match date_regex
55
+ expect(review.data).to be_a(Hash)
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../app/models', __FILE__)
2
+
3
+ require 'support/vcr_loader'
4
+ require 'support/coverage_loader'
5
+ require 'feefo'
@@ -0,0 +1,4 @@
1
+ require 'simplecov-rcov'
2
+ require 'coveralls'
3
+ require 'coverage/kit'
4
+ Coverage::Kit.setup(minimum_coverage: 96.3)
@@ -0,0 +1,7 @@
1
+ require 'vcr'
2
+ require 'webmock/rspec'
3
+
4
+ VCR.configure do |c|
5
+ c.cassette_library_dir = 'spec/cassettes'
6
+ c.hook_into :webmock
7
+ end
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feefo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Noack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: coverage-kit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov-rcov
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'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: travis
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ description: Methods to fetch and show feefo reviews
154
+ email:
155
+ - support@travellink.com.au
156
+ executables: []
157
+ extensions: []
158
+ extra_rdoc_files: []
159
+ files:
160
+ - ".gitignore"
161
+ - ".travis.yml"
162
+ - CHANGELOG.md
163
+ - Gemfile
164
+ - README.md
165
+ - Rakefile
166
+ - feefo.gemspec
167
+ - feefo.yml.example
168
+ - lib/feefo.rb
169
+ - lib/feefo/remote_review_fetcher.rb
170
+ - lib/feefo/review.rb
171
+ - lib/feefo/review_fetcher.rb
172
+ - lib/feefo/reviews.rb
173
+ - lib/feefo/version.rb
174
+ - spec/badge_spec.rb
175
+ - spec/cassettes/feefo_reviews_with_feedback.yml
176
+ - spec/feefo_review_fetcher_spec.rb
177
+ - spec/feefo_spec.rb
178
+ - spec/reviews_spec.rb
179
+ - spec/spec_helper.rb
180
+ - spec/support/coverage_loader.rb
181
+ - spec/support/vcr_loader.rb
182
+ homepage: https://github.com/sealink/feefo
183
+ licenses:
184
+ - MIT
185
+ metadata: {}
186
+ post_install_message:
187
+ rdoc_options: []
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ required_rubygems_version: !ruby/object:Gem::Requirement
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ version: '0'
200
+ requirements: []
201
+ rubyforge_project:
202
+ rubygems_version: 2.4.8
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: Methods to fetch and shwo feefo reviews
206
+ test_files:
207
+ - spec/badge_spec.rb
208
+ - spec/cassettes/feefo_reviews_with_feedback.yml
209
+ - spec/feefo_review_fetcher_spec.rb
210
+ - spec/feefo_spec.rb
211
+ - spec/reviews_spec.rb
212
+ - spec/spec_helper.rb
213
+ - spec/support/coverage_loader.rb
214
+ - spec/support/vcr_loader.rb