RedcapAPI 0.0.6a → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -44
- data/RedcapAPI.gemspec +21 -2
- data/lib/RedcapAPI/version.rb +1 -1
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aeb12add1292232685b8dc3f4261ab2c1e6b1daf
|
4
|
+
data.tar.gz: f8cdffe33d25cd99b30a2bd587ff27775919304e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59b2d2909983bad3a39ad3d77ca8526778659045a7c412d4cb18fe9ac02b44a203f92eff44322dede62ec71649ce11d3c0adf3089496bae5a4c1053dd813710a
|
7
|
+
data.tar.gz: ac9f5cc66f444f3825a639cb204a8eba51da925b4487ef18221431ea11ce0a5c4531bbb622423a973f77d29d67e0b8566afd6f24ae2388a36f19791416c6491f
|
data/README.md
CHANGED
@@ -3,63 +3,35 @@
|
|
3
3
|
This is an api to utilize REDCAP api with ruby. This Gem requires mechanize as a dependency.
|
4
4
|
it is based on instructions here http://sburns.org/2013/07/22/intro-to-redcap-api.html
|
5
5
|
|
6
|
-
This gem is under development
|
7
|
-
|
8
|
-
Special thanks to mmcrockett for making great additions.
|
6
|
+
This gem is still under active development. Please contact me directly with any questions or suggestions.
|
9
7
|
|
10
8
|
To start:
|
11
|
-
```ruby
|
12
|
-
r = RedcapAPI.new(token, url, parser)
|
13
|
-
```
|
14
|
-
your institution has it's own url, and each project has it's own token, an optional 'parser' that defaults to JSON. See the test cases for how to use other parsers like Nokogiri::XML and CSV.
|
15
9
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
r = RedcapAPI.new(token, url, parser) # your institution has it's own url, and each project has it's own token, an optional 'parser' that defaults to JSON. See the test cases for how to use other parsers like Nokogiri::XML and CSV.
|
11
|
+
|
12
|
+
r.export(optional params) # returns all records in JSON format, provide additional hash of parameters in you want to override or add any additional RedcapAPI options.
|
13
|
+
|
14
|
+
r.export_metadata(optional params) # returns all metadata records in JSON format, provide additional hash of parameters in you want to override or add any additional RedcapAPI options.
|
15
|
+
|
16
|
+
r.import(optional params) # imports new records, the 'post' method is likely more helpful as it puts the 'data' in the correct format.
|
17
|
+
|
18
|
+
r.api(optional params) # returns the raw data, this allows you to return 'xml' or 'csv' instead of forcing 'json'. Simply override the params. Example r.api({:format => 'xml'}).
|
20
19
|
|
21
|
-
|
22
|
-
r.export_metadata(optional params)
|
23
|
-
```
|
24
|
-
returns all metadata records in JSON format, provide additional hash of parameters in you want to override or add any additional RedcapAPI options.
|
20
|
+
r.get(optional record_id) # returns all records in JSON format or a specific record if specified
|
25
21
|
|
26
|
-
|
27
|
-
r.import(optional params)
|
28
|
-
```
|
29
|
-
imports new records, the 'post' method is likely more helpful as it puts the 'data' in the correct format.
|
22
|
+
r.get_fields # returns all fields for that instrument
|
30
23
|
|
31
|
-
|
32
|
-
r.api(optional params)
|
33
|
-
```
|
34
|
-
returns the raw data, this allows you to return 'xml' or 'csv' instead of forcing 'json'. Simply override the params. Example r.api({:format => 'xml'}).
|
35
|
-
```
|
36
|
-
r.get(optional record_id)
|
37
|
-
```
|
38
|
-
returns all records in JSON format or a specific record if specified
|
39
|
-
```
|
40
|
-
r.get_fields
|
41
|
-
```
|
42
|
-
returns all fields for that instrument
|
43
|
-
```
|
44
|
-
r.post(data)
|
45
|
-
```
|
46
|
-
this will either update an old record or create a new one. the data should be in form of array of hashes or as a hash (for one item). dates are accepted in Date class or in strftime('%F') format.
|
24
|
+
r.post(data) # this will either update an old record or create a new one. the data should be in form of array of hashes or as a hash (for one item). dates are accepted in Date class or in strftime('%F') format.
|
47
25
|
for example
|
48
|
-
```
|
49
26
|
data = {name: 'this is a test', field_2: Date.today}
|
50
|
-
r.post(data)
|
51
|
-
```
|
52
|
-
creates a new object using the fields above. field names must match those in the existing project
|
27
|
+
r.post(data) # creates a new object using the fields above. field names must match those in the existing project
|
53
28
|
"{\"count\": 1}" --> indicates the object posted.
|
54
29
|
|
55
30
|
to update an existing record:
|
56
|
-
```
|
57
31
|
data = {record_id: 3, name: 'this is a test to update', field_2: Date.today}
|
58
|
-
r.post(data)
|
59
|
-
```
|
60
|
-
this will update the record with record_id 3. if record_id 3 does not exist it will create an entry with that record id
|
32
|
+
r.post(data) # this will update the record with record_id 3. if record_id 3 does not exist it will create an entry with that record id
|
61
33
|
|
62
|
-
There is also a helper class added to ruby Hash allowing you to convert a ruby array to a http-post style array.
|
34
|
+
There is also a helper class added to ruby Hash allowing you to convert a ruby array to a http-post style array. I created this after having some issues filtering on 'forms' and 'fields'
|
63
35
|
Example:
|
64
36
|
params = {:fields => ['record_id', 'lab_id'], :forms => ['slide_tracking', 'id_shipping']} # This is the data I want to send to RedcapAPI, limiting the fields and forms
|
65
37
|
r.export_metadata(params.to_http_post_array()) # This gets the metadata for only those fields/forms by using the newly added method on Hash 'to_http_post_array'.
|
data/RedcapAPI.gemspec
CHANGED
@@ -9,10 +9,29 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["eugyev"]
|
10
10
|
spec.email = ["eugyev@gmail.com"]
|
11
11
|
spec.summary = %q{This is an api to utilize REDCAP api with ruby. This Gem requires mechanize as a dependency.
|
12
|
-
|
12
|
+
it is based on instructions here http://sburns.org/2013/07/22/intro-to-redcap-api.html
|
13
13
|
}
|
14
14
|
spec.description = %q{
|
15
|
-
Please
|
15
|
+
This gem is still under active development. Please contact me directly with any questions or suggestions.
|
16
|
+
|
17
|
+
To start:
|
18
|
+
|
19
|
+
r = RedcapAPI.new(token, url) # your institution has it's own url, and each project has it's own token
|
20
|
+
|
21
|
+
r.get(optional record_id) # returns all records in JSON format or a specific record if specified
|
22
|
+
|
23
|
+
r.get_fields # returns all fields for that instrument
|
24
|
+
|
25
|
+
r.post(data) # this will either update an old record or create a new one. the data should be in form of array of hashes or as a hash (for one item). dates are accepted in Date class or in strftime('%F') format.
|
26
|
+
for example
|
27
|
+
data = {name: 'this is a test', field_2: Date.today}
|
28
|
+
r.post(data) # creates a new object using the fields above. field names must match those in the existing project
|
29
|
+
"{\"count\": 1}" --> indicates the object posted.
|
30
|
+
|
31
|
+
to update an existing record:
|
32
|
+
data = {record_id: 3, name: 'this is a test to update', field_2: Date.today}
|
33
|
+
r.post(data) # this will update the record with record_id 3. if record_id 3 does not exist it will create an entry with that record id
|
34
|
+
|
16
35
|
}
|
17
36
|
spec.homepage = ""
|
18
37
|
spec.license = "MIT"
|
data/lib/RedcapAPI/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: RedcapAPI
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- eugyev
|
@@ -94,8 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
-
description: "\n
|
98
|
-
\
|
97
|
+
description: "\n This gem is still under active development. Please contact me
|
98
|
+
directly with any questions or suggestions. \n \n To start:\n\n r = RedcapAPI.new(token,
|
99
|
+
url) # your institution has it's own url, and each project has it's own token\n\n
|
100
|
+
\ r.get(optional record_id) # returns all records in JSON format or a specific record
|
101
|
+
if specified\n \n r.get_fields # returns all fields for that instrument\n \n
|
102
|
+
\ r.post(data) # this will either update an old record or create a new one. the
|
103
|
+
data should be in form of array of hashes or as a hash (for one item). dates are
|
104
|
+
accepted in Date class or in strftime('%F') format. \n for example\n data =
|
105
|
+
{name: 'this is a test', field_2: Date.today}\n r.post(data) # creates a new
|
106
|
+
object using the fields above. field names must match those in the existing project\n
|
107
|
+
\ \"{\\\"count\\\": 1}\" --> indicates the object posted. \n \n to update an
|
108
|
+
existing record:\n data = {record_id: 3, name: 'this is a test to update', field_2:
|
109
|
+
Date.today}\n r.post(data) # this will update the record with record_id 3. if record_id
|
110
|
+
3 does not exist it will create an entry with that record id\n \n "
|
99
111
|
email:
|
100
112
|
- eugyev@gmail.com
|
101
113
|
executables: []
|
@@ -126,15 +138,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
138
|
version: '0'
|
127
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
140
|
requirements:
|
129
|
-
- - "
|
141
|
+
- - ">="
|
130
142
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
143
|
+
version: '0'
|
132
144
|
requirements: []
|
133
145
|
rubyforge_project:
|
134
146
|
rubygems_version: 2.2.2
|
135
147
|
signing_key:
|
136
148
|
specification_version: 4
|
137
149
|
summary: This is an api to utilize REDCAP api with ruby. This Gem requires mechanize
|
138
|
-
as a dependency.
|
150
|
+
as a dependency. it is based on instructions here http://sburns.org/2013/07/22/intro-to-redcap-api.html
|
139
151
|
test_files:
|
140
152
|
- test/test_redcap_api.rb
|