bazaar_voice 0.1.0 → 0.1.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 +4 -4
- data/README.md +1 -1
- data/bazaar_voice.gemspec +1 -0
- data/lib/bazaar_voice/version.rb +1 -1
- data/lib/bazaar_voice.rb +19 -8
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87bbb2dffddaa2f59f2f47d626b0ec21fcdcfb6a
|
4
|
+
data.tar.gz: 2306e2c63f10bb6148ad39665fbe674e12821ce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6599ba3565c98a41fc9025aedd5d57e30501ba37acf4f2bc210f114443d988aff583832cfd75313bad89de1f87afe3459be50466ba2fe0119e895140a0c8983d
|
7
|
+
data.tar.gz: d804960ee5400b32e804c14a6f77b33a08b4c0fabdaf2ec4513f1a2c443bd09123e3ba5e3fdc8b7eada83fbff2aa13e06572537c8cfab764d98295180f570c4b
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
```
|
23
|
-
BizaarVoice::Api.
|
23
|
+
BizaarVoice::Api.configure do |c|
|
24
24
|
c.passkey = 'YOUR_API_KEY_GOES_HERE'
|
25
25
|
c.protocol = 'http' # defautls to 'https'
|
26
26
|
c.host = 'stg.api.bazaarvoice.com' # defautls to production. i.e.: 'api.bazaarvoice.com'
|
data/bazaar_voice.gemspec
CHANGED
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_development_dependency 'guard-rubocop', '~> 1.2', '>= 1.2.0'
|
28
28
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.3', '>= 1.3.0'
|
29
29
|
spec.add_runtime_dependency 'rest-client', '~> 1.8', '>= 1.8.0'
|
30
|
+
spec.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
30
31
|
end
|
data/lib/bazaar_voice/version.rb
CHANGED
data/lib/bazaar_voice.rb
CHANGED
@@ -18,36 +18,47 @@ module BazaarVoice
|
|
18
18
|
yield(configuration)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
# Some metaprogramming to define many similar methods.
|
22
|
+
%w(reviews categories stories questions comments answers authors products statistics).each do |resource|
|
23
|
+
define_method("get_#{resource}") do |argument = nil|
|
23
24
|
get(resource, argument)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
27
28
|
private
|
28
29
|
|
29
|
-
def
|
30
|
-
|
30
|
+
def rest_client
|
31
|
+
@rest_client ||= rest_client_with_logger
|
31
32
|
end
|
32
33
|
|
33
|
-
def
|
34
|
+
def rest_client_with_logger
|
35
|
+
RestClient.log = configuration.logger
|
36
|
+
RestClient
|
37
|
+
end
|
38
|
+
|
39
|
+
def get(resource, params = nil)
|
40
|
+
JSON.parse rest_client.get(uri(resource, params))
|
41
|
+
end
|
42
|
+
|
43
|
+
def uri(resource, params = nil)
|
34
44
|
"#{configuration.protocol}://#{configuration.host}/data/#{resource}.#{configuration.format}#{query_string(params)}"
|
35
45
|
end
|
36
46
|
|
37
|
-
def query_string(params)
|
38
|
-
all_params = { passkey: configuration.passkey, apiversion: configuration.apiversion }.merge(params)
|
47
|
+
def query_string(params = nil)
|
48
|
+
all_params = { passkey: configuration.passkey, apiversion: configuration.apiversion }.merge(params || {})
|
39
49
|
'?' + all_params.map { |k, v| "#{k}=#{v}" }.join('&')
|
40
50
|
end
|
41
51
|
end
|
42
52
|
end
|
43
53
|
|
44
54
|
class Configuration
|
45
|
-
attr_accessor :passkey, :apiversion, :host, :resource, :protocol, :format
|
55
|
+
attr_accessor :passkey, :apiversion, :host, :resource, :protocol, :format, :logger
|
46
56
|
def initialize
|
47
57
|
@apiversion = '5.4'
|
48
58
|
@host = 'api.bazaarvoice.com'
|
49
59
|
@protocol = 'https'
|
50
60
|
@format = 'json'
|
61
|
+
@logger = $stdout
|
51
62
|
end
|
52
63
|
end
|
53
64
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bazaar_voice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Shelton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -158,6 +158,26 @@ dependencies:
|
|
158
158
|
- - ">="
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: 1.8.0
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: json
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '1.8'
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 1.8.3
|
171
|
+
type: :runtime
|
172
|
+
prerelease: false
|
173
|
+
version_requirements: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '1.8'
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 1.8.3
|
161
181
|
description: Talk to Bazzar Voice API's with this handy gem
|
162
182
|
email:
|
163
183
|
- dshelt2@searshc.com
|