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 +4 -4
- data/README.md +1 -1
- data/lib/gerry/client/changes.rb +4 -4
- data/lib/gerry/client/request.rb +29 -7
- data/lib/gerry/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e200dab14c89753f41cfb890952e8cb061b7c5a8
|
4
|
+
data.tar.gz: ace3546df83782b1c5d0216950b169e7c122a2be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
|
data/lib/gerry/client/changes.rb
CHANGED
@@ -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
|
data/lib/gerry/client/request.rb
CHANGED
@@ -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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
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
|
+
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:
|
14
|
+
date: 2016-01-12 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: httparty
|