red_cap 0.8.0 → 0.9.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: aff79d0a3d8f11d798bc3ea044f6e9ecaf6120f104b8b9d619a4c9b4f8f08db3
4
- data.tar.gz: 7171c90ea289a8706c800d0df102065b84cb9cdc7754afdd0c5b4d327925d7a4
3
+ metadata.gz: d78e642412a6c1130c646f78d9857495c5c47face4834f9f89ee5f323f4f9ed2
4
+ data.tar.gz: 21eeaefdc5c38b84916ae2257f8ba14fc3e89d327c392dd9b703973ca6c8d351
5
5
  SHA512:
6
- metadata.gz: 53a38cf69401b1820e148d42d0c32ac748f4b034a4f98bba960c74e808f78f0d6e209a35e7c6df648cc8650ddab6a32f8a204c33de96c73c18b0f85455d89ffa
7
- data.tar.gz: d05eee71134492e2925db33fc85705ed3c77cd167e5d2dbbf9105860f83fc7b3280a099e288f167ab257d32009a08e780625ee35532c817d95ed51ff716fc680
6
+ metadata.gz: cfbca51100d14bc29820d402cef3bef6ef45a2c3878e3e9f6b31d45f06b65c53e915db3dd0e2496fd055c3d86fb5abcc84aa9d30128af5e3d0c79140a4739887
7
+ data.tar.gz: fff7559efdd1645e5cc781d192694f002b0f2f3476777dfcb6bdfe74cc5a541bea1f4acb224738767420f10b645e680f947d7504db2ddfff5e8a4001be1e80e0
@@ -1,7 +1,7 @@
1
1
  require "json"
2
2
  require "faraday"
3
3
 
4
- module REDCap
4
+ class REDCap
5
5
  class Client
6
6
  def initialize url: REDCap.url, token: REDCap.token, per_page: REDCap.per_page
7
7
  @url = url
@@ -24,6 +24,10 @@ module REDCap
24
24
  end
25
25
  end
26
26
 
27
+ def find_record study_id
28
+ json_api_request(content: "record", records: study_id).first
29
+ end
30
+
27
31
  def metadata
28
32
  json_api_request(content: "metadata")
29
33
  end
@@ -1,6 +1,6 @@
1
1
  require "active_support/core_ext/object/blank"
2
2
 
3
- module REDCap
3
+ class REDCap
4
4
  class Form
5
5
  class Field < Struct.new(:attributes, :options, :associated_fields)
6
6
  KEYS = [
data/lib/red_cap/form.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "red_cap/form/fields"
2
2
  require "active_support/core_ext/string/inflections"
3
3
 
4
- module REDCap
4
+ class REDCap
5
5
  class Form
6
6
  def initialize data_dictionary
7
7
  @data_dictionary = data_dictionary
@@ -1,3 +1,3 @@
1
- module REDCap
2
- VERSION = "0.8.0"
1
+ class REDCap
2
+ VERSION = "0.9.0"
3
3
  end
data/lib/red_cap.rb CHANGED
@@ -2,7 +2,7 @@ require "red_cap/version"
2
2
  require "red_cap/client"
3
3
  require "red_cap/form"
4
4
 
5
- module REDCap
5
+ class REDCap
6
6
  class << self
7
7
  def configure
8
8
  yield self
@@ -14,5 +14,30 @@ module REDCap
14
14
  @per_page ||= 100
15
15
  end
16
16
  end
17
+
18
+ def form
19
+ @form ||= Form.new(client.metadata)
20
+ end
21
+
22
+ def find study_id
23
+ client.find_record study_id
24
+ end
25
+
26
+ def all &block
27
+ client.records &block
28
+ end
29
+
30
+ def where conditions, &block
31
+ filters = conditions.reduce([]) do |filters, (field, value)|
32
+ filters << "[#{field}]=#{value}"
33
+ end
34
+ client.records(filters.join(" AND "), &block)
35
+ end
36
+
37
+ private
38
+
39
+ def client
40
+ @client ||= Client.new
41
+ end
17
42
  end
18
43
 
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.8.0
4
+ version: 0.9.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: 2019-11-14 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday