Class: TrelloFs::CardBuilder
- Inherits:
-
Object
- Object
- TrelloFs::CardBuilder
- Defined in:
- lib/trello-fs/card_builder.rb
Instance Attribute Summary collapse
-
#list_builder ⇒ Object
readonly
Returns the value of attribute list_builder.
Class Method Summary collapse
Instance Method Summary collapse
- #attachments_content(attachment_paths = []) ⇒ Object
- #board ⇒ Object
- #board_builder ⇒ Object
- #board_name ⇒ Object
- #build ⇒ Object
- #card_description ⇒ Object
- #card_labels ⇒ Object
- #card_name ⇒ Object
- #content(attachment_paths = []) ⇒ Object
- #file_name ⇒ Object
-
#initialize(list_builder, card) ⇒ CardBuilder
constructor
A new instance of CardBuilder.
- #list_name ⇒ Object
- #path ⇒ Object
- #relative_path ⇒ Object
- #repository ⇒ Object
- #repository_name ⇒ Object
Constructor Details
#initialize(list_builder, card) ⇒ CardBuilder
Returns a new instance of CardBuilder.
9 10 11 12 |
# File 'lib/trello-fs/card_builder.rb', line 9 def initialize(list_builder, card) @card = card @list_builder = list_builder end |
Instance Attribute Details
#list_builder ⇒ Object (readonly)
Returns the value of attribute list_builder.
3 4 5 |
# File 'lib/trello-fs/card_builder.rb', line 3 def list_builder @list_builder end |
Class Method Details
.new_by_card(repository, card) ⇒ Object
5 6 7 |
# File 'lib/trello-fs/card_builder.rb', line 5 def self.new_by_card(repository, card) self.new(ListBuilder.new_by_list(repository, card.list), card) end |
Instance Method Details
#attachments_content(attachment_paths = []) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/trello-fs/card_builder.rb', line 59 def ( = []) return '' unless .any? links = .map do |path| name = path.split('/').last path = "../../#{path}" link = "[#{name}](#{path})" if path.end_with?('.png') || path.end_with?('.jpg') || path.end_with?('gif') || path.end_with?('.jpeg') "!#{link}" else link end end.join("\n\n") "\n\n## Attachments\n\n#{links}" end |
#board ⇒ Object
96 97 98 |
# File 'lib/trello-fs/card_builder.rb', line 96 def board board_builder.board end |
#board_builder ⇒ Object
92 93 94 |
# File 'lib/trello-fs/card_builder.rb', line 92 def board_builder @list_builder.board_builder end |
#board_name ⇒ Object
100 101 102 |
# File 'lib/trello-fs/card_builder.rb', line 100 def board_name board_builder.board_name end |
#build ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/trello-fs/card_builder.rb', line 14 def build @list_builder.build_path = @card..map do || = AttachmentBuilder.new(self, ) .build .relative_path end File.open(path, 'w') do |file| file.write(content()) end end |
#card_description ⇒ Object
80 81 82 |
# File 'lib/trello-fs/card_builder.rb', line 80 def card_description LinkReplacer.new(repository).card_description(@card) end |
#card_labels ⇒ Object
88 89 90 |
# File 'lib/trello-fs/card_builder.rb', line 88 def card_labels @card_labels ||= @card.labels end |
#card_name ⇒ Object
76 77 78 |
# File 'lib/trello-fs/card_builder.rb', line 76 def card_name @card.name end |
#content(attachment_paths = []) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/trello-fs/card_builder.rb', line 40 def content( = []) labels = card_labels.map do |lbl| label_builder = LabelBuilder.new(repository, lbl) "[`#{label_builder.label_name}`](../../#{label_builder.relative_path})" end.sort.join(' ') [ "# [#{card_name}](#{@card.url})", [ "[#{repository_name}](../../README.md)", "[#{board_name}](../README.md)", "[#{list_name}](README.md)" ].join(' > '), labels, card_description, () ].join("\n\n") end |
#file_name ⇒ Object
36 37 38 |
# File 'lib/trello-fs/card_builder.rb', line 36 def file_name "#{StringToFileName.convert(@card.name)}.md" end |
#list_name ⇒ Object
104 105 106 |
# File 'lib/trello-fs/card_builder.rb', line 104 def list_name @list_builder.list_name end |
#path ⇒ Object
28 29 30 |
# File 'lib/trello-fs/card_builder.rb', line 28 def path File.join(@list_builder.path, file_name) end |
#relative_path ⇒ Object
32 33 34 |
# File 'lib/trello-fs/card_builder.rb', line 32 def relative_path File.join(@list_builder.relative_path, file_name) end |
#repository ⇒ Object
84 85 86 |
# File 'lib/trello-fs/card_builder.rb', line 84 def repository @list_builder.repository end |
#repository_name ⇒ Object
108 109 110 |
# File 'lib/trello-fs/card_builder.rb', line 108 def repository_name repository.title end |