radiant-feefo-extension 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +39 -18
- data/app/controllers/feefo_controller.rb +2 -2
- data/app/models/feefo.rb +11 -0
- data/app/models/feefo_review_fetcher.rb +10 -8
- data/app/models/feefo_reviews.rb +28 -0
- data/app/models/remote_feefo_review_fetcher.rb +2 -1
- data/config/routes.rb +5 -2
- data/lib/radiant-feefo-extension.rb +2 -2
- data/radiant-feefo-extension.gemspec +10 -4
- metadata +21 -6
data/Gemfile.lock
CHANGED
@@ -9,11 +9,13 @@ PATH
|
|
9
9
|
specs:
|
10
10
|
radiant-feefo-extension (0.0.2)
|
11
11
|
radiant (>= 1.0.0.rc2)
|
12
|
+
yamload (~> 0.2)
|
12
13
|
|
13
14
|
GEM
|
14
15
|
remote: https://rubygems.org/
|
15
16
|
specs:
|
16
17
|
RedCloth (4.2.9)
|
18
|
+
abstract_type (0.0.7)
|
17
19
|
actionmailer (2.3.18)
|
18
20
|
actionpack (= 2.3.18)
|
19
21
|
actionpack (2.3.18)
|
@@ -25,8 +27,16 @@ GEM
|
|
25
27
|
activesupport (= 2.3.18)
|
26
28
|
activesupport (2.3.18)
|
27
29
|
acts_as_tree (0.1.1)
|
28
|
-
|
29
|
-
|
30
|
+
adamantium (0.2.0)
|
31
|
+
ice_nine (~> 0.11.0)
|
32
|
+
memoizable (~> 0.4.0)
|
33
|
+
addressable (2.3.7)
|
34
|
+
anima (0.2.0)
|
35
|
+
abstract_type (~> 0.0.7)
|
36
|
+
adamantium (~> 0.1)
|
37
|
+
equalizer (~> 0.0.8)
|
38
|
+
chunky_png (1.3.4)
|
39
|
+
classy_hash (0.1.3)
|
30
40
|
compass (0.12.7)
|
31
41
|
chunky_png (~> 1.2)
|
32
42
|
fssm (>= 0.2.7)
|
@@ -37,10 +47,15 @@ GEM
|
|
37
47
|
safe_yaml (~> 1.0.0)
|
38
48
|
delocalize (0.2.6)
|
39
49
|
diff-lcs (1.2.5)
|
50
|
+
equalizer (0.0.9)
|
51
|
+
facets (3.0.0)
|
40
52
|
fssm (0.2.10)
|
41
53
|
haml (3.1.8)
|
42
54
|
highline (1.6.21)
|
43
|
-
|
55
|
+
ice_nine (0.11.1)
|
56
|
+
json (1.8.2)
|
57
|
+
memoizable (0.4.2)
|
58
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
44
59
|
rack (1.1.6)
|
45
60
|
rack-cache (1.2)
|
46
61
|
rack (>= 0.4)
|
@@ -70,31 +85,37 @@ GEM
|
|
70
85
|
activeresource (= 2.3.18)
|
71
86
|
activesupport (= 2.3.18)
|
72
87
|
rake (>= 0.8.3)
|
73
|
-
rake (10.4.
|
74
|
-
rdoc (4.
|
88
|
+
rake (10.4.2)
|
89
|
+
rdoc (4.2.0)
|
75
90
|
json (~> 1.4)
|
76
|
-
redis (
|
77
|
-
rspec (3.
|
78
|
-
rspec-core (~> 3.
|
79
|
-
rspec-expectations (~> 3.
|
80
|
-
rspec-mocks (~> 3.
|
81
|
-
rspec-core (3.
|
82
|
-
rspec-support (~> 3.
|
83
|
-
rspec-expectations (3.
|
91
|
+
redis (3.2.1)
|
92
|
+
rspec (3.2.0)
|
93
|
+
rspec-core (~> 3.2.0)
|
94
|
+
rspec-expectations (~> 3.2.0)
|
95
|
+
rspec-mocks (~> 3.2.0)
|
96
|
+
rspec-core (3.2.0)
|
97
|
+
rspec-support (~> 3.2.0)
|
98
|
+
rspec-expectations (3.2.0)
|
84
99
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
|
-
rspec-support (~> 3.
|
86
|
-
rspec-mocks (3.
|
87
|
-
|
88
|
-
|
100
|
+
rspec-support (~> 3.2.0)
|
101
|
+
rspec-mocks (3.2.0)
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
+
rspec-support (~> 3.2.0)
|
104
|
+
rspec-support (3.2.1)
|
89
105
|
safe_yaml (1.0.4)
|
90
106
|
sass (3.2.19)
|
91
107
|
stringex (1.3.3)
|
92
|
-
|
108
|
+
thread_safe (0.3.4)
|
109
|
+
tzinfo (0.3.43)
|
93
110
|
vcr (2.9.3)
|
94
111
|
webmock (1.20.4)
|
95
112
|
addressable (>= 2.3.6)
|
96
113
|
crack (>= 0.3.2)
|
97
114
|
will_paginate (2.3.16)
|
115
|
+
yamload (0.2.0)
|
116
|
+
anima (~> 0.2)
|
117
|
+
classy_hash (~> 0.1)
|
118
|
+
facets (~> 3.0)
|
98
119
|
|
99
120
|
PLATFORMS
|
100
121
|
ruby
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
|
3
|
-
class FeefoController <
|
3
|
+
class FeefoController < SiteController
|
4
4
|
|
5
5
|
def fetch_reviews
|
6
6
|
code = params[:product_code]
|
7
7
|
reviews = FeefoReviewFetcher.new(code).fetch_reviews
|
8
8
|
render json: reviews, status: 200
|
9
9
|
end
|
10
|
-
end
|
10
|
+
end
|
data/app/models/feefo.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
module Feefo
|
2
|
+
def self.config
|
3
|
+
@config ||= Yamload::Loader.new(:feefo, Rails.root.join('config')).loaded_hash
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.review_base_url
|
7
|
+
name = URI.encode(config['name'])
|
8
|
+
account = URI.encode(config['account'])
|
9
|
+
"http://www.feefo.com/reviews/#{name}/?logon=#{account}"
|
10
|
+
end
|
11
|
+
end
|
@@ -2,13 +2,15 @@ class FeefoReviewFetcher
|
|
2
2
|
|
3
3
|
attr_reader :code, :feefo_config
|
4
4
|
|
5
|
-
def initialize(code, feefo_config=
|
5
|
+
def initialize(code, feefo_config = Feefo.config)
|
6
6
|
@code = code
|
7
7
|
@feefo_config = feefo_config
|
8
|
-
@redis = Redis.new
|
8
|
+
@redis = Redis.new(host: redis_config['host'],
|
9
|
+
port: redis_config['port'],
|
10
|
+
db: redis_config['db'])
|
9
11
|
end
|
10
12
|
|
11
|
-
def
|
13
|
+
def fetch_reviews_json
|
12
14
|
with_caching do
|
13
15
|
RemoteFeefoReviewFetcher.new(code, feefo_config).fetch_reviews
|
14
16
|
end
|
@@ -16,10 +18,6 @@ class FeefoReviewFetcher
|
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
|
-
def load_feefo_config
|
20
|
-
YamlConfiguration.new(Rails.root.join('config/feefo.yml')).data
|
21
|
-
end
|
22
|
-
|
23
21
|
def with_caching
|
24
22
|
fetch_from_cache.presence || yield.tap { |reviews| store_in_cache(reviews) }
|
25
23
|
end
|
@@ -36,4 +34,8 @@ class FeefoReviewFetcher
|
|
36
34
|
"feefo_reviews_for_#{code}"
|
37
35
|
end
|
38
36
|
|
39
|
-
|
37
|
+
def redis_config
|
38
|
+
@redis_config ||= Yamload::Loader.new(:redis, Rails.root.join('config')).loaded_hash[Rails.env]
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class FeefoReviews
|
2
|
+
attr_reader :reviews, :summary
|
3
|
+
|
4
|
+
def initialize(code)
|
5
|
+
data = fetch_reviews_json(code)
|
6
|
+
return unless data
|
7
|
+
|
8
|
+
@reviews = Array.wrap(data['FEEDBACKLIST']['FEEDBACK'])
|
9
|
+
@summary = data['FEEDBACKLIST']['SUMMARY']
|
10
|
+
end
|
11
|
+
|
12
|
+
def average
|
13
|
+
@summary['AVERAGE']
|
14
|
+
end
|
15
|
+
|
16
|
+
def count
|
17
|
+
@summary['COUNT']
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def fetch_reviews_json(feefo_code)
|
23
|
+
fetcher = FeefoReviewFetcher.new(feefo_code)
|
24
|
+
JSON.parse(fetcher.fetch_reviews_json)
|
25
|
+
rescue JSON::ParserError => e
|
26
|
+
nil
|
27
|
+
end
|
28
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
ActionController::Routing::Routes.draw do |map|
|
2
2
|
|
3
|
-
map.feefo_fetch_reviews
|
3
|
+
map.feefo_fetch_reviews '/feefo/fetch_reviews/:product_code',
|
4
|
+
controller: :feefo,
|
5
|
+
action: 'fetch_reviews',
|
6
|
+
conditions: {method: :get}
|
4
7
|
|
5
|
-
end
|
8
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module RadiantFeefoExtension
|
2
|
-
VERSION = '0.0.
|
3
|
-
end
|
2
|
+
VERSION = '0.0.3'
|
3
|
+
end
|
@@ -2,17 +2,19 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
+
lib = File.expand_path('../lib', __FILE__)
|
6
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
7
|
+
require 'radiant-feefo-extension'
|
5
8
|
|
6
9
|
Gem::Specification.new do |s|
|
7
10
|
s.name = "radiant-feefo-extension"
|
8
|
-
s.version =
|
9
|
-
|
11
|
+
s.version = RadiantFeefoExtension::VERSION
|
10
12
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
13
|
s.authors = ["Stefan Kojic"]
|
12
14
|
s.date = "2014-12-02"
|
13
15
|
s.description = ""
|
14
16
|
s.email = "support@travellink.com.au"
|
15
|
-
s.homepage = "https://github.com/
|
17
|
+
s.homepage = "https://github.com/sealink/radiant-feefo-extension"
|
16
18
|
s.require_paths = ["lib"]
|
17
19
|
s.summary = ""
|
18
20
|
|
@@ -22,6 +24,8 @@ Gem::Specification.new do |s|
|
|
22
24
|
s.add_development_dependency('webmock')
|
23
25
|
s.add_development_dependency('redis')
|
24
26
|
|
27
|
+
s.add_dependency 'yamload', '~> 0.2'
|
28
|
+
|
25
29
|
if s.respond_to? :specification_version then
|
26
30
|
s.specification_version = 3
|
27
31
|
|
@@ -41,7 +45,9 @@ Gem::Specification.new do |s|
|
|
41
45
|
README.md
|
42
46
|
Rakefile
|
43
47
|
app/controllers/feefo_controller.rb
|
48
|
+
app/models/feefo.rb
|
44
49
|
app/models/feefo_review_fetcher.rb
|
50
|
+
app/models/feefo_reviews.rb
|
45
51
|
app/models/remote_feefo_review_fetcher.rb
|
46
52
|
config/feefo.yml.example
|
47
53
|
config/routes.rb
|
@@ -55,4 +61,4 @@ Gem::Specification.new do |s|
|
|
55
61
|
]
|
56
62
|
# = MANIFEST =
|
57
63
|
|
58
|
-
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-feefo-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ! '>='
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: yamload
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.2'
|
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: '0.2'
|
94
110
|
- !ruby/object:Gem::Dependency
|
95
111
|
name: radiant
|
96
112
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +134,9 @@ files:
|
|
118
134
|
- README.md
|
119
135
|
- Rakefile
|
120
136
|
- app/controllers/feefo_controller.rb
|
137
|
+
- app/models/feefo.rb
|
121
138
|
- app/models/feefo_review_fetcher.rb
|
139
|
+
- app/models/feefo_reviews.rb
|
122
140
|
- app/models/remote_feefo_review_fetcher.rb
|
123
141
|
- config/feefo.yml.example
|
124
142
|
- config/routes.rb
|
@@ -129,7 +147,7 @@ files:
|
|
129
147
|
- spec/cassettes/feefo_reviews_with_feedback.yml
|
130
148
|
- spec/feefo_review_fetcher_spec.rb
|
131
149
|
- spec/spec_helper.rb
|
132
|
-
homepage: https://github.com/
|
150
|
+
homepage: https://github.com/sealink/radiant-feefo-extension
|
133
151
|
licenses: []
|
134
152
|
post_install_message:
|
135
153
|
rdoc_options: []
|
@@ -141,9 +159,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
159
|
- - ! '>='
|
142
160
|
- !ruby/object:Gem::Version
|
143
161
|
version: '0'
|
144
|
-
segments:
|
145
|
-
- 0
|
146
|
-
hash: 3083003707786389768
|
147
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
163
|
none: false
|
149
164
|
requirements:
|
@@ -152,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
167
|
version: '0'
|
153
168
|
requirements: []
|
154
169
|
rubyforge_project:
|
155
|
-
rubygems_version: 1.8.
|
170
|
+
rubygems_version: 1.8.23.2
|
156
171
|
signing_key:
|
157
172
|
specification_version: 3
|
158
173
|
summary: ''
|