love 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/lib/love.rb +6 -4
- data/love.gemspec +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/love.rb
CHANGED
@@ -93,7 +93,7 @@ module Love
|
|
93
93
|
protected
|
94
94
|
|
95
95
|
def get(uri)
|
96
|
-
Love.logger.debug "GET #{
|
96
|
+
Love.logger.debug "GET #{uri}" if Love.logger
|
97
97
|
|
98
98
|
http = Net::HTTP.new(uri.host, uri.port)
|
99
99
|
if uri.scheme = 'https'
|
@@ -121,16 +121,18 @@ module Love
|
|
121
121
|
def buffered_each(uri, list_key, options = {}, &block)
|
122
122
|
query_options = {}
|
123
123
|
query_options[:since] = options[:since].to_date.to_s(:db) if options[:since]
|
124
|
-
|
125
|
-
|
124
|
+
|
125
|
+
uri.query = query_options.map { |k, v| "#{k}=#{v}" }.join('&')
|
126
|
+
initial_result = get(uri)
|
126
127
|
start_page = [options[:start_page].to_i, 1].max rescue 1
|
127
128
|
max_page = (initial_result['total'].to_f / initial_result['per_page'].to_f).ceil
|
128
129
|
end_page = options[:end_page].nil? ? max_page : [options[:end_page].to_i, max_page].min
|
129
130
|
|
130
131
|
# Print out some initial debugging information
|
131
|
-
Love.logger.debug "Paged requests to #{
|
132
|
+
Love.logger.debug "Paged requests to #{uri}: #{max_page} total pages, importing #{start_page} upto #{end_page}." if Love.logger
|
132
133
|
|
133
134
|
start_page.upto(end_page) do |page|
|
135
|
+
query_options[:page] = page
|
134
136
|
uri.query = query_options.map { |k, v| "#{k}=#{v}" }.join('&')
|
135
137
|
result = get(uri)
|
136
138
|
result[list_key].each { |record| yield(record) }
|
data/love.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
|
|
3
3
|
|
4
4
|
# Do not change the version and date fields by hand. This will be done
|
5
5
|
# automatically by the gem release script.
|
6
|
-
s.version = "0.0.
|
6
|
+
s.version = "0.0.3"
|
7
7
|
s.date = "2010-11-29"
|
8
8
|
|
9
9
|
s.summary = "Ruby library to access the Tender REST API."
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: love
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Willem van Bergen
|