ohmage 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ohmage/campaign.rb +25 -0
- data/lib/ohmage/cli.rb +2 -2
- data/lib/ohmage/document.rb +18 -3
- data/lib/ohmage/request.rb +1 -1
- data/lib/ohmage/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5346e0bbef95966904e71f121444a7953aef1f25
|
4
|
+
data.tar.gz: 15c14cf7eb79247f05519225fe4beeb46627a203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca7ad1732dd2e189ead2d9ff1360a01c4cd6a0f9be05cfca98fb40e58bfa2176122bda3cf1c522cde49313b630f79fe997c5fe86e3c3550dd58b9a28dc74c07b
|
7
|
+
data.tar.gz: 0b90a0cff36432d5b9f87dd6958125af287b7d5b46a619b164874615c4c7977c7a56c51e136c4cd19df061349fcdf68281d4f475ef8d3be0608328ef8c42d3b4
|
data/lib/ohmage/campaign.rb
CHANGED
@@ -15,6 +15,31 @@ module Ohmage
|
|
15
15
|
t
|
16
16
|
end
|
17
17
|
|
18
|
+
#
|
19
|
+
# ohmage campaign/create call
|
20
|
+
# @see https://github.com/ohmage/server/wiki/Campaign-Manipulation#campaignCreate
|
21
|
+
# @returns [Ohmage::Campaign object] or nil if urn is not passed as param
|
22
|
+
#
|
23
|
+
def campaign_create(params = {})
|
24
|
+
params[:xml] = HTTP::FormData::File.new(params[:xml])
|
25
|
+
request = Ohmage::Request.new(self, :post, 'campaign/create', params)
|
26
|
+
request.perform
|
27
|
+
# we cannot create a campaign object if campaign_urn is not passed as a param. returns nil otherwise
|
28
|
+
campaign_read(campaign_urn_list: params[:campaign_urn], output_format: 'long') if params[:campaign_urn]
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# ohmage campaign/update call
|
33
|
+
# @see https://github.com/ohmage/server/wiki/Campaign-Manipulation#campaignUpdate
|
34
|
+
# @returns [Ohmage::Campaign object]
|
35
|
+
#
|
36
|
+
def campaign_update(params = {})
|
37
|
+
params[:xml] = HTTP::FormData::File.new(params[:xml]) if params[:xml]
|
38
|
+
request = Ohmage::Request.new(self, :post, 'campaign/update', params)
|
39
|
+
request.perform
|
40
|
+
campaign_read(campaign_urn_list: params[:campaign_urn])
|
41
|
+
end
|
42
|
+
|
18
43
|
def campaign_delete(params = {})
|
19
44
|
request = Ohmage::Request.new(self, :post, 'campaign/delete', params)
|
20
45
|
request.perform
|
data/lib/ohmage/cli.rb
CHANGED
@@ -89,13 +89,13 @@ module Ohmage
|
|
89
89
|
if options[:campaign_role].nil? && options[:class_role].nil?
|
90
90
|
puts 'must supply one of [--class_role, --campaign_role]'
|
91
91
|
elsif options[:name].nil?
|
92
|
-
new_document = Ohmage.document_create(file,
|
92
|
+
new_document = Ohmage.document_create(document: file,
|
93
93
|
document_class_role_list: options[:class_role],
|
94
94
|
document_campaign_role_list: options[:campaign_role],
|
95
95
|
privacy_state: privacy_state,
|
96
96
|
description: options[:description])
|
97
97
|
else
|
98
|
-
new_document = Ohmage.document_create(file,
|
98
|
+
new_document = Ohmage.document_create(document: file,
|
99
99
|
document_class_role_list: options[:class_role],
|
100
100
|
document_campaign_role_list: options[:campaign_role],
|
101
101
|
privacy_state: privacy_state,
|
data/lib/ohmage/document.rb
CHANGED
@@ -15,15 +15,30 @@ module Ohmage
|
|
15
15
|
t
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
18
|
+
#
|
19
|
+
# ohmage document/create call
|
20
|
+
# @see https://github.com/ohmage/server/wiki/Document-Manipulation#documentCreate
|
21
|
+
# @returns [Ohmage::Document object]
|
22
|
+
#
|
23
|
+
def document_create(params = {})
|
24
|
+
params[:document] = HTTP::FormData::File.new(params[:document])
|
20
25
|
# catch lack of document_name param, since we can just append the filename we have!
|
21
|
-
params[:document_name] = File.basename(file) unless params.key?(:document_name)
|
22
26
|
request = Ohmage::Request.new(self, :post, 'document/create', params)
|
23
27
|
request.perform
|
24
28
|
document_read(document_name_search: params[:document_name])
|
25
29
|
end
|
26
30
|
|
31
|
+
#
|
32
|
+
# ohmage document/update call
|
33
|
+
# @see https://github.com/ohmage/server/wiki/Document-Manipulation#documentUpdate
|
34
|
+
# @returns nil, can't be sure we can search for the updated file.
|
35
|
+
#
|
36
|
+
def document_update(params = {})
|
37
|
+
params[:document] = HTTP::FormData::File.new(params[:document]) if params[:document]
|
38
|
+
request = Ohmage::Request.new(self, :post, 'document/update', params)
|
39
|
+
request.perform
|
40
|
+
end
|
41
|
+
|
27
42
|
def document_delete(params = {})
|
28
43
|
request = Ohmage::Request.new(self, :post, 'document/delete', params)
|
29
44
|
request.perform
|
data/lib/ohmage/request.rb
CHANGED
@@ -16,7 +16,7 @@ module Ohmage
|
|
16
16
|
@request_method = request_method
|
17
17
|
# some create/upload apis require content to be sent as multipart form. catch that here
|
18
18
|
case api
|
19
|
-
when 'document/create', 'survey/upload'
|
19
|
+
when 'document/create', 'survey/upload', 'document/update', 'campaign/create', 'campaign/update'
|
20
20
|
@params = {form: @options}
|
21
21
|
else
|
22
22
|
@params = {params: @options}
|
data/lib/ohmage/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ohmage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Nolen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -115,9 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: 1.3.5
|
116
116
|
requirements: []
|
117
117
|
rubyforge_project:
|
118
|
-
rubygems_version: 2.4.
|
118
|
+
rubygems_version: 2.4.6
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: A Ruby interface for the ohmage 2.x API.
|
122
122
|
test_files: []
|
123
|
-
has_rdoc:
|