red_cap 0.5.1 → 0.6.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
  SHA256:
3
- metadata.gz: d3d586cf781b2e55fa4d879708049bc78be1cdd3f15b69d9779316aef52403d9
4
- data.tar.gz: 4e5490c8e2e3447014f9df6d9fb23b1055227c1f36a584e734f3e8a1943018d4
3
+ metadata.gz: 49aa29a5b4552436f251e90d2866a45fc052021d7210c0198516f64edbfcff37
4
+ data.tar.gz: 6dc7aeb9484414094e1ee9e042ebf3c25727ae38f11c0a8914afab17ecb84d0d
5
5
  SHA512:
6
- metadata.gz: 9ff3598b19c883f62409dc6dd6819686019b4fc72e08725e611d33cce284cfd24cc1bda21c2ff8bfd61d85f109bf07f5b188168ca88d132c4710712b237c0ff9
7
- data.tar.gz: 65c5e4440ef12ae2a127ace752730a1687900b989eb4a070dc16eb72088f71945910a9921d4c8d1e965174b371c6d03c86263ebe85b561c141e3468e94753b88
6
+ metadata.gz: 6a87e812af13a9dfa6ca6dc78b54f772c1eeb2ca00f5fcc6b9bb9ad77e5c79fcb2efcb2ce6dc2d0ae201bfae65f8dc87de5d53cc7ab77a31a0fcf3f4c504e189
7
+ data.tar.gz: f4f57ab0539ddcb9b3a494c090886d6fb52cc6eb1dc6c75dd5f191ee882ed33e6dae310575033c42a6616ca4835ebd40981d7a853b9e6285e3d7fd5978d916fd
@@ -8,8 +8,14 @@ module REDCap
8
8
  @token = token
9
9
  end
10
10
 
11
- def records
12
- json_api_request(content: "record")
11
+ def records filter=nil
12
+ study_ids =
13
+ json_api_request(content: "record", fields: "study_id", filterLogic: filter)
14
+ .map { |hash| hash["study_id"] }
15
+
16
+ study_ids.in_groups_of(100, false).flat_map do |study_ids|
17
+ json_api_request(content: "record", records: study_ids.join(","))
18
+ end
13
19
  end
14
20
 
15
21
  def metadata
@@ -23,7 +29,7 @@ module REDCap
23
29
  record: record_id,
24
30
  field: file_id,
25
31
  })
26
- _, type, filename = *response.headers["content-type"].match(/\A(.+); name=\"(.+)\"/)
32
+ _, type, filename = *response.headers["content-type"].match(/\A(.+); name=\"(.+)\"\z/)
27
33
  File.new(response.body, type, filename)
28
34
  end
29
35
 
@@ -40,9 +46,9 @@ module REDCap
40
46
 
41
47
  def base_request options
42
48
  connection = Faraday.new(url: @url)
43
- response = connection.post(nil, options.reverse_merge({
44
- token: @token,
45
- }))
49
+ connection.options.open_timeout = 300
50
+ connection.options.timeout = 300
51
+ response = connection.post nil, options.reverse_merge(token: @token)
46
52
  if error_message = response.body[/<error>(.+?)<\/error>/, 1]
47
53
  raise Error.new(error_message)
48
54
  end
@@ -1,3 +1,3 @@
1
1
  module REDCap
2
- VERSION = "0.5.1"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_cap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-26 00:00:00.000000000 Z
11
+ date: 2019-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  requirements: []
126
- rubygems_version: 3.0.8
126
+ rubygems_version: 3.0.4
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Library for connecting to REDCap and parsing forms and data