Sha256: 0745e85a60917f216611e0519290596ebb29914ad5b198f46a7ecb700deeb918
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
require 'cgi' module Gerry class Client module Changes # Get changes visible to the caller. # # @param [Array] options the query parameters. # @return [Hash] the changes. def changes(options = []) endpoint = '/changes/' url = endpoint if !options.empty? url += '?' + map_options(options) end response = get(url) return response unless response.last.delete('_more_changes') # Get the original start parameter, if any, else start from 0. query = URI.parse(url).query query = query ? CGI.parse(query) : { 'S' => ['0'] } start = query['S'].join.to_i # Keep getting data until there are no more changes. loop do # Replace the start parameter, using the original start as an offset. query['S'] = ["#{start + response.size}"] url = endpoint + '?' + map_options(query) response.concat(get(url)) return response unless response.last.delete('_more_changes') end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gerry-0.1.2 | lib/gerry/client/changes.rb |