class TrelloFs::BoardBuilder

Attributes

board[R]
repository[R]

Public Class Methods

new(repository, board) click to toggle source
# File lib/trello-fs/board_builder.rb, line 5
def initialize(repository, board)
  @repository = repository
  @board = board
end

Public Instance Methods

board_name() click to toggle source
# File lib/trello-fs/board_builder.rb, line 63
def board_name
  @board.name
end
build() click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# File lib/trello-fs/board_builder.rb, line 57
def folder_name
  StringToFileName.convert(board_name)
end
Also aliased as: relative_path
labels_content() click to toggle source
# 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() click to toggle source
# File lib/trello-fs/board_builder.rb, line 53
def path
  File.join(@repository.path, folder_name)
end
readme_content() click to toggle source
# File lib/trello-fs/board_builder.rb, line 25
def readme_content
  [
    "# [#{board_name}](#{@board.url})",
    "[#{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"),
    labels_content
  ].join("\n\n")
end
relative_path()
Alias for: folder_name
repository_name() click to toggle source
# File lib/trello-fs/board_builder.rb, line 67
def repository_name
  @repository.title
end