Sha256: 346d0a15b9165158224d472606a4c788e0b875082d449842f7f6d15e43290fec

Contents?: true

Size: 663 Bytes

Versions: 2

Compression:

Stored size: 663 Bytes

Contents

module Source2MD
  class Generator
    attr_accessor :params

    def initialize(params = {})
      @params = params
    end

    def call
      output_file.write(to_md)
      puts "write: #{output_file}"
    end

    private

    def to_md
      s = file_blocks.collect(&:to_md) * "\n\n"
      s = TextHelper.text_squish(s)
      s = TextHelper.add_newline_at_end_of_text(s)
    end

    def file_blocks
      @file_blocks ||= files.collect { |e| FileBlock.new(e) }
    end

    def files
      @files ||= params[:files].collect { |e| Pathname(e) }
    end

    def output_file
      @output_file ||= Pathname(params[:output_file]).expand_path
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
source2md-0.0.2 lib/source2md/generator.rb
source2md-0.0.1 lib/source2md/generator.rb