rsqoot 0.5.5 → 0.5.6
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 +7 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/Gemfile.lock +20 -12
- data/README.md +16 -3
- data/Rakefile +1 -1
- data/lib/rsqoot.rb +13 -10
- data/lib/rsqoot/category.rb +3 -4
- data/lib/rsqoot/click.rb +4 -4
- data/lib/rsqoot/client.rb +12 -12
- data/lib/rsqoot/commission.rb +3 -4
- data/lib/rsqoot/deal.rb +11 -13
- data/lib/rsqoot/helper.rb +17 -18
- data/lib/rsqoot/logger.rb +7 -7
- data/lib/rsqoot/merchant.rb +3 -4
- data/lib/rsqoot/provider.rb +3 -4
- data/lib/rsqoot/request.rb +8 -9
- data/lib/rsqoot/version.rb +1 -1
- data/rsqoot.gemspec +1 -1
- data/spec/spec_helper.rb +17 -0
- metadata +37 -37
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 52108f00df49a72b00a891feb8926305611c6fa8
|
4
|
+
data.tar.gz: 4bfc1bd06f2adacc39055b67567552076b6ed12a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7cb8c9e6beeea8743624af02851f3196fc03f87ebd3f84c328604774df5b7cd11b1dc503613c757260145b879b11717aedb4dcf14218c6084c8be32847f13809
|
7
|
+
data.tar.gz: 386407cc0d184accdc9be5b1a96b93ee8be72ab9d753ec2a00fc639b943dd3bac50507c4840fd2a58bd329a1681fd83432a8633139892b90e60ceebb11afb3d0
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rsqoot (0.5.
|
4
|
+
rsqoot (0.5.6)
|
5
5
|
activesupport (>= 3.0.0)
|
6
6
|
hashie (>= 2.0.0)
|
7
7
|
json (>= 1.6.0)
|
@@ -9,22 +9,29 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (4.0
|
13
|
-
i18n (~> 0.6, >= 0.6.
|
14
|
-
|
15
|
-
|
12
|
+
activesupport (4.1.0)
|
13
|
+
i18n (~> 0.6, >= 0.6.9)
|
14
|
+
json (~> 1.7, >= 1.7.7)
|
15
|
+
minitest (~> 5.1)
|
16
16
|
thread_safe (~> 0.1)
|
17
|
-
tzinfo (~>
|
18
|
-
|
17
|
+
tzinfo (~> 1.1)
|
18
|
+
diff-lcs (1.2.5)
|
19
19
|
hashie (2.0.5)
|
20
20
|
i18n (0.6.9)
|
21
21
|
json (1.8.1)
|
22
|
-
minitest (
|
23
|
-
multi_json (1.8.4)
|
22
|
+
minitest (5.3.3)
|
24
23
|
rake (10.1.1)
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
rspec (2.14.1)
|
25
|
+
rspec-core (~> 2.14.0)
|
26
|
+
rspec-expectations (~> 2.14.0)
|
27
|
+
rspec-mocks (~> 2.14.0)
|
28
|
+
rspec-core (2.14.8)
|
29
|
+
rspec-expectations (2.14.5)
|
30
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
31
|
+
rspec-mocks (2.14.6)
|
32
|
+
thread_safe (0.3.3)
|
33
|
+
tzinfo (1.1.0)
|
34
|
+
thread_safe (~> 0.1)
|
28
35
|
|
29
36
|
PLATFORMS
|
30
37
|
ruby
|
@@ -32,4 +39,5 @@ PLATFORMS
|
|
32
39
|
DEPENDENCIES
|
33
40
|
bundler (>= 1.0.0)
|
34
41
|
rake
|
42
|
+
rspec
|
35
43
|
rsqoot!
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
RSqoot
|
1
|
+
RSqoot [](https://travis-ci.org/lyfeyaj/rsqoot)
|
2
2
|
======
|
3
3
|
|
4
4
|
A Ruby Wrapper for [Sqoot](http://www.sqoot.com) [API V2](http://docs.sqoot.com/v2/overview.html). With Auto-caching for all APIS, and Auto-increment for deals.
|
@@ -85,13 +85,13 @@ SqootClient.categories(query: 'home,health')
|
|
85
85
|
SqootClient.commissions
|
86
86
|
# => returns current month commissions
|
87
87
|
|
88
|
-
SqootClient.commissions(from: '
|
88
|
+
SqootClient.commissions(from: '2014-01-01', to: '2014-01-20')
|
89
89
|
# => returns commissions using date_range :from & :to
|
90
90
|
|
91
91
|
SqootClient.clicks
|
92
92
|
# => returns real-time clicks from the event request limit of 1000
|
93
93
|
|
94
|
-
SqootClient.clicks(from: '
|
94
|
+
SqootClient.clicks(from: '2014-01-01', to: '2014-01-20')
|
95
95
|
# => returns clicks using date_range :from & :to
|
96
96
|
```
|
97
97
|
|
@@ -130,3 +130,16 @@ SqootClient.total_sqoot_deals(query: 'Home', page: 2, per_page: 20, category_slu
|
|
130
130
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
131
131
|
4. Push to the branch (`git push origin my-new-feature`)
|
132
132
|
5. Create new Pull Request
|
133
|
+
|
134
|
+
## LICENCE
|
135
|
+
|
136
|
+
MIT
|
137
|
+
|
138
|
+
## Author
|
139
|
+
|
140
|
+
[Felix Liu](https://github.com/lyfeyaj)
|
141
|
+
|
142
|
+
## TODO
|
143
|
+
|
144
|
+
+ Add fully test specs
|
145
|
+
+ Use memcached to cache records
|
data/Rakefile
CHANGED
data/lib/rsqoot.rb
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'active_support/core_ext'
|
2
|
+
require 'rsqoot/client'
|
3
|
+
require 'rsqoot/logger'
|
4
4
|
|
5
5
|
module RSqoot
|
6
6
|
|
7
7
|
class << self
|
8
|
-
attr_accessor :public_api_key,
|
8
|
+
attr_accessor :public_api_key,
|
9
|
+
:private_api_key,
|
10
|
+
:base_api_url,
|
11
|
+
:authentication_method,
|
12
|
+
:read_timeout,
|
13
|
+
:expired_in
|
9
14
|
|
10
15
|
# Configure default credentials easily
|
11
16
|
#
|
@@ -13,15 +18,15 @@ module RSqoot
|
|
13
18
|
def configure
|
14
19
|
load_defaults
|
15
20
|
yield self
|
16
|
-
|
17
|
-
|
18
|
-
|
21
|
+
fail 'You must add your own public api key to initializer .' if public_api_key.nil?
|
22
|
+
fail 'You must add your own private api key to initializer .' if private_api_key.nil?
|
23
|
+
fail 'Authentication method must be :header or :parameter .' unless AUTHENTICATION_METHODS.include? authentication_method
|
19
24
|
SqootClient.reload!
|
20
25
|
true
|
21
26
|
end
|
22
27
|
|
23
28
|
def load_defaults
|
24
|
-
self.base_api_url ||=
|
29
|
+
self.base_api_url ||= 'https://api.sqoot.com'
|
25
30
|
self.authentication_method = :header
|
26
31
|
self.read_timeout = 60.seconds
|
27
32
|
self.expired_in = 1.hour
|
@@ -30,9 +35,7 @@ module RSqoot
|
|
30
35
|
private
|
31
36
|
|
32
37
|
AUTHENTICATION_METHODS = [:header, :parameter]
|
33
|
-
|
34
38
|
end
|
35
|
-
|
36
39
|
end
|
37
40
|
|
38
41
|
begin
|
data/lib/rsqoot/category.rb
CHANGED
@@ -4,7 +4,7 @@ module RSqoot
|
|
4
4
|
# Retrieve a list of categories base on the following parameters
|
5
5
|
#
|
6
6
|
# @return [RSqoot::SqootCategory] category list
|
7
|
-
def categories(options={})
|
7
|
+
def categories(options = {})
|
8
8
|
options = update_by_expire_time options
|
9
9
|
query = options.delete(:query)
|
10
10
|
if categories_not_latest?(options)
|
@@ -12,9 +12,8 @@ module RSqoot
|
|
12
12
|
@rsqoot_categories = @rsqoot_categories.categories.map(&:category) if @rsqoot_categories
|
13
13
|
end
|
14
14
|
result = query.present? ? query_categories(query) : @rsqoot_categories
|
15
|
-
logger(
|
15
|
+
logger(uri: sqoot_query_uri, records: result, type: 'categories', opts: options)
|
16
16
|
result
|
17
17
|
end
|
18
|
-
|
19
18
|
end
|
20
|
-
end
|
19
|
+
end
|
data/lib/rsqoot/click.rb
CHANGED
@@ -7,15 +7,15 @@ module RSqoot
|
|
7
7
|
# @param [String] :from End date
|
8
8
|
#
|
9
9
|
# @return [RSqoot::SqootClick]
|
10
|
-
def clicks(options={})
|
10
|
+
def clicks(options = {})
|
11
11
|
options = update_by_expire_time options
|
12
12
|
if clicks_not_latest?(options)
|
13
13
|
@rsqoot_clicks = get('clicks', options, SqootClick)
|
14
14
|
@rsqoot_clicks = @rsqoot_clicks.clicks if @rsqoot_clicks
|
15
|
+
@rsqoot_clicks = @rsqoot_clicks.clicks.map(&:click) if @rsqoot_clicks.clicks
|
15
16
|
end
|
16
|
-
logger(
|
17
|
+
logger(uri: sqoot_query_uri, records: @rsqoot_clicks, type: 'clicks', opts: options)
|
17
18
|
@rsqoot_clicks
|
18
19
|
end
|
19
|
-
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
data/lib/rsqoot/client.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
1
|
+
require 'singleton'
|
2
|
+
require 'rsqoot/helper'
|
3
|
+
require 'rsqoot/merchant'
|
4
|
+
require 'rsqoot/category'
|
5
|
+
require 'rsqoot/provider'
|
6
|
+
require 'rsqoot/commission'
|
7
|
+
require 'rsqoot/click'
|
8
|
+
require 'rsqoot/deal'
|
9
|
+
require 'rsqoot/request'
|
10
|
+
require 'rsqoot/logger'
|
11
11
|
|
12
12
|
module RSqoot
|
13
13
|
class Client
|
@@ -31,7 +31,7 @@ module RSqoot
|
|
31
31
|
:expired_in,
|
32
32
|
:sqoot_query_uri
|
33
33
|
|
34
|
-
def initialize(options={})
|
34
|
+
def initialize(options = {})
|
35
35
|
@public_api_key = options[:public_api_key] || RSqoot.public_api_key
|
36
36
|
@private_api_key = options[:private_api_key] || RSqoot.private_api_key
|
37
37
|
@base_api_url = options[:base_api_url] || RSqoot.base_api_url
|
@@ -40,7 +40,7 @@ module RSqoot
|
|
40
40
|
@expired_in = options[:expired_in] || RSqoot.expired_in
|
41
41
|
end
|
42
42
|
|
43
|
-
def reload!(options={})
|
43
|
+
def reload!(options = {})
|
44
44
|
initialize(options)
|
45
45
|
self.class.instance
|
46
46
|
end
|
data/lib/rsqoot/commission.rb
CHANGED
@@ -7,15 +7,14 @@ module RSqoot
|
|
7
7
|
# @param [String] :from End date
|
8
8
|
#
|
9
9
|
# @return [RSqoot::SqootCommission]
|
10
|
-
def commissions(options={})
|
10
|
+
def commissions(options = {})
|
11
11
|
options = update_by_expire_time options
|
12
12
|
if commissions_not_latest?(options)
|
13
13
|
@rsqoot_commissions = get('commissions', options, SqootCommission)
|
14
14
|
@rsqoot_commissions = @rsqoot_commissions.commissions if @rsqoot_commissions
|
15
15
|
end
|
16
|
-
logger(
|
16
|
+
logger(uri: sqoot_query_uri, records: @rsqoot_commissions, type: 'commissions', opts: options)
|
17
17
|
@rsqoot_commissions
|
18
18
|
end
|
19
|
-
|
20
19
|
end
|
21
|
-
end
|
20
|
+
end
|
data/lib/rsqoot/deal.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module RSqoot
|
2
2
|
module Deal
|
3
|
+
|
3
4
|
# Retrieve a list of deals based on the following parameters
|
4
5
|
#
|
5
6
|
# @param [String] query (Search deals by title, description, fine print, merchant name, provider, and category.)
|
@@ -8,32 +9,32 @@ module RSqoot
|
|
8
9
|
# @param [Integer] page (Which page of result to return. Default to 1.)
|
9
10
|
# @param [Integer] per_page (Number of results to return at once. Defaults to 10.)
|
10
11
|
#
|
11
|
-
def deals(options={})
|
12
|
+
def deals(options = {})
|
12
13
|
options = update_by_expire_time options
|
13
14
|
if deals_not_latest?(options)
|
14
15
|
uniq = !!options.delete(:uniq)
|
15
16
|
@rsqoot_deals = get('deals', options, SqootDeal) || []
|
16
|
-
@rsqoot_deals = @rsqoot_deals.deals.map(&:deal)
|
17
|
+
@rsqoot_deals = @rsqoot_deals.deals.map(&:deal) unless @rsqoot_deals.empty?
|
17
18
|
@rsqoot_deals = uniq_deals(@rsqoot_deals) if uniq
|
18
19
|
end
|
19
|
-
logger(
|
20
|
+
logger(uri: sqoot_query_uri, records: @rsqoot_deals, type: 'deals', opts: options)
|
20
21
|
@rsqoot_deals
|
21
22
|
end
|
22
23
|
|
23
24
|
# Retrieve a deal by id
|
24
25
|
#
|
25
|
-
def deal(id, options={})
|
26
|
+
def deal(id, options = {})
|
26
27
|
options = update_by_expire_time options
|
27
28
|
if deal_not_latest?(id)
|
28
29
|
@rsqoot_deal = get("deals/#{id}", options, SqootDeal)
|
29
30
|
@rsqoot_deal = @rsqoot_deal.deal if @rsqoot_deal
|
30
31
|
end
|
31
|
-
logger(
|
32
|
+
logger(uri: sqoot_query_uri, records: [@rsqoot_deal], type: 'deal', opts: options)
|
32
33
|
@rsqoot_deal
|
33
34
|
end
|
34
35
|
|
35
|
-
def impression(deal_id, options={})
|
36
|
-
url_generator("deals/#{deal_id}/image", options,
|
36
|
+
def impression(deal_id, options = {})
|
37
|
+
url_generator("deals/#{deal_id}/image", options, true).first.to_s
|
37
38
|
end
|
38
39
|
|
39
40
|
# Auto Increment for deals query.
|
@@ -42,7 +43,7 @@ module RSqoot
|
|
42
43
|
@cached_pages ||= []
|
43
44
|
page = options[:page] || 1
|
44
45
|
check_query_change options
|
45
|
-
|
46
|
+
unless page_cached? page
|
46
47
|
@total_deals += deals(options)
|
47
48
|
@total_deals.uniq!
|
48
49
|
@cached_pages << page.to_s
|
@@ -63,9 +64,7 @@ module RSqoot
|
|
63
64
|
titles = deals.map(&:title).uniq
|
64
65
|
titles.map do |title|
|
65
66
|
deals.map do |deal|
|
66
|
-
if deal.try(:title) == title
|
67
|
-
deal
|
68
|
-
end
|
67
|
+
deal if deal.try(:title) == title
|
69
68
|
end.compact.last
|
70
69
|
end.flatten
|
71
70
|
end
|
@@ -96,6 +95,5 @@ module RSqoot
|
|
96
95
|
def page_cached?(page = 1)
|
97
96
|
cached_pages.include? page.to_s
|
98
97
|
end
|
99
|
-
|
100
98
|
end
|
101
|
-
end
|
99
|
+
end
|
data/lib/rsqoot/helper.rb
CHANGED
@@ -5,13 +5,13 @@ module RSqoot
|
|
5
5
|
# Add auto-cache helper methods, instances to save the latest query
|
6
6
|
#
|
7
7
|
def self.included(base)
|
8
|
-
[
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
['deals',
|
9
|
+
'deal',
|
10
|
+
'categories',
|
11
|
+
'providers',
|
12
|
+
'merchant',
|
13
|
+
'commissions',
|
14
|
+
'clicks'].each do |name|
|
15
15
|
attr_reader ('rsqoot_' + name).to_sym
|
16
16
|
attr_accessor (name + '_options').to_sym
|
17
17
|
base.send :define_method, (name + '_not_latest?').to_sym do |opt|
|
@@ -26,8 +26,8 @@ module RSqoot
|
|
26
26
|
# Such as: query_categories('home&_visiter,friends')
|
27
27
|
# => search records like: home, visiter, friends
|
28
28
|
#
|
29
|
-
[
|
30
|
-
|
29
|
+
['categories',
|
30
|
+
'providers'].each do |name|
|
31
31
|
base.send :define_method, ('query_' + name).to_sym do |q|
|
32
32
|
queries = q.downcase.scan(/[A-Za-z]+|\d+/)
|
33
33
|
if queries.present?
|
@@ -44,12 +44,12 @@ module RSqoot
|
|
44
44
|
# Add Wrappers: Deal, Category, Commission, Merchant, Provider, Click
|
45
45
|
# All records should return as RSqoot::Sqoot* object
|
46
46
|
#
|
47
|
-
[
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
['SqootDeal',
|
48
|
+
'SqootCategory',
|
49
|
+
'SqootCommission',
|
50
|
+
'SqootMerchant',
|
51
|
+
'SqootProvider',
|
52
|
+
'SqootClick'].each do |class_name|
|
53
53
|
new_class = Class.new(::Hashie::Mash)
|
54
54
|
RSqoot.const_set class_name, new_class
|
55
55
|
end
|
@@ -61,8 +61,7 @@ module RSqoot
|
|
61
61
|
def update_by_expire_time(options = {})
|
62
62
|
@expired_in = options[:expired_in] if options[:expired_in].present?
|
63
63
|
time = Time.now.to_i / expired_in.to_i
|
64
|
-
options.merge(
|
64
|
+
options.merge(expired_in: time)
|
65
65
|
end
|
66
|
-
|
67
66
|
end
|
68
|
-
end
|
67
|
+
end
|
data/lib/rsqoot/logger.rb
CHANGED
@@ -5,7 +5,7 @@ module RSqoot
|
|
5
5
|
# Output errors and valid records count
|
6
6
|
# TODO add color support
|
7
7
|
#
|
8
|
-
def logger(options = {records: [], uri: '', error: '', type: '', opts: {}})
|
8
|
+
def logger(options = { records: [], uri: '', error: '', type: '', opts: {} })
|
9
9
|
records = options[:records].nil? ? [] : options[:records]
|
10
10
|
error = options[:error]
|
11
11
|
uri = options[:uri]
|
@@ -24,20 +24,20 @@ module RSqoot
|
|
24
24
|
else
|
25
25
|
if error.present?
|
26
26
|
puts ">>> Error: #{error}"
|
27
|
-
puts
|
27
|
+
puts ''
|
28
28
|
else
|
29
29
|
puts ">>> Querying Sqoot API V2: #{type}"
|
30
|
-
puts
|
30
|
+
puts ''
|
31
31
|
puts ">>> #{uri}"
|
32
|
-
puts
|
32
|
+
puts ''
|
33
33
|
puts ">>> #{opts}"
|
34
|
-
puts
|
34
|
+
puts ''
|
35
35
|
puts ">>> Hit #{records.count} records"
|
36
|
-
puts
|
36
|
+
puts ''
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
module_function :logger
|
42
42
|
end
|
43
|
-
end
|
43
|
+
end
|
data/lib/rsqoot/merchant.rb
CHANGED
@@ -6,15 +6,14 @@ module RSqoot
|
|
6
6
|
# @param [String] id (The merchant's ID, Use the Sqoot ID or ID for any supported namespace. Must supply namespace if we don't use Sqoot)
|
7
7
|
# @param [String] namespace (One of the supported namespaces. Factual, Foursquare, Facebook, Google, CitySearch, Yelp.)
|
8
8
|
|
9
|
-
def merchant(id, options={})
|
9
|
+
def merchant(id, options = {})
|
10
10
|
options = update_by_expire_time options
|
11
11
|
if merchant_not_latest?(id)
|
12
12
|
@rsqoot_merchant = get("merchants/#{id}", options, SqootMerchant)
|
13
13
|
@rsqoot_merchant = @rsqoot_merchant.merchant if @rsqoot_merchant
|
14
14
|
end
|
15
|
-
logger(
|
15
|
+
logger(uri: sqoot_query_uri, records: [@rsqoot_merchant], type: 'merchants', opts: options)
|
16
16
|
@rsqoot_merchant
|
17
17
|
end
|
18
|
-
|
19
18
|
end
|
20
|
-
end
|
19
|
+
end
|
data/lib/rsqoot/provider.rb
CHANGED
@@ -3,7 +3,7 @@ module RSqoot
|
|
3
3
|
# Retrieve a list of providers base on the following parameters
|
4
4
|
#
|
5
5
|
# @return [RSqoot::SqootProvider]
|
6
|
-
def providers(options={})
|
6
|
+
def providers(options = {})
|
7
7
|
options = update_by_expire_time options
|
8
8
|
query = options.delete(:query)
|
9
9
|
if providers_not_latest?(options)
|
@@ -11,9 +11,8 @@ module RSqoot
|
|
11
11
|
@rsqoot_providers = @rsqoot_providers.providers.map(&:provider) if @rsqoot_providers
|
12
12
|
end
|
13
13
|
result = query.present? ? query_providers(query) : @rsqoot_providers
|
14
|
-
logger(
|
14
|
+
logger(uri: sqoot_query_uri, records: result, type: 'providers', opts: options)
|
15
15
|
result
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
19
|
-
end
|
18
|
+
end
|
data/lib/rsqoot/request.rb
CHANGED
@@ -15,7 +15,7 @@ module RSqoot
|
|
15
15
|
@query_options = result.query
|
16
16
|
result
|
17
17
|
rescue => e
|
18
|
-
logger(
|
18
|
+
logger(error: e)
|
19
19
|
nil
|
20
20
|
end
|
21
21
|
end
|
@@ -25,16 +25,16 @@ module RSqoot
|
|
25
25
|
#
|
26
26
|
def url_generator(path, opts = {}, require_key = false)
|
27
27
|
uri = URI.parse base_api_url
|
28
|
-
headers = {read_timeout: read_timeout}
|
28
|
+
headers = { read_timeout: read_timeout }
|
29
29
|
uri.path = '/v2/' + path
|
30
30
|
query = options_parser opts
|
31
31
|
endpoint = path.split('/')[0]
|
32
32
|
case authentication_method
|
33
33
|
when :header
|
34
|
-
headers.merge!
|
35
|
-
query
|
34
|
+
headers.merge! 'Authorization' => "api_key #{api_key(endpoint)}"
|
35
|
+
query += "&api_key=#{api_key(endpoint)}" if require_key
|
36
36
|
when :parameter
|
37
|
-
query
|
37
|
+
query += "&api_key=#{api_key(endpoint)}"
|
38
38
|
end
|
39
39
|
uri.query = query
|
40
40
|
@sqoot_query_uri = uri
|
@@ -56,13 +56,13 @@ module RSqoot
|
|
56
56
|
end
|
57
57
|
|
58
58
|
# Decide which api key should be used: private, public
|
59
|
-
def api_key(endpoint='')
|
59
|
+
def api_key(endpoint = '')
|
60
60
|
if private_endpoints.include? endpoint
|
61
61
|
private_api_key
|
62
62
|
elsif public_endpoints.include? endpoint
|
63
63
|
public_api_key
|
64
64
|
else
|
65
|
-
|
65
|
+
fail "No such endpoint #{endpoint} available."
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -76,6 +76,5 @@ module RSqoot
|
|
76
76
|
end.join('&')
|
77
77
|
URI.encode query
|
78
78
|
end
|
79
|
-
|
80
79
|
end
|
81
|
-
end
|
80
|
+
end
|
data/lib/rsqoot/version.rb
CHANGED
data/rsqoot.gemspec
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
metadata
CHANGED
@@ -1,94 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsqoot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Felix Liu
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-04-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: hashie
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.0.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 2.0.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: json
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 1.6.0
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 1.6.0
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: activesupport
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 3.0.0
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 3.0.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: 1.0.0
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: 1.0.0
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
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
|
+
- - ">="
|
92
95
|
- !ruby/object:Gem::Version
|
93
96
|
version: '0'
|
94
97
|
description: A Ruby Wrapper for Sqoot API V2.
|
@@ -99,7 +102,9 @@ extensions: []
|
|
99
102
|
extra_rdoc_files:
|
100
103
|
- README.md
|
101
104
|
files:
|
102
|
-
- .gitignore
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
103
108
|
- Gemfile
|
104
109
|
- Gemfile.lock
|
105
110
|
- LICENSE
|
@@ -120,35 +125,30 @@ files:
|
|
120
125
|
- lib/rsqoot/request.rb
|
121
126
|
- lib/rsqoot/version.rb
|
122
127
|
- rsqoot.gemspec
|
128
|
+
- spec/spec_helper.rb
|
123
129
|
homepage: https://github.com/lyfeyaj/rsqoot
|
124
130
|
licenses:
|
125
131
|
- MIT
|
132
|
+
metadata: {}
|
126
133
|
post_install_message:
|
127
134
|
rdoc_options: []
|
128
135
|
require_paths:
|
129
136
|
- lib
|
130
137
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
138
|
requirements:
|
133
|
-
- -
|
139
|
+
- - ">="
|
134
140
|
- !ruby/object:Gem::Version
|
135
141
|
version: '0'
|
136
|
-
segments:
|
137
|
-
- 0
|
138
|
-
hash: -2539217587726128751
|
139
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
-
none: false
|
141
143
|
requirements:
|
142
|
-
- -
|
144
|
+
- - ">="
|
143
145
|
- !ruby/object:Gem::Version
|
144
146
|
version: '0'
|
145
|
-
segments:
|
146
|
-
- 0
|
147
|
-
hash: -2539217587726128751
|
148
147
|
requirements: []
|
149
148
|
rubyforge_project:
|
150
|
-
rubygems_version:
|
149
|
+
rubygems_version: 2.2.2
|
151
150
|
signing_key:
|
152
|
-
specification_version:
|
151
|
+
specification_version: 4
|
153
152
|
summary: Wrapper for Sqoot API V2
|
154
|
-
test_files:
|
153
|
+
test_files:
|
154
|
+
- spec/spec_helper.rb
|