forked from waits/dropbox-sdk-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add upload session methods and UploadSessionCursor class
- Loading branch information
Showing
7 changed files
with
137 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Dropbox | ||
# UploadSessionCursor holds information about an in-progress upload session. | ||
# | ||
# @attr [String] session_id A unique identifier for the session. | ||
# @attr [Integer] offset The size of the data uploaded so far. | ||
class UploadSessionCursor | ||
attr_reader :session_id | ||
attr_accessor :offset | ||
|
||
# @param [String] session_id | ||
# @param [Integer] offset | ||
def initialize(session_id, offset) | ||
@session_id = session_id | ||
@offset = offset | ||
end | ||
|
||
# @return [Hash] | ||
def to_h | ||
{session_id: session_id, offset: offset} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'minitest/autorun' | ||
require 'dropbox' | ||
|
||
class DropboxUploadSessionCursorTest < Minitest::Test | ||
def test_upload_session_cursor | ||
cursor = Dropbox::UploadSessionCursor.new('id:123', 10) | ||
hash = cursor.to_h | ||
correct = {session_id: 'id:123', offset: 10} | ||
|
||
assert_instance_of Hash, hash | ||
assert_equal correct, hash | ||
end | ||
end |