Class: TrelloFs::BoardBuilder
- Inherits:
-
Object
- Object
- TrelloFs::BoardBuilder
- Defined in:
- lib/trello-fs/board_builder.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #board_name ⇒ Object
- #build ⇒ Object
- #build_readme ⇒ Object
- #folder_name ⇒ Object (also: #relative_path)
-
#initialize(repository, board) ⇒ BoardBuilder
constructor
A new instance of BoardBuilder.
- #labels_content ⇒ Object
- #path ⇒ Object
- #readme_content ⇒ Object
- #repository_name ⇒ Object
Constructor Details
#initialize(repository, board) ⇒ BoardBuilder
Returns a new instance of BoardBuilder.
5 6 7 8 |
# File 'lib/trello-fs/board_builder.rb', line 5 def initialize(repository, board) @repository = repository @board = board end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
3 4 5 |
# File 'lib/trello-fs/board_builder.rb', line 3 def board @board end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
3 4 5 |
# File 'lib/trello-fs/board_builder.rb', line 3 def repository @repository end |
Instance Method Details
#board_name ⇒ Object
63 64 65 |
# File 'lib/trello-fs/board_builder.rb', line 63 def board_name @board.name end |
#build ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/trello-fs/board_builder.rb', line 10 def build board.lists.each do |list| ListBuilder.new(self, list).build end build_readme end |
#build_readme ⇒ Object
18 19 20 21 22 23 |
# File 'lib/trello-fs/board_builder.rb', line 18 def build_readme readme_path = File.join(path, 'README.md') File.open(readme_path, 'w') do |file| file.write(readme_content) end end |
#folder_name ⇒ Object Also known as: relative_path
57 58 59 |
# File 'lib/trello-fs/board_builder.rb', line 57 def folder_name StringToFileName.convert(board_name) end |
#labels_content ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/trello-fs/board_builder.rb', line 42 def labels_content return '' unless @board.labels && @board.labels.any? @board.labels.sort {|a, b| a.name <=> b.name }. select {|lbl| lbl.cards.any? }. map do |label| label_builder = LabelBuilder.new(@repository, label) "[`#{label_builder.label_name}`](../#{label_builder.relative_path})" end.join(' ') end |
#path ⇒ Object
53 54 55 |
# File 'lib/trello-fs/board_builder.rb', line 53 def path File.join(@repository.path, folder_name) end |
#readme_content ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trello-fs/board_builder.rb', line 25 def readme_content [ "# [#{board_name}](#{@board.url})", labels_content, "[#{repository_name}](../README.md)", board.lists.map do |list| list_builder = ListBuilder.new(self, list) list_link = "[#{list_builder.list_name}](#{list_builder.file_name}/README.md)" [ "## #{list_link}", list_builder.content(true) ].join("\n\n") end.join("\n\n") ].join("\n\n") end |
#repository_name ⇒ Object
67 68 69 |
# File 'lib/trello-fs/board_builder.rb', line 67 def repository_name @repository.title end |