trello-fs 0.1.5 → 0.1.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da00f44ee1357ebf00449eb4b77cd855597366c5
|
4
|
+
data.tar.gz: 05539b142f5d5b4d4381dc395fc65e30e384e5ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d40a0f286e72ce49461a32363fceb3a89d6538c9a35c39a5fab65390bf30ae0e6cd94bef257806bcce36530969c31264609230b63c5c82bad4ba431f524a02c
|
7
|
+
data.tar.gz: 0554b429271b6d5920d1794b01dd616a4ca089a1c6bb7f3cfcfbb628d547f6bd9530b99da2723a12239d0ba461e70c87ed2ed672b954467dc16e4e3a9b4f7188
|
@@ -20,6 +20,8 @@ module TrelloFs
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def download_and_save
|
23
|
+
return unless is_trello_attachment?
|
24
|
+
|
23
25
|
data = download
|
24
26
|
return unless data
|
25
27
|
|
@@ -53,8 +55,12 @@ module TrelloFs
|
|
53
55
|
File.exist? path
|
54
56
|
end
|
55
57
|
|
58
|
+
def is_trello_attachment?
|
59
|
+
url.include?('trello-attachments.s3.amazonaws.com')
|
60
|
+
end
|
61
|
+
|
56
62
|
def download
|
57
|
-
open(
|
63
|
+
open(url).read
|
58
64
|
end
|
59
65
|
|
60
66
|
def repository
|
@@ -64,5 +70,9 @@ module TrelloFs
|
|
64
70
|
def board_builder
|
65
71
|
@card_builder.board_builder
|
66
72
|
end
|
73
|
+
|
74
|
+
def url
|
75
|
+
@attachment.url
|
76
|
+
end
|
67
77
|
end
|
68
78
|
end
|
@@ -17,7 +17,11 @@ module TrelloFs
|
|
17
17
|
attachment_paths = @card.attachments.map do |attachment|
|
18
18
|
attachment_builder = AttachmentBuilder.new(self, attachment)
|
19
19
|
attachment_builder.build
|
20
|
-
attachment_builder.
|
20
|
+
if attachment_builder.is_trello_attachment?
|
21
|
+
attachment_builder.relative_path
|
22
|
+
else
|
23
|
+
attachment_builder.url
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
File.open(path, 'w') do |file|
|
@@ -60,8 +64,13 @@ module TrelloFs
|
|
60
64
|
return '' unless attachment_paths.any?
|
61
65
|
|
62
66
|
links = attachment_paths.map do |path|
|
63
|
-
|
64
|
-
|
67
|
+
if is_url?(path)
|
68
|
+
name = path
|
69
|
+
else
|
70
|
+
name = path.split('/').last
|
71
|
+
path = "../../#{path}"
|
72
|
+
end
|
73
|
+
|
65
74
|
link = "[#{name}](#{path})"
|
66
75
|
if path.end_with?('.png') || path.end_with?('.jpg') || path.end_with?('gif') || path.end_with?('.jpeg')
|
67
76
|
"!#{link}"
|
@@ -108,5 +117,11 @@ module TrelloFs
|
|
108
117
|
def repository_name
|
109
118
|
repository.title
|
110
119
|
end
|
120
|
+
|
121
|
+
private
|
122
|
+
|
123
|
+
def is_url?(path)
|
124
|
+
path.start_with?('http://') || path.start_with?('https://')
|
125
|
+
end
|
111
126
|
end
|
112
127
|
end
|
data/lib/trello-fs/version.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe TrelloFs::AttachmentBuilder do
|
4
|
-
let(:attachment) { OpenStruct.new(id: '1',
|
4
|
+
let(:attachment) { OpenStruct.new(id: '1',
|
5
|
+
name: 'Attachment Name',
|
6
|
+
url: 'trello-attachments.s3.amazonaws.com') }
|
5
7
|
let(:card) { OpenStruct.new(name: 'Card Name', attachments: [attachment]) }
|
6
8
|
let(:list) { OpenStruct.new(name: 'List Name', cards: [card]) }
|
7
9
|
let(:board) { OpenStruct.new(name: 'Board') }
|
@@ -34,4 +36,18 @@ describe TrelloFs::AttachmentBuilder do
|
|
34
36
|
should eq true
|
35
37
|
end
|
36
38
|
end
|
39
|
+
|
40
|
+
describe '#is_trello_attachment?' do
|
41
|
+
subject { attachment_builder.is_trello_attachment? }
|
42
|
+
|
43
|
+
it do
|
44
|
+
attachment.url = 'http://not-trello.com'
|
45
|
+
should eq false
|
46
|
+
end
|
47
|
+
|
48
|
+
it do
|
49
|
+
attachment.url = 'https://trello-attachments.s3.amazonaws.com/fdksajfls'
|
50
|
+
should eq true
|
51
|
+
end
|
52
|
+
end
|
37
53
|
end
|
@@ -31,7 +31,7 @@ describe TrelloFs::CardBuilder do
|
|
31
31
|
subject { card_builder }
|
32
32
|
|
33
33
|
describe '#content' do
|
34
|
-
subject { card_builder.content(['Attachments/file.pdf', 'Attachments/picture.png']) }
|
34
|
+
subject { card_builder.content(['Attachments/file.pdf', 'Attachments/picture.png', 'http://url.com/file.docx']) }
|
35
35
|
|
36
36
|
it { should include 'Card Name' }
|
37
37
|
it { should include 'Card Description' }
|
@@ -40,6 +40,7 @@ describe TrelloFs::CardBuilder do
|
|
40
40
|
it { should include 'List Name' }
|
41
41
|
it { should include '[file.pdf' }
|
42
42
|
it { should include '![picture.png]' }
|
43
|
+
it { should include '[http://url.com/file.docx](http://url.com/file.docx)' }
|
43
44
|
end
|
44
45
|
|
45
46
|
describe '#path' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trello-fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matúš Tomlein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|