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: 1ad4e72e639015d196993e241a9de84c03b26603
4
- data.tar.gz: 23f3e09d23a991b51fdd2fc0cb2f28ae96ad7248
3
+ metadata.gz: da00f44ee1357ebf00449eb4b77cd855597366c5
4
+ data.tar.gz: 05539b142f5d5b4d4381dc395fc65e30e384e5ac
5
5
  SHA512:
6
- metadata.gz: 00ba43ada3f4c1dea631715b8830225f0c8d1e915dff7470b84a5d16749e10078b02039564f0828577e140aeee0db887f85512bacbbff55d57d45e05030a5e18
7
- data.tar.gz: 406460a7a03e8fcb445830d0d81e9dd073993209f21681572fd43df93da744510523165ce8bf29b4e9dceb7e92117d470b5b8f4213f7787eee2c2ff3042b0a5d
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(@attachment.url).read
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.relative_path
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
- name = path.split('/').last
64
- path = "../../#{path}"
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
@@ -1,3 +1,3 @@
1
1
  module TrelloFs
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -1,7 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe TrelloFs::AttachmentBuilder do
4
- let(:attachment) { OpenStruct.new(id: '1', name: 'Attachment Name') }
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.5
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-03-14 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler