dropbox_api 0.1.9 → 0.1.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: 0a9b3e0abcd48bf5bc5749072c91438d30958141
4
- data.tar.gz: 92d7370854daa2516b81956e72d855ab5014f59d
3
+ metadata.gz: 2801013459cdb9c5a71f72f07e5967cc09452625
4
+ data.tar.gz: d99d873e573f87879f2b0acb8f215eda78ba5182
5
5
  SHA512:
6
- metadata.gz: a9c558222a39bff0a3a54e22d3d26b27f8b93b7fe64798b0ca07f44495fa9a834e4d88ee88051bacebf688a73326fb4d3f9a848b31144b461e3ebcea81949018
7
- data.tar.gz: 4d04b472af2aa318f5538d853c71a02e4fc5a1be844ae37c7da4d614ba5d1235c54c0643a18ebdeea623a98274a1d9fbb5b7f00c9d962d83fb4b454ab875895c
6
+ metadata.gz: c968a2f558de87f21e1428786ed34c021ffe092df8975f7904c93013a27a57a36f2f8bb0bc6e291cdaf8d7a025c7cd9b82637308ea49da88e1701b42ec0618f4
7
+ data.tar.gz: a7659b676c8df3cd23df8679723d2716cd21bfd0280a3f1de6480a8c46fd769bc8d75d8adf7c6f9074dfc34caba3baba14563fe1dd07c9adf02d145872cfad72
@@ -7,6 +7,7 @@ require 'faraday'
7
7
  require 'dropbox_api/authenticator'
8
8
 
9
9
  require 'dropbox_api/middleware/decode_result'
10
+ require 'dropbox_api/middleware/stack'
10
11
 
11
12
  require 'dropbox_api/metadata/field'
12
13
  require 'dropbox_api/metadata/base'
@@ -15,11 +16,12 @@ require 'dropbox_api/metadata/symbol'
15
16
  require 'dropbox_api/metadata/access_level'
16
17
  require 'dropbox_api/metadata/member_action'
17
18
 
18
- require 'dropbox_api/metadata/dimensions.rb'
19
- require 'dropbox_api/metadata/location.rb'
20
- require 'dropbox_api/metadata/photo_metadata.rb'
21
- require 'dropbox_api/metadata/video_metadata.rb'
22
- require 'dropbox_api/metadata/media_info.rb'
19
+ require 'dropbox_api/metadata/dimensions'
20
+ require 'dropbox_api/metadata/location'
21
+ require 'dropbox_api/metadata/photo_metadata'
22
+ require 'dropbox_api/metadata/video_metadata'
23
+ require 'dropbox_api/metadata/media_info'
24
+ require 'dropbox_api/metadata/media_metadata'
23
25
  require 'dropbox_api/metadata/member'
24
26
  require 'dropbox_api/metadata/add_member'
25
27
  require 'dropbox_api/metadata/name'
@@ -4,6 +4,10 @@ module DropboxApi
4
4
  @connection_builder = ConnectionBuilder.new(oauth_bearer)
5
5
  end
6
6
 
7
+ def middleware
8
+ @connection_builder.middleware
9
+ end
10
+
7
11
  # @!visibility private
8
12
  def self.add_endpoint(name, endpoint)
9
13
  define_method(name) do |*args, &block|
@@ -4,13 +4,17 @@ module DropboxApi
4
4
  @oauth_bearer = oauth_bearer
5
5
  end
6
6
 
7
- def build(url)
8
- Faraday.new(url) do |c|
9
- c.authorization :Bearer, @oauth_bearer
7
+ def middleware
8
+ @middleware ||= MiddleWare::Stack.new
9
+ end
10
10
 
11
- yield c
11
+ def build(url)
12
+ Faraday.new(url) do |connection|
13
+ middleware.apply(connection) do
14
+ connection.authorization :Bearer, @oauth_bearer
12
15
 
13
- c.adapter Faraday.default_adapter
16
+ yield connection
17
+ end
14
18
  end
15
19
  end
16
20
  end
@@ -11,6 +11,9 @@ module DropboxApi::Endpoints::Files
11
11
  #
12
12
  # Note: Metadata for the root folder is unsupported.
13
13
  #
14
+ # If you request the `media_info` attribute, note that it could be set to
15
+ # `:pending` or `nil`.
16
+ #
14
17
  # @param path [String] The path of a file or folder on Dropbox.
15
18
  # @option include_media_info [Boolean] If `true`, FileMetadata.media_info
16
19
  # is set for photo and video. The default for this field is `false`.
@@ -2,37 +2,34 @@ module DropboxApi::Metadata
2
2
  # Example of a serialized {MediaInfo} object:
3
3
  # {
4
4
  # ".tag": "metadata",
5
- # "metadata": {
6
- # ".tag": "video",
7
- # "dimensions": {
8
- # "height": 1500,
9
- # "width": 1500
10
- # },
11
- # "location": {
12
- # "latitude": 10.123456,
13
- # "longitude": 5.123456
14
- # }
15
- # "time_taken": "2016-09-04T17:00:27Z",
16
- # "duration": 6000
17
- # }
5
+ # "metadata": {...}
6
+ # }
7
+ # or:
8
+ # {
9
+ # ".tag": "pending"
18
10
  # }
19
11
  class MediaInfo < Base
20
12
  class << self
21
13
  def new(data)
22
- tag = data['metadata']['.tag']
23
- class_for(tag.to_sym).new(data['metadata'])
14
+ klass = class_for(data['.tag'].to_sym)
15
+
16
+ if klass == :pending
17
+ :pending
18
+ else
19
+ klass.new(data['metadata'])
20
+ end
24
21
  end
25
22
 
26
23
  private
27
24
 
28
25
  def class_for(tag)
29
26
  case tag
30
- when :photo
31
- DropboxApi::Metadata::PhotoMetadata
32
- when :video
33
- DropboxApi::Metadata::VideoMetadata
27
+ when :pending
28
+ :pending
29
+ when :metadata
30
+ DropboxApi::Metadata::MediaMetadata
34
31
  else
35
- raise ArgumentError, "Unable to build individual result with `#{tag}`"
32
+ raise ArgumentError, "Unable to build individual result with `#{tag.inspect}`"
36
33
  end
37
34
  end
38
35
  end
@@ -0,0 +1,38 @@
1
+ module DropboxApi::Metadata
2
+ # Example of a serialized {MediaInfo} object:
3
+ # {
4
+ # ".tag": "video",
5
+ # "dimensions": {
6
+ # "height": 1500,
7
+ # "width": 1500
8
+ # },
9
+ # "location": {
10
+ # "latitude": 10.123456,
11
+ # "longitude": 5.123456
12
+ # }
13
+ # "time_taken": "2016-09-04T17:00:27Z",
14
+ # "duration": 6000
15
+ # }
16
+ # }
17
+ class MediaMetadata < Base
18
+ class << self
19
+ def new(data)
20
+ tag = data['.tag']
21
+ class_for(tag.to_sym).new(data)
22
+ end
23
+
24
+ private
25
+
26
+ def class_for(tag)
27
+ case tag
28
+ when :photo
29
+ DropboxApi::Metadata::PhotoMetadata
30
+ when :video
31
+ DropboxApi::Metadata::VideoMetadata
32
+ else
33
+ raise ArgumentError, "Unable to build individual result with `#{tag}`"
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,28 @@
1
+ module DropboxApi::MiddleWare
2
+ class Stack
3
+ def initialize
4
+ @prependable, @appendable = [], []
5
+ end
6
+
7
+ def prepend(&block)
8
+ @prependable << block
9
+ end
10
+
11
+ def append(&block)
12
+ @appendable << block
13
+ end
14
+
15
+ def adapter=(value)
16
+ @adapter = value
17
+ end
18
+
19
+ def apply(connection)
20
+ @prependable.each { |block| block.yield(connection) }
21
+ yield connection
22
+ @appendable.each { |block| block.yield(connection) }
23
+
24
+ # Adapter must be the last middleware configured
25
+ connection.adapter(@adapter || Faraday.default_adapter)
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module DropboxApi
2
- VERSION = '0.1.9'.freeze
2
+ VERSION = '0.1.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dropbox_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesús Burgos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-20 00:00:00.000000000 Z
11
+ date: 2017-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -240,6 +240,7 @@ files:
240
240
  - lib/dropbox_api/metadata/link_permissions.rb
241
241
  - lib/dropbox_api/metadata/location.rb
242
242
  - lib/dropbox_api/metadata/media_info.rb
243
+ - lib/dropbox_api/metadata/media_metadata.rb
243
244
  - lib/dropbox_api/metadata/member.rb
244
245
  - lib/dropbox_api/metadata/member_action.rb
245
246
  - lib/dropbox_api/metadata/member_action_list.rb
@@ -261,6 +262,7 @@ files:
261
262
  - lib/dropbox_api/metadata/video_metadata.rb
262
263
  - lib/dropbox_api/metadata/write_mode.rb
263
264
  - lib/dropbox_api/middleware/decode_result.rb
265
+ - lib/dropbox_api/middleware/stack.rb
264
266
  - lib/dropbox_api/result_builder.rb
265
267
  - lib/dropbox_api/results/add_file_member_result_list.rb
266
268
  - lib/dropbox_api/results/base.rb