trello-fs 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/examples/boards/TrelloFs_Demo_Board/A_Second_List_of_Cards/This_one_has_a_puppy.md +1 -1
- data/lib/trello-fs/attachment_cleaner.rb +0 -1
- data/lib/trello-fs/card_builder.rb +5 -1
- data/lib/trello-fs/link_replacer.rb +35 -0
- data/lib/trello-fs/trello_api.rb +1 -1
- data/lib/trello-fs/version.rb +1 -1
- data/spec/trello-fs/link_replacer_spec.rb +68 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4e776850b441acf7babb494a9663071aace594c
|
4
|
+
data.tar.gz: a9091dd78cef3599f0cc5d6f5e6c2d7d48cb18ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8136ccfa0503cb8f7440089b0826ad5e708c3697b5dafcc98e36c576d5bb0dd61c4ead62004d4520d9bf34682d61e394f569da74f1ec2882be3cb6f59a5b009c
|
7
|
+
data.tar.gz: c749c02925949ff498aaa24ac869f328d826623f51c07bcdbf29e1c6fa489a05457d88d566297ad52482c84e3ae0ea071462a1bef2693b22f81767e4561044be
|
data/README.md
CHANGED
@@ -18,6 +18,7 @@ from this Trello board:
|
|
18
18
|
- label files that contain references to cards with the labels
|
19
19
|
- supports updating the repository
|
20
20
|
- downloads the same attachments only once
|
21
|
+
- replaces links to cards in the exported boards with local links
|
21
22
|
|
22
23
|
# Installation
|
23
24
|
|
@@ -33,6 +34,8 @@ from this Trello board:
|
|
33
34
|
require 'trello-fs'
|
34
35
|
|
35
36
|
TrelloFs.build({
|
37
|
+
title: 'Some Title',
|
38
|
+
description: 'Some Description',
|
36
39
|
path: 'PATH_TO_THE_TARGET_FOLDER',
|
37
40
|
developer_public_key: 'DEVELOPER_PUBLIC_KEY',
|
38
41
|
member_token: 'MEMBER_TOKEN',
|
@@ -53,7 +53,7 @@ module TrelloFs
|
|
53
53
|
"[#{list_name}](README.md)"
|
54
54
|
].join(' > '),
|
55
55
|
labels,
|
56
|
-
|
56
|
+
card_description,
|
57
57
|
attachments_content(attachment_paths)
|
58
58
|
].join("\n\n")
|
59
59
|
end
|
@@ -79,6 +79,10 @@ module TrelloFs
|
|
79
79
|
@card.name
|
80
80
|
end
|
81
81
|
|
82
|
+
def card_description
|
83
|
+
LinkReplacer.new(repository).card_description(@card)
|
84
|
+
end
|
85
|
+
|
82
86
|
def repository
|
83
87
|
@list_builder.repository
|
84
88
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module TrelloFs
|
2
|
+
class LinkReplacer
|
3
|
+
def initialize(repository)
|
4
|
+
@repository = repository
|
5
|
+
end
|
6
|
+
|
7
|
+
def card_description(card)
|
8
|
+
links = links_in_description(card)
|
9
|
+
description = card.desc.dup
|
10
|
+
|
11
|
+
links.each do |link|
|
12
|
+
url = link.first
|
13
|
+
short_link = link.last
|
14
|
+
|
15
|
+
linked_card = @repository.cards[short_link]
|
16
|
+
next unless linked_card
|
17
|
+
|
18
|
+
card_builder = CardBuilder.new_by_card(@repository, linked_card)
|
19
|
+
link_to_card = "[#{card_builder.card_name}](../../#{card_builder.relative_path})"
|
20
|
+
description.gsub!(url, link_to_card)
|
21
|
+
end
|
22
|
+
|
23
|
+
description
|
24
|
+
end
|
25
|
+
|
26
|
+
def links_in_description(card)
|
27
|
+
card.desc.scan(/(https:\/\/trello.com\/c\/[\w]*(?:\/[\w_=+-]*)?)/).map do |match|
|
28
|
+
url = match.first
|
29
|
+
url.match(/https:\/\/trello.com\/c\/([\w]*)/)
|
30
|
+
short_id = $1
|
31
|
+
[url, short_id]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/trello-fs/trello_api.rb
CHANGED
data/lib/trello-fs/version.rb
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe TrelloFs::LinkReplacer do
|
4
|
+
let(:repository) { TestRepository.new }
|
5
|
+
let(:list) do
|
6
|
+
OpenStruct.new(
|
7
|
+
name: 'List Name',
|
8
|
+
board: OpenStruct.new(name: 'Board Name')
|
9
|
+
)
|
10
|
+
end
|
11
|
+
let(:card1) do
|
12
|
+
OpenStruct.new(
|
13
|
+
desc: 'https://trello.com/c/card2id/71-software-center-denmark-day-25-2-2015',
|
14
|
+
name: 'Card 1',
|
15
|
+
list: list
|
16
|
+
)
|
17
|
+
end
|
18
|
+
let(:card2) do
|
19
|
+
OpenStruct.new(
|
20
|
+
desc: 'https://trello.com/c/card1id some text https://trello.com/c/card2id',
|
21
|
+
name: 'Card 2',
|
22
|
+
list: list
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
before :each do
|
27
|
+
repository.cards['card1id'] = card1
|
28
|
+
repository.cards['card2id'] = card2
|
29
|
+
end
|
30
|
+
|
31
|
+
subject { TrelloFs::LinkReplacer.new(repository) }
|
32
|
+
|
33
|
+
describe '#links_in_description' do
|
34
|
+
it 'finds links with text at the end' do
|
35
|
+
expect(subject.links_in_description(card1)).to eq [
|
36
|
+
['https://trello.com/c/card2id/71-software-center-denmark-day-25-2-2015', 'card2id']
|
37
|
+
]
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'finds all the links' do
|
41
|
+
expect(subject.links_in_description(card2)).to eq [
|
42
|
+
['https://trello.com/c/card1id', 'card1id'],
|
43
|
+
['https://trello.com/c/card2id', 'card2id']
|
44
|
+
]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#card_description' do
|
49
|
+
it 'removes the links from the description' do
|
50
|
+
expect(subject.card_description(card1)).not_to include 'https://trello.com'
|
51
|
+
expect(subject.card_description(card2)).not_to include 'https://trello.com'
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'keeps other text' do
|
55
|
+
expect(subject.card_description(card2)).to include 'some text'
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'creates links to local files' do
|
59
|
+
expect(subject.card_description(card1)).to include 'Card 2'
|
60
|
+
expect(subject.card_description(card1)).to include 'List_Name/Card_2'
|
61
|
+
|
62
|
+
expect(subject.card_description(card2)).to include 'Card 1'
|
63
|
+
expect(subject.card_description(card2)).to include 'List_Name/Card_1'
|
64
|
+
expect(subject.card_description(card2)).to include 'Card 2'
|
65
|
+
expect(subject.card_description(card2)).to include 'List_Name/Card_2'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trello-fs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matúš Tomlein
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/trello-fs/card_builder.rb
|
111
111
|
- lib/trello-fs/label_builder.rb
|
112
112
|
- lib/trello-fs/labels_builder.rb
|
113
|
+
- lib/trello-fs/link_replacer.rb
|
113
114
|
- lib/trello-fs/list_builder.rb
|
114
115
|
- lib/trello-fs/repository.rb
|
115
116
|
- lib/trello-fs/repository_cleaner.rb
|
@@ -123,6 +124,7 @@ files:
|
|
123
124
|
- spec/trello-fs/board_builder_spec.rb
|
124
125
|
- spec/trello-fs/card_builder_spec.rb
|
125
126
|
- spec/trello-fs/label_builder_spec.rb
|
127
|
+
- spec/trello-fs/link_replacer_spec.rb
|
126
128
|
- spec/trello-fs/list_builder_spec.rb
|
127
129
|
- spec/trello-fs/repository_spec.rb
|
128
130
|
- spec/trello-fs/string_to_file_name_spec.rb
|
@@ -160,6 +162,7 @@ test_files:
|
|
160
162
|
- spec/trello-fs/board_builder_spec.rb
|
161
163
|
- spec/trello-fs/card_builder_spec.rb
|
162
164
|
- spec/trello-fs/label_builder_spec.rb
|
165
|
+
- spec/trello-fs/link_replacer_spec.rb
|
163
166
|
- spec/trello-fs/list_builder_spec.rb
|
164
167
|
- spec/trello-fs/repository_spec.rb
|
165
168
|
- spec/trello-fs/string_to_file_name_spec.rb
|