gerry 0.0.4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7d5a26248ca8569e79405d01127cc7e15a3e985
4
- data.tar.gz: 1af2e09f12d470b7effd4ca6349fd926027345a5
3
+ metadata.gz: e200dab14c89753f41cfb890952e8cb061b7c5a8
4
+ data.tar.gz: ace3546df83782b1c5d0216950b169e7c122a2be
5
5
  SHA512:
6
- metadata.gz: 1fa7b2004e3ee74dfb975fab016e168919f3e7192e4701d53d766f1b23def124fac756b8eaf4f8693fe2add30726e25b68980a8e96fd0955260e9a90a538ad6d
7
- data.tar.gz: 2d7c4734217f7197607532c0f0d281cbf151c91496bb02f86222a0e5803130fccfe5aff6b1c16b4749fb156244eb46f40c7c3858ad64a98f5061f0a467e87c7f
6
+ metadata.gz: b4a79250d3610b37ab47590eda2f3b624c34b4ec2f490fb12df8229dfd818afc3f2473eddd9cad6ef60cc2257088b6e6686dcb8bcf66d380230daa47d2f49e95
7
+ data.tar.gz: 0e03a33a5d0bb547e08588e2ca22dcbf94b50e79501264dd13d6842b8316db69a29de2109b784de844fd87a1b08c98a024db67c124c1cf946893fbace444fd39
data/README.md CHANGED
@@ -42,7 +42,7 @@ client.changes(['q=is:open'])
42
42
  ## Licence
43
43
  The MIT Licence
44
44
 
45
- Copyright (c) Fabian Mettler, Andrew Erickson, Travis Truman
45
+ Copyright (c) Fabian Mettler, Andrew Erickson, Travis Truman, Sebastian Schuberth
46
46
 
47
47
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
48
48
 
@@ -7,14 +7,14 @@ module Gerry
7
7
  # @return [Hash] the changes.
8
8
  def changes(options = [])
9
9
  url = '/changes/'
10
-
10
+
11
11
  if options.empty?
12
12
  return get(url)
13
13
  end
14
-
14
+
15
15
  options = map_options(options)
16
- get("#{url}?#{options}")
16
+ get("#{url}?#{options}")
17
17
  end
18
18
  end
19
19
  end
20
- end
20
+ end
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+
1
3
  module Gerry
2
4
  class Client
3
5
  module Request
@@ -14,14 +16,34 @@ module Gerry
14
16
  end
15
17
 
16
18
  def get(url)
17
- if @username && @password
18
- auth = { username: @username, password: @password }
19
- response = self.class.get("/a#{url}", digest_auth: auth)
20
- parse(response)
21
- else
22
- response = self.class.get(url)
23
- parse(response)
19
+ orig_url = url
20
+
21
+ # Get the original start parameter, if any.
22
+ query = URI.parse(orig_url).query
23
+ start = query ? CGI.parse(query)['S'].join.to_i : 0
24
+
25
+ # Keep requesting data until there are no more changes.
26
+ all_results = []
27
+ loop do
28
+ response = if @username && @password
29
+ auth = { username: @username, password: @password }
30
+ self.class.get("/a#{url}", digest_auth: auth)
31
+ else
32
+ self.class.get(url)
33
+ end
34
+
35
+ result = parse(response)
36
+ unless result.is_a?(Array) && result.last.is_a?(Hash) && result.last.delete('_more_changes')
37
+ return result
38
+ end
39
+
40
+ all_results.concat(result)
41
+
42
+ # Append the start parameter to the URL, overriding any previous start parameter.
43
+ url = orig_url + "&S=#{start + all_results.size}"
24
44
  end
45
+
46
+ all_results
25
47
  end
26
48
 
27
49
  def put(url, body)
data/lib/gerry/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Gerry
2
2
 
3
- VERSION = "0.0.4"
3
+ VERSION = "0.1.0"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gerry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabian Mettler
8
8
  - Andrew Erickson
9
9
  - Travis Truman
10
+ - Sebastian Schuberth
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2015-08-03 00:00:00.000000000 Z
14
+ date: 2016-01-12 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: httparty