Sha256: 9c6f88567e4f059d075186ff9cf0a2ad06903dca0dd63a099b2dfac027058a92

Contents?: true

Size: 622 Bytes

Versions: 3

Compression:

Stored size: 622 Bytes

Contents

module Flutterby
  class Exporter
    def initialize(root)
      @root = root
    end

    def export!(into:)
      @root.paths.each do |path, node|
        if node.should_publish?
          path = ::File.expand_path(::File.join(into, node.url))

          if node.file?
            # Make sure directory exists
            FileUtils.mkdir_p(::File.dirname(path))

            # Write file
            ::File.write(path, node.render(layout: true))
            logger.info "Exported #{node.url}"
          end
        end
      end
    end


    private

    def logger
      @logger ||= Flutterby.logger
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flutterby-0.4.0 lib/flutterby/exporter.rb
flutterby-0.3.1 lib/flutterby/exporter.rb
flutterby-0.2.0 lib/flutterby/exporter.rb