rsqoot 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +1 -8
- data/lib/rsqoot/deal.rb +30 -0
- data/lib/rsqoot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjcwZDMzOTM2ZWI4NWNlYzRiY2I4ZjcxNmU0Y2Y0Nzk1YmFkZTVhNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzViOTRlN2I2N2JjNDYzMWE0MGZlYzU1OWY4ZTZmOTBmMThiY2Q3MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmVhOTYyM2M3NDk1ZTU3NmJkM2JhM2NkM2QyNzIyZjM1YWY5NTcyMjNmNjZi
|
10
|
+
YjNhYjFiODk4ZDliZTUyNTJmYWIxNWUyMjQ0NDcwMGRjYzUyNWRiMjVlZGU3
|
11
|
+
N2Q5ZDc5ZjFkMmZiZjcxOGI3MTNlZDdkYzg5MDExNTY3MGU3Yjk=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2ViOGI5MTk1NmE0ZDk2NDRjNGQyYjUyZDdiN2JiMmY2MGM3MzNjNDQ3ZGU0
|
14
|
+
YzM2OWZlNjgzNjhhNWMwZDE5OGExNTY5NGVjZjQyMTRmMWZiOTgzN2EyYTBi
|
15
|
+
YzQ5YzNkNjkwZWUzN2Y3OWE5NmM5Nzg4ZTZmYWViYWU1NGRiZjk=
|
data/README.md
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
RSqoot
|
2
2
|
======
|
3
3
|
|
4
|
-
A Ruby Wrapper
|
5
|
-
|
6
|
-
Wrapper for [Sqoot](http://www.sqoot.com) [API V2](http://docs.sqoot.com/v2/overview.html).
|
4
|
+
A Ruby Wrapper for [Sqoot](http://www.sqoot.com) [API V2](http://docs.sqoot.com/v2/overview.html).
|
7
5
|
|
8
6
|
To get the list of available parameters kindly check out [API V2](http://docs.sqoot.com/v2/overview.html)
|
9
7
|
|
@@ -97,11 +95,6 @@ If you want to fetch the newest records each time, you can do as below:
|
|
97
95
|
|
98
96
|
By this, it will update the cache by each query.
|
99
97
|
|
100
|
-
## TODO
|
101
|
-
|
102
|
-
+ Add auto-caching in config file
|
103
|
-
+ Add cache expire time in config file
|
104
|
-
|
105
98
|
## Contributing
|
106
99
|
|
107
100
|
1. Fork it
|
data/lib/rsqoot/deal.rb
CHANGED
@@ -34,8 +34,24 @@ module RSqoot
|
|
34
34
|
url_generator("deals/#{deal_id}/image", options, require_key = true).first.to_s
|
35
35
|
end
|
36
36
|
|
37
|
+
def total_sqoot_deals(options = {})
|
38
|
+
@total_deals ||= []
|
39
|
+
@cached_pages ||= []
|
40
|
+
page = options[:page] || 1
|
41
|
+
check_query_change options
|
42
|
+
if !page_cached? page
|
43
|
+
@total_deals += deals(options)
|
44
|
+
@total_deals.uniq!
|
45
|
+
@cached_pages << page.to_s
|
46
|
+
@cached_pages.uniq!
|
47
|
+
end
|
48
|
+
@total_deals
|
49
|
+
end
|
50
|
+
|
37
51
|
private
|
38
52
|
|
53
|
+
attr_reader :cached_pages, :total_deals, :last_deals_query
|
54
|
+
|
39
55
|
def uniq_deals(deals = [])
|
40
56
|
titles = deals.map(&:title).uniq
|
41
57
|
titles.map do |title|
|
@@ -47,5 +63,19 @@ module RSqoot
|
|
47
63
|
end.flatten
|
48
64
|
end
|
49
65
|
|
66
|
+
def check_query_change(options = {})
|
67
|
+
@last_deals_query ||= ''
|
68
|
+
current_query = options[:query].to_s + options[:category_slugs].to_s
|
69
|
+
if @last_deals_query != current_query
|
70
|
+
@last_deals_query = current_query
|
71
|
+
@total_deals = []
|
72
|
+
@cached_pages = []
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def page_cached?(page = 1)
|
77
|
+
cached_pages.include? page.to_s
|
78
|
+
end
|
79
|
+
|
50
80
|
end
|
51
81
|
end
|
data/lib/rsqoot/version.rb
CHANGED