shopify_unlimited 0.0.9 → 0.0.10
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.
- data/lib/shopify_unlimited/version.rb +1 -1
- data/lib/shopify_unlimited.rb +18 -5
- metadata +3 -3
data/lib/shopify_unlimited.rb
CHANGED
@@ -17,16 +17,29 @@ module ShopifyUnlimited
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def cached_time(max)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
(
|
20
|
+
now = Time.now
|
21
|
+
result = now
|
22
|
+
unless memcached.add(cache_key, now, 500)
|
23
|
+
memcached.cas(cache_key, 500) do |cached_time|
|
24
|
+
result = ((now - cached_time) > max) ? now : cached_time
|
25
|
+
result
|
26
|
+
end
|
24
27
|
end
|
25
|
-
|
28
|
+
result
|
26
29
|
end
|
27
30
|
|
28
31
|
def set_cached_time(time)
|
32
|
+
|
29
33
|
memcached.set(cache_key, time, 500)
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def estimated_time_until_reset
|
38
|
+
credit_record = ShopifyAPI::Base.connection.shopify_credit
|
39
|
+
time = credit_record.time unless credit_record.nil?
|
40
|
+
time ||= cached_time(ShopifyUnlimited::SHOPIFY_CREDIT_LIMIT_PERIOD)
|
41
|
+
est = ShopifyUnlimited::SHOPIFY_CREDIT_LIMIT_PERIOD - (Time.now - time)
|
42
|
+
[est, 0].max
|
30
43
|
end
|
31
44
|
end
|
32
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_unlimited
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -141,7 +141,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
141
|
version: '0'
|
142
142
|
segments:
|
143
143
|
- 0
|
144
|
-
hash: -
|
144
|
+
hash: -1618288233735018532
|
145
145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
146
|
none: false
|
147
147
|
requirements:
|
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
segments:
|
152
152
|
- 0
|
153
|
-
hash: -
|
153
|
+
hash: -1618288233735018532
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
156
|
rubygems_version: 1.8.25
|