Skip to content
This repository was archived by the owner on Dec 11, 2020. It is now read-only.

Commit b641436

Browse files
authored
Optional set title to web content (#26)
* optional set title to web content * Bumped version * rubocop * Specify content * added title to add_url method example * Remove post install message
1 parent 9eb68f3 commit b641436

File tree

6 files changed

+29
-12
lines changed

6 files changed

+29
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ transfer = @client.create_transfer(name: "My wonderful transfer", description: "
6868
upload.add_file_at(path: '/path/to/local/file.jpg')
6969
upload.add_file_at(path: '/path/to/another/local/file.jpg')
7070
upload.add_file(name: 'README.txt', io: StringIO.new("This is the contents of the file"))
71-
upload.add_web_content(url: "https://www.the.url.you.want.to.share.com"))
71+
upload.add_web_url(url: "https://www.the.url.you.want.to.share.com", title: "title of the url"))
7272
end
7373

7474
transfer.shortened_url => "https://we.tl/SSBsb3ZlIHJ1Ynk="

lib/we_transfer_client/transfer_builder.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ def add_file_at(path:)
1616
add_file(name: File.basename(path), io: File.open(path, 'rb'))
1717
end
1818

19-
def add_web_content(url:)
20-
@items << FutureWebItem.new(url: url, title: url)
19+
def add_web_url(url:, title: nil)
20+
title ||= url
21+
@items << FutureWebItem.new(url: url, title: title)
2122
true
2223
end
2324

lib/we_transfer_client/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class WeTransferClient
2-
VERSION = '0.4.1'
2+
VERSION = '0.4.2'
33
end

spec/integration_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def broken.read(*)
9797
client = WeTransferClient.new(api_key: ENV.fetch('WT_API_KEY'), logger: test_logger)
9898
transfer = client.create_transfer(name: 'My collection of web content', description: 'link collection') do |builder|
9999
10.times do
100-
builder.add_web_content(url: 'https://www.wetransfer.com')
100+
builder.add_web_url(url: 'https://www.wetransfer.com')
101101
end
102102
end
103103
expect(transfer).to be_kind_of(RemoteTransfer)
@@ -135,7 +135,7 @@ def broken.read(*)
135135
expect(add_result).to eq(true)
136136

137137
# add url to transfer
138-
add_result = builder.add_web_content(url: 'http://www.wetransfer.com')
138+
add_result = builder.add_web_url(url: 'http://www.wetransfer.com', title: 'website used for file transfers')
139139
expect(add_result).to eq(true)
140140
end
141141

spec/we_transfer_client/transfer_builder_spec.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,33 @@
2929

3030
it 'should add a url' do
3131
transfer_builder = described_class.new
32-
transfer_builder.add_web_content(url: 'https://www.wetransfer.com/')
32+
transfer_builder.add_web_url(url: 'https://www.wetransfer.com/')
3333
expect(transfer_builder.items.count).to eq(1)
3434

3535
item = transfer_builder.items.first
3636
expect(item.url).to eq('https://www.wetransfer.com/')
37+
expect(item.local_identifier).to be_kind_of(String)
38+
end
39+
40+
it 'should user url for the title when none is given' do
41+
transfer_builder = described_class.new
42+
transfer_builder.add_web_url(url: 'https://www.wetransfer.com/')
43+
expect(transfer_builder.items.count).to eq(1)
44+
45+
item = transfer_builder.items.first
46+
3747
expect(item.title).to eq('https://www.wetransfer.com/')
3848
expect(item.local_identifier).to be_kind_of(String)
3949
end
50+
51+
it 'should pass title as webcontent title' do
52+
transfer_builder = described_class.new
53+
transfer_builder.add_web_url(url: 'https://www.wetransfer.com/', title: 'awesome website for file transfering')
54+
expect(transfer_builder.items.count).to eq(1)
55+
56+
item = transfer_builder.items.first
57+
expect(item.url).to eq('https://www.wetransfer.com/')
58+
expect(item.title).to eq('awesome website for file transfering')
59+
expect(item.local_identifier).to be_kind_of(String)
60+
end
4061
end

wetransfer.gemspec

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ Gem::Specification.new do |spec|
2727
spec.bindir = 'exe'
2828
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2929
spec.require_paths = ['lib']
30-
spec.post_install_message = %q{
31-
Warning: We have changed the syntax for the create_transfer method.
32-
create_transfer(title:, message:) is now create_transfer(name:, description:)
33-
Please update your usage accordingly. Thank you and our apologies for the disruption.
34-
}
3530

3631
spec.add_dependency 'faraday', '~> 0.12'
3732
spec.add_dependency 'ks', '~> 0.0.1'

0 commit comments

Comments
 (0)