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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ebefc351370a8ba8f791877c159709ae3830489
4
- data.tar.gz: 53d1be480618e93933bbeb6bc3b6fe08fa9f7ae2
3
+ metadata.gz: a4e776850b441acf7babb494a9663071aace594c
4
+ data.tar.gz: a9091dd78cef3599f0cc5d6f5e6c2d7d48cb18ac
5
5
  SHA512:
6
- metadata.gz: d2347e25ce6218113bd073a5b46167295de01d930a7337fe20008738c96cc286e3b11d45d140459a7b7ee022c67d9d3d6f32c495e31724ba32e36ae12894d90d
7
- data.tar.gz: 6e7571f9e8657b1cf491087af1a255bec52a5087b52c5ec759c57b43fe92bf8566abd346c360b4256d87c8fef7a3e7f11fbb2482ed1a8afc40e2d6f9afc5b2c1
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',
@@ -4,7 +4,7 @@
4
4
 
5
5
  [`images`](../Labels/images.md) [`puppies`](../Labels/puppies.md)
6
6
 
7
-
7
+ Here is a link to the one with a cat: [A card with an image](../../TrelloFs_Demo_Board/A_Second_List_of_Cards/A_card_with_an_image.md)
8
8
 
9
9
 
10
10
 
@@ -21,7 +21,6 @@ module TrelloFs
21
21
  reject {|fn| File.directory?(fn) }.
22
22
  each do |file|
23
23
  next if new_attachments.include? file
24
- puts file
25
24
  FileUtils.rm(file)
26
25
 
27
26
  # remove parent dir if empty
@@ -53,7 +53,7 @@ module TrelloFs
53
53
  "[#{list_name}](README.md)"
54
54
  ].join(' > '),
55
55
  labels,
56
- @card.desc,
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
@@ -81,7 +81,7 @@ module TrelloFs
81
81
  a
82
82
  end
83
83
 
84
- @repository.cards[card['shortLink']] = card
84
+ @repository.cards[card['shortLink']] = c
85
85
  c
86
86
  end
87
87
 
@@ -1,3 +1,3 @@
1
1
  module TrelloFs
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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.5
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