wetransfer 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop.yml +0 -4
- data/.travis.yml +2 -1
- data/README.md +2 -1
- data/lib/we_transfer_client.rb +10 -64
- data/lib/we_transfer_client/future_file_item.rb +16 -0
- data/lib/we_transfer_client/future_transfer.rb +9 -0
- data/lib/we_transfer_client/future_web_item.rb +18 -0
- data/lib/we_transfer_client/remote_item.rb +2 -0
- data/lib/we_transfer_client/remote_transfer.rb +2 -0
- data/lib/we_transfer_client/transfer_builder.rb +35 -0
- data/lib/we_transfer_client/version.rb +1 -1
- data/spec/integration_spec.rb +67 -6
- data/spec/we_transfer_client/future_file_item_spec.rb +39 -0
- data/spec/we_transfer_client/future_transfer_spec.rb +22 -0
- data/spec/we_transfer_client/future_web_item_spec.rb +39 -0
- data/spec/we_transfer_client/transfer_builder_spec.rb +40 -0
- data/spec/we_transfer_client_spec.rb +9 -0
- data/wetransfer.gemspec +2 -1
- metadata +30 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c3bcf1003d1940a7f374bc5e395ed0c0ed245c5
|
4
|
+
data.tar.gz: 6a9d0d2dcb79b3d9645836a689af75f4623131e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8e7ce672d56cae479a45c2f8dc370f5a87515c4d55dae54ecd0106250d0d0e1d06b82e687a19dc376e24d0fd51b063d57d9a92815fdbcc4cad33fcae9fc60c7
|
7
|
+
data.tar.gz: 3c3d91e6bab75ea66f4a79e3248b4363bffe1c08e0f3a798c24d7275eaf50a5a42067ef1b78bbfc7adcd2a2093d96898b07f84e1ea66ec7b0b96263443646fa6
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -10,5 +10,6 @@ matrix:
|
|
10
10
|
allow_failures:
|
11
11
|
- rvm: jruby-9.0
|
12
12
|
script:
|
13
|
-
- bundle exec rspec
|
13
|
+
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bundle exec rspec --exclude-pattern "spec/integration_spec.rb"; fi'
|
14
|
+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bundle exec rspec; fi'
|
14
15
|
- bundle exec rubocop -c .rubocop.yml --force-exclusion
|
data/README.md
CHANGED
@@ -68,6 +68,7 @@ transfer = @client.create_transfer(name: "My wonderful transfer", description: "
|
|
68
68
|
upload.add_file_at(path: '/path/to/local/file.jpg')
|
69
69
|
upload.add_file_at(path: '/path/to/another/local/file.jpg')
|
70
70
|
upload.add_file(name: 'README.txt', io: StringIO.new("This is the contents of the file"))
|
71
|
+
upload.add_web_content(path: "https://www.the.url.you.want.to.share.com"))
|
71
72
|
end
|
72
73
|
|
73
74
|
transfer.shortened_url => "https://we.tl/SSBsb3ZlIHJ1Ynk="
|
@@ -114,4 +115,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
114
115
|
|
115
116
|
## Code of Conduct
|
116
117
|
|
117
|
-
Everyone interacting in the WeTransfer Ruby SDK project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/WeTransfer/wetransfer_ruby_sdk/blob/master/.github/CODE_OF_CONDUCT.md).
|
118
|
+
Everyone interacting in the WeTransfer Ruby SDK project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/WeTransfer/wetransfer_ruby_sdk/blob/master/.github/CODE_OF_CONDUCT.md).
|
data/lib/we_transfer_client.rb
CHANGED
@@ -3,78 +3,23 @@ require 'logger'
|
|
3
3
|
require 'ks'
|
4
4
|
require 'securerandom'
|
5
5
|
require 'json'
|
6
|
+
require 'open-uri'
|
7
|
+
require 'open_uri_redirections'
|
6
8
|
|
7
9
|
class WeTransferClient
|
8
10
|
require_relative 'we_transfer_client/version'
|
11
|
+
require_relative 'we_transfer_client/future_file_item'
|
12
|
+
require_relative 'we_transfer_client/future_web_item'
|
13
|
+
require_relative 'we_transfer_client/future_transfer'
|
14
|
+
require_relative 'we_transfer_client/transfer_builder'
|
15
|
+
require_relative 'we_transfer_client/remote_transfer'
|
16
|
+
require_relative 'we_transfer_client/remote_item'
|
9
17
|
|
10
18
|
class Error < StandardError
|
11
19
|
end
|
12
20
|
|
13
21
|
NULL_LOGGER = Logger.new(nil)
|
14
22
|
MAGIC_PART_SIZE = 6 * 1024 * 1024
|
15
|
-
EXPOSED_COLLECTION_ATTRIBUTES = [:id, :version_identifier, :state, :shortened_url, :name, :description, :size, :items]
|
16
|
-
EXPOSED_ITEM_ATTRIBUTES = [:id, :local_identifier, :content_identifier, :name, :size, :mime_type]
|
17
|
-
|
18
|
-
class FutureFileItem < Ks.strict(:name, :io, :local_identifier)
|
19
|
-
def initialize(**kwargs)
|
20
|
-
super(local_identifier: SecureRandom.uuid, **kwargs)
|
21
|
-
end
|
22
|
-
|
23
|
-
def to_item_request_params
|
24
|
-
# Ideally the content identifier should stay the same throughout multiple
|
25
|
-
# calls if the file contents doesn't change.
|
26
|
-
{
|
27
|
-
content_identifier: 'file',
|
28
|
-
local_identifier: local_identifier,
|
29
|
-
filename: name,
|
30
|
-
filesize: io.size,
|
31
|
-
}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class TransferBuilder
|
36
|
-
attr_reader :items
|
37
|
-
|
38
|
-
def initialize
|
39
|
-
@items = []
|
40
|
-
end
|
41
|
-
|
42
|
-
def add_file(name:, io:)
|
43
|
-
ensure_io_compliant!(io)
|
44
|
-
@items << FutureFileItem.new(name: name, io: io)
|
45
|
-
true
|
46
|
-
end
|
47
|
-
|
48
|
-
def add_file_at(path:)
|
49
|
-
add_file(name: File.basename(path), io: File.open(path, 'rb'))
|
50
|
-
end
|
51
|
-
|
52
|
-
def ensure_io_compliant!(io)
|
53
|
-
io.seek(0)
|
54
|
-
io.read(1) # Will cause things like Errno::EACCESS to happen early, before the upload begins
|
55
|
-
io.seek(0) # Also rewinds the IO for later uploading action
|
56
|
-
size = io.size # Will cause a NoMethodError
|
57
|
-
raise Error, 'The IO object given to add_file has a size of 0' if size <= 0
|
58
|
-
rescue NoMethodError
|
59
|
-
raise Error, "The IO object given to add_file must respond to seek(), read() and size(), but #{io.inspect} did not"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class FutureTransfer < Ks.strict(:name, :description, :items)
|
64
|
-
def to_create_transfer_params
|
65
|
-
{
|
66
|
-
name: name,
|
67
|
-
description: description,
|
68
|
-
items: items.map(&:to_item_request_params),
|
69
|
-
}
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class RemoteTransfer < Ks.strict(*EXPOSED_COLLECTION_ATTRIBUTES)
|
74
|
-
end
|
75
|
-
|
76
|
-
class RemoteItem < Ks.strict(*EXPOSED_ITEM_ATTRIBUTES)
|
77
|
-
end
|
78
23
|
|
79
24
|
def initialize(api_key:, logger: NULL_LOGGER)
|
80
25
|
@api_url_base = 'https://dev.wetransfer.com'
|
@@ -114,7 +59,9 @@ class WeTransferClient
|
|
114
59
|
|
115
60
|
create_transfer_response.fetch(:items).each do |remote_item|
|
116
61
|
local_item = item_id_map.fetch(remote_item.fetch(:local_identifier))
|
62
|
+
next unless local_item.is_a?(FutureFileItem)
|
117
63
|
remote_item_id = remote_item.fetch(:id)
|
64
|
+
|
118
65
|
put_io_in_parts(
|
119
66
|
remote_item_id,
|
120
67
|
remote_item.fetch(:meta).fetch(:multipart_parts),
|
@@ -129,7 +76,6 @@ class WeTransferClient
|
|
129
76
|
)
|
130
77
|
ensure_ok_status!(complete_response)
|
131
78
|
end
|
132
|
-
|
133
79
|
remote_transfer
|
134
80
|
end
|
135
81
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class FutureFileItem < Ks.strict(:name, :io, :local_identifier)
|
2
|
+
def initialize(**kwargs)
|
3
|
+
super(local_identifier: SecureRandom.uuid, **kwargs)
|
4
|
+
end
|
5
|
+
|
6
|
+
def to_item_request_params
|
7
|
+
# Ideally the content identifier should stay the same throughout multiple
|
8
|
+
# calls if the file contents doesn't change.
|
9
|
+
{
|
10
|
+
content_identifier: 'file',
|
11
|
+
local_identifier: local_identifier,
|
12
|
+
filename: name,
|
13
|
+
filesize: io.size,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class FutureWebItem < Ks.strict(:url, :title, :local_identifier)
|
2
|
+
def initialize(**kwargs)
|
3
|
+
super(local_identifier: SecureRandom.uuid, **kwargs)
|
4
|
+
end
|
5
|
+
|
6
|
+
def to_item_request_params
|
7
|
+
# Ideally the content identifier should stay the same throughout multiple
|
8
|
+
# calls if the file contents doesn't change.
|
9
|
+
{
|
10
|
+
content_identifier: 'web_content',
|
11
|
+
local_identifier: local_identifier,
|
12
|
+
url: url,
|
13
|
+
meta: {
|
14
|
+
title: title
|
15
|
+
}
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class TransferBuilder
|
2
|
+
attr_reader :items
|
3
|
+
class TransferIOError < StandardError; end
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@items = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_file(name:, io:)
|
10
|
+
ensure_io_compliant!(io)
|
11
|
+
@items << FutureFileItem.new(name: name, io: io)
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_file_at(path:)
|
16
|
+
add_file(name: File.basename(path), io: File.open(path, 'rb'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_web_content(path:)
|
20
|
+
url = open(path, allow_redirections: :safe).base_uri.to_s
|
21
|
+
url_title = url.split('/').last
|
22
|
+
@items << FutureWebItem.new(url: url, title: url_title)
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
def ensure_io_compliant!(io)
|
27
|
+
io.seek(0)
|
28
|
+
io.read(1) # Will cause things like Errno::EACCESS to happen early, before the upload begins
|
29
|
+
io.seek(0) # Also rewinds the IO for later uploading action
|
30
|
+
size = io.size # Will cause a NoMethodError
|
31
|
+
raise TransferIOError, 'The IO object given to add_file has a size of 0' if size <= 0
|
32
|
+
rescue NoMethodError
|
33
|
+
raise TransferIOError, "The IO object given to add_file must respond to seek(), read() and size(), but #{io.inspect} did not"
|
34
|
+
end
|
35
|
+
end
|
data/spec/integration_spec.rb
CHANGED
@@ -15,10 +15,6 @@ describe WeTransferClient do
|
|
15
15
|
tf
|
16
16
|
end
|
17
17
|
|
18
|
-
it 'exposes VERSION' do
|
19
|
-
expect(WeTransferClient::VERSION).to be_kind_of(String)
|
20
|
-
end
|
21
|
-
|
22
18
|
it 'is able to create a transfer start to finish, both with small and large files' do
|
23
19
|
client = WeTransferClient.new(api_key: ENV.fetch('WT_API_KEY'), logger: test_logger)
|
24
20
|
transfer = client.create_transfer(name: 'My amazing board', description: 'Hi there!') do |builder|
|
@@ -37,7 +33,7 @@ describe WeTransferClient do
|
|
37
33
|
expect(add_result).to eq(true)
|
38
34
|
end
|
39
35
|
|
40
|
-
expect(transfer).to be_kind_of(
|
36
|
+
expect(transfer).to be_kind_of(RemoteTransfer)
|
41
37
|
expect(transfer.id).to be_kind_of(String)
|
42
38
|
|
43
39
|
# expect(transfer.version_identifier).to be_kind_of(String)
|
@@ -48,7 +44,7 @@ describe WeTransferClient do
|
|
48
44
|
expect(transfer.items.length).to eq(3)
|
49
45
|
|
50
46
|
item = transfer.items.first
|
51
|
-
expect(item).to be_kind_of(
|
47
|
+
expect(item).to be_kind_of(RemoteItem)
|
52
48
|
|
53
49
|
expect(transfer.shortened_url).to be_kind_of(String)
|
54
50
|
response = Faraday.get(transfer.shortened_url)
|
@@ -96,4 +92,69 @@ describe WeTransferClient do
|
|
96
92
|
end
|
97
93
|
}.to raise_error(/has a size of 0/)
|
98
94
|
end
|
95
|
+
|
96
|
+
it 'is able to create a transfer with only webcontent' do
|
97
|
+
client = WeTransferClient.new(api_key: ENV.fetch('WT_API_KEY'), logger: test_logger)
|
98
|
+
transfer = client.create_transfer(name: 'My collection of web content', description: 'link collection') do |builder|
|
99
|
+
10.times do
|
100
|
+
builder.add_web_content(path: 'https://www.wetransfer.com')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
expect(transfer).to be_kind_of(RemoteTransfer)
|
104
|
+
expect(transfer.id).to be_kind_of(String)
|
105
|
+
|
106
|
+
# expect(transfer.version_identifier).to be_kind_of(String)
|
107
|
+
expect(transfer.state).to be_kind_of(String)
|
108
|
+
expect(transfer.name).to eq('My collection of web content')
|
109
|
+
expect(transfer.description).to eq('link collection')
|
110
|
+
expect(transfer.items).to be_kind_of(Array)
|
111
|
+
expect(transfer.items.length).to eq(10)
|
112
|
+
|
113
|
+
item = transfer.items.first
|
114
|
+
expect(item).to be_kind_of(RemoteItem)
|
115
|
+
|
116
|
+
expect(transfer.shortened_url).to be_kind_of(String)
|
117
|
+
response = Faraday.get(transfer.shortened_url)
|
118
|
+
expect(response.status).to eq(302)
|
119
|
+
expect(response['location']).to start_with('https://wetransfer')
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'is able to create a transfer with web_content and files' do
|
123
|
+
client = WeTransferClient.new(api_key: ENV.fetch('WT_API_KEY'), logger: test_logger)
|
124
|
+
transfer = client.create_transfer(name: 'Mixed Board Content', description: 'Files and Webcontent') do |builder|
|
125
|
+
# Upload ourselves
|
126
|
+
add_result = builder.add_file(name: File.basename(__FILE__), io: File.open(__FILE__, 'rb'))
|
127
|
+
expect(add_result).to eq(true)
|
128
|
+
|
129
|
+
# Upload ourselves again, but using add_file_at
|
130
|
+
add_result = builder.add_file_at(path: __FILE__) # Upload ourselves again, but this time via path
|
131
|
+
expect(add_result).to eq(true)
|
132
|
+
|
133
|
+
# Upload the large file
|
134
|
+
add_result = builder.add_file(name: 'large.bin', io: very_large_file)
|
135
|
+
expect(add_result).to eq(true)
|
136
|
+
|
137
|
+
# add url to transfer
|
138
|
+
add_result = builder.add_web_content(path: 'http://www.wetransfer.com')
|
139
|
+
expect(add_result).to eq(true)
|
140
|
+
end
|
141
|
+
|
142
|
+
expect(transfer).to be_kind_of(RemoteTransfer)
|
143
|
+
expect(transfer.id).to be_kind_of(String)
|
144
|
+
|
145
|
+
# expect(transfer.version_identifier).to be_kind_of(String)
|
146
|
+
expect(transfer.state).to be_kind_of(String)
|
147
|
+
expect(transfer.name).to eq('Mixed Board Content')
|
148
|
+
expect(transfer.description).to eq('Files and Webcontent')
|
149
|
+
expect(transfer.items).to be_kind_of(Array)
|
150
|
+
expect(transfer.items.length).to eq(4)
|
151
|
+
|
152
|
+
item = transfer.items.first
|
153
|
+
expect(item).to be_kind_of(RemoteItem)
|
154
|
+
|
155
|
+
expect(transfer.shortened_url).to be_kind_of(String)
|
156
|
+
response = Faraday.get(transfer.shortened_url)
|
157
|
+
expect(response.status).to eq(302)
|
158
|
+
expect(response['location']).to start_with('https://wetransfer')
|
159
|
+
end
|
99
160
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FutureFileItem do
|
4
|
+
it 'errors if not given all required arguments' do
|
5
|
+
expect {
|
6
|
+
described_class.new(name: 'nope', local_identifier: 'sorry')
|
7
|
+
}.to raise_error(/missing keyword: io/)
|
8
|
+
|
9
|
+
expect {
|
10
|
+
described_class.new(io: 'nope')
|
11
|
+
}.to raise_error(/missing keyword: name/)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'succeeds if given all arguments' do
|
15
|
+
future_file_item = described_class.new(name: 'yes', io: 'hello', local_identifier: '4815162342')
|
16
|
+
expect(future_file_item).to be_kind_of(FutureFileItem)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'succeeds if not passed a local_identifier' do
|
20
|
+
future_file_item = described_class.new(name: 'yes', io: 'hello')
|
21
|
+
expect(future_file_item).to be_kind_of(FutureFileItem)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'generates a local_identifier' do
|
25
|
+
future_file_item = described_class.new(name: 'who', io: 'ami')
|
26
|
+
expect(future_file_item).to be_kind_of(FutureFileItem)
|
27
|
+
expect(future_file_item.local_identifier).to_not be nil
|
28
|
+
expect(future_file_item.local_identifier).to be_kind_of(String)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'creates params properly' do
|
32
|
+
future_file_item = described_class.new(name: 'yes', io: 'hello')
|
33
|
+
item_as_params = future_file_item.to_item_request_params
|
34
|
+
expect(item_as_params[:content_identifier]).to eq('file')
|
35
|
+
expect(item_as_params[:local_identifier]).to be_kind_of(String)
|
36
|
+
expect(item_as_params[:filename]).to eq('yes')
|
37
|
+
expect(item_as_params[:filesize]).to eq(5)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FutureTransfer do
|
4
|
+
it 'errors if not given all required arguments' do
|
5
|
+
expect {
|
6
|
+
described_class.new(name: 'nope', description: 'sorry')
|
7
|
+
}.to raise_error(/missing keyword: items/)
|
8
|
+
|
9
|
+
expect {
|
10
|
+
described_class.new(description: 'lol', items: [])
|
11
|
+
}.to raise_error(/missing keyword: name/)
|
12
|
+
|
13
|
+
expect {
|
14
|
+
described_class.new(name: 'lol', items: [])
|
15
|
+
}.to raise_error(/missing keyword: description/)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'succeeds if given all required arguments' do
|
19
|
+
future_transfer = described_class.new(name: 'frank', description: 'a decent bloke', items: [])
|
20
|
+
expect(future_transfer).to be_kind_of(FutureTransfer)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FutureWebItem do
|
4
|
+
it 'errors if not given all required arguments' do
|
5
|
+
expect {
|
6
|
+
described_class.new(url: 'https://www.wetransfer.com', local_identifier: '321235151')
|
7
|
+
}.to raise_error(/missing keyword: title/)
|
8
|
+
|
9
|
+
expect {
|
10
|
+
described_class.new(title: 'wetransfer.com')
|
11
|
+
}.to raise_error(/missing keyword: url/)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'succeeds if given all arguments' do
|
15
|
+
future_web_item = described_class.new(url: 'https://www.wetransfer.com', title: 'wetransfer.com', local_identifier: '321235151')
|
16
|
+
expect(future_web_item).to be_kind_of(FutureWebItem)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'succeeds if not passed a local_identifier' do
|
20
|
+
future_web_item = described_class.new(url: 'https://www.wetransfer.com', title: 'wetransfer.com')
|
21
|
+
expect(future_web_item).to be_kind_of(FutureWebItem)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'generates a local_identifier' do
|
25
|
+
future_web_item = described_class.new(url: 'https://www.wetransfer.com', title: 'wetransfer.com')
|
26
|
+
expect(future_web_item).to be_kind_of(FutureWebItem)
|
27
|
+
expect(future_web_item.local_identifier).to_not be nil
|
28
|
+
expect(future_web_item.local_identifier).to be_kind_of(String)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'creates params properly' do
|
32
|
+
future_web_item = described_class.new(url: 'https://www.wetransfer.com', title: 'wetransfer.com')
|
33
|
+
item_as_params = future_web_item.to_item_request_params
|
34
|
+
expect(item_as_params[:content_identifier]).to eq('web_content')
|
35
|
+
expect(item_as_params[:local_identifier]).to be_kind_of(String)
|
36
|
+
expect(item_as_params[:url]).to eq('https://www.wetransfer.com')
|
37
|
+
expect(item_as_params[:meta][:title]).to eq('wetransfer.com')
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TransferBuilder do
|
4
|
+
it 'raises if given an item with a size of 0' do
|
5
|
+
broken = StringIO.new('')
|
6
|
+
expect {
|
7
|
+
described_class.new.ensure_io_compliant!(broken)
|
8
|
+
}.to raise_error(/The IO object given to add_file has a size of 0/)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'raises if IO raises an error' do
|
12
|
+
broken = []
|
13
|
+
|
14
|
+
expect {
|
15
|
+
described_class.new.ensure_io_compliant!(broken)
|
16
|
+
}.to raise_error(TransferBuilder::TransferIOError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'adds a file' do
|
20
|
+
transfer_builder = described_class.new
|
21
|
+
transfer_builder.add_file_at(path: __FILE__)
|
22
|
+
expect(transfer_builder.items.count).to eq(1)
|
23
|
+
|
24
|
+
item = transfer_builder.items.first
|
25
|
+
expect(item.name).to eq('transfer_builder_spec.rb')
|
26
|
+
expect(item.io).to be_kind_of(File)
|
27
|
+
expect(item.local_identifier).to be_kind_of(String)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should add a url' do
|
31
|
+
transfer_builder = described_class.new
|
32
|
+
transfer_builder.add_web_content(path: 'https://www.wetransfer.com')
|
33
|
+
expect(transfer_builder.items.count).to eq(1)
|
34
|
+
|
35
|
+
item = transfer_builder.items.first
|
36
|
+
expect(item.url).to eq('https://wetransfer.com/')
|
37
|
+
expect(item.title).to eq('wetransfer.com')
|
38
|
+
expect(item.local_identifier).to be_kind_of(String)
|
39
|
+
end
|
40
|
+
end
|
data/wetransfer.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
Please update your usage accordingly. Thank you and our apologies for the disruption.
|
34
34
|
}
|
35
35
|
|
36
|
-
spec.add_dependency 'faraday', '~> 0.
|
36
|
+
spec.add_dependency 'faraday', '~> 0.12'
|
37
37
|
spec.add_dependency 'ks', '~> 0.0.1'
|
38
38
|
|
39
39
|
spec.add_development_dependency 'dotenv', '~> 2.2'
|
@@ -43,4 +43,5 @@ Gem::Specification.new do |spec|
|
|
43
43
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
44
44
|
spec.add_development_dependency 'simplecov', '~> 0.15'
|
45
45
|
spec.add_development_dependency 'wetransfer_style', '0.5.0'
|
46
|
+
spec.add_development_dependency 'open_uri_redirections'
|
46
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wetransfer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Berman
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '0.
|
20
|
+
version: '0.12'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '0.
|
27
|
+
version: '0.12'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: ks
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,6 +137,20 @@ dependencies:
|
|
137
137
|
- - '='
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: 0.5.0
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: open_uri_redirections
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
140
154
|
description: Ruby bindings for using WeTransfer's Public API.
|
141
155
|
email:
|
142
156
|
- noah@wetransfer.com
|
@@ -164,9 +178,20 @@ files:
|
|
164
178
|
- bin/setup
|
165
179
|
- examples/create_transfer.rb
|
166
180
|
- lib/we_transfer_client.rb
|
181
|
+
- lib/we_transfer_client/future_file_item.rb
|
182
|
+
- lib/we_transfer_client/future_transfer.rb
|
183
|
+
- lib/we_transfer_client/future_web_item.rb
|
184
|
+
- lib/we_transfer_client/remote_item.rb
|
185
|
+
- lib/we_transfer_client/remote_transfer.rb
|
186
|
+
- lib/we_transfer_client/transfer_builder.rb
|
167
187
|
- lib/we_transfer_client/version.rb
|
168
188
|
- spec/integration_spec.rb
|
169
189
|
- spec/spec_helper.rb
|
190
|
+
- spec/we_transfer_client/future_file_item_spec.rb
|
191
|
+
- spec/we_transfer_client/future_transfer_spec.rb
|
192
|
+
- spec/we_transfer_client/future_web_item_spec.rb
|
193
|
+
- spec/we_transfer_client/transfer_builder_spec.rb
|
194
|
+
- spec/we_transfer_client_spec.rb
|
170
195
|
- wetransfer.gemspec
|
171
196
|
homepage: https://developers.wetransfer.com
|
172
197
|
licenses:
|
@@ -192,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
217
|
version: '0'
|
193
218
|
requirements: []
|
194
219
|
rubyforge_project:
|
195
|
-
rubygems_version: 2.6.
|
220
|
+
rubygems_version: 2.6.14
|
196
221
|
signing_key:
|
197
222
|
specification_version: 4
|
198
223
|
summary: A Ruby SDK for WeTransfer's Public API
|