ohmage 0.0.9 → 0.0.10
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/api.rb +2 -0
- data/lib/ohmage/entity/clazz.rb +1 -1
- data/lib/ohmage/media.rb +34 -0
- data/lib/ohmage/request.rb +4 -0
- data/lib/ohmage/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: 37dc20d0591f071bbf12a953fc0814cab13c8923
|
4
|
+
data.tar.gz: 9b09debd1c7c1430b66fd3a2645bcd3854cb6bd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2da59701975de44f0a0a00e244eda1a9746baa98d1c2dc166d436c0c0180db9191569b54f8dad3f06301ec42751b259bd5789f843055d85af2ab7681d4b14607
|
7
|
+
data.tar.gz: 794e46d0799cbbe5c443bf41c8d14cd763a1558986809c67bfdac97143c4eee778c99543c18a8308559aba516ff4695d91b746f28a90ab0f87aad35d12843a7b
|
data/lib/ohmage/api.rb
CHANGED
@@ -2,6 +2,7 @@ require 'ohmage/user'
|
|
2
2
|
require 'ohmage/campaign'
|
3
3
|
require 'ohmage/clazz'
|
4
4
|
require 'ohmage/document'
|
5
|
+
require 'ohmage/media'
|
5
6
|
|
6
7
|
module Ohmage
|
7
8
|
module API
|
@@ -9,5 +10,6 @@ module Ohmage
|
|
9
10
|
include Ohmage::API::Clazz
|
10
11
|
include Ohmage::API::Campaign
|
11
12
|
include Ohmage::API::Document
|
13
|
+
include Ohmage::API::Media
|
12
14
|
end
|
13
15
|
end
|
data/lib/ohmage/entity/clazz.rb
CHANGED
@@ -6,7 +6,7 @@ module Ohmage
|
|
6
6
|
# @return [Hash]
|
7
7
|
attr_reader :users
|
8
8
|
# @return [Array]
|
9
|
-
attr_reader :usernames #class/search returns only array of usernames
|
9
|
+
attr_reader :usernames # class/search returns only array of usernames
|
10
10
|
|
11
11
|
def initialize(attrs = {})
|
12
12
|
@urn = attrs.keys[0].to_s
|
data/lib/ohmage/media.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Ohmage
|
2
|
+
module API
|
3
|
+
module Media
|
4
|
+
#
|
5
|
+
# ohmage media/read call
|
6
|
+
# @see https://github.com/ohmage/server/wiki/Media-Manipulation#mediaRead
|
7
|
+
# @returns [Binary File] from raw HTTP Response Body.
|
8
|
+
def media_read(params = {})
|
9
|
+
# support for media/read exists only in 2.17+
|
10
|
+
if server_config[:application_version].to_f >= 2.17
|
11
|
+
# 2.17 beta does not currently support size param for images
|
12
|
+
# in media/read. wire in image_read.
|
13
|
+
if params[:size]
|
14
|
+
image_read(params)
|
15
|
+
else
|
16
|
+
request = Ohmage::Request.new(self, :get, 'media/read', params)
|
17
|
+
request.perform
|
18
|
+
end
|
19
|
+
else
|
20
|
+
# finaly, if server ver is <= 2.16 fall back to image/read for all
|
21
|
+
# media calls. yes, this is weird. but it works!
|
22
|
+
image_read(params)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
alias_method :audio_read, :media_read
|
26
|
+
alias_method :video_read, :media_read
|
27
|
+
|
28
|
+
def image_read(params = {})
|
29
|
+
request = Ohmage::Request.new(self, :get, 'image/read', params)
|
30
|
+
request.perform
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/ohmage/request.rb
CHANGED
@@ -24,6 +24,10 @@ module Ohmage
|
|
24
24
|
end
|
25
25
|
def perform # rubocop:disable all
|
26
26
|
response = HTTP.public_send(@request_method, @uri.to_s, @params)
|
27
|
+
# ohmage responds to image/read, audio/read, video/read (and media/read) with a file only.
|
28
|
+
unless (response.headers['Content-Type'] == 'application/json')
|
29
|
+
return response.body
|
30
|
+
end
|
27
31
|
response_body = symbolize_keys!(response.parse)
|
28
32
|
response_headers = response.headers
|
29
33
|
begin
|
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.10
|
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-04
|
11
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/ohmage/entity/document.rb
|
90
90
|
- lib/ohmage/entity/user.rb
|
91
91
|
- lib/ohmage/error.rb
|
92
|
+
- lib/ohmage/media.rb
|
92
93
|
- lib/ohmage/request.rb
|
93
94
|
- lib/ohmage/user.rb
|
94
95
|
- lib/ohmage/version.rb
|