ohmage 0.0.9 → 0.0.10

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
  SHA1:
3
- metadata.gz: e2169fc32e39f48c29654ae1999aa620bbae898b
4
- data.tar.gz: 3801b035b32612fc88ff2c8200d8d5ebb4412778
3
+ metadata.gz: 37dc20d0591f071bbf12a953fc0814cab13c8923
4
+ data.tar.gz: 9b09debd1c7c1430b66fd3a2645bcd3854cb6bd0
5
5
  SHA512:
6
- metadata.gz: 335dd945c810dfd59e84d5cef5816ead69f4ed401df096b3352bb9655a1e8398803b8237da36bed4e33da38e7258873d9e98dfd99cd20bdbd2f285f12b41c2fc
7
- data.tar.gz: 02b671f8eb2c8c7700c1432fe71f66e36c6c7da2f738dc146c32361bb22562b9ecc4add0965dc469ea328bc2af4e0f61645aff38b06b8b75885460a2e27c213b
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
@@ -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
@@ -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
@@ -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
@@ -14,7 +14,7 @@ module Ohmage
14
14
 
15
15
  # @return [Integer]
16
16
  def patch
17
- 9
17
+ 10
18
18
  end
19
19
 
20
20
  # @return [Integer, NilClass]
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.9
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-23 00:00:00.000000000 Z
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