Sha256: 06f3b15449783b50641cd0d14b40ca05e136cf880d5137c6b308b867532346f1

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'rake'

require_relative '../static/assets'
require_relative '../static/site'

module Nesta
  module Commands
    class Build
      DEFAULT_DESTINATION = "dist"

      attr_accessor :domain

      def initialize(build_dir = nil, options = {})
        @build_dir = build_dir || DEFAULT_DESTINATION
        if @build_dir == Nesta::App.settings.public_folder
          raise RuntimeError.new("#{@build_dir} is already used, for assets")
        end
        @domain = options['domain'] || configured_domain_name
      end

      def configured_domain_name
        Nesta::Config.build.fetch('domain', 'localhost')
      end

      def execute(process)
        logger = Proc.new { |message| puts message }
        site = Nesta::Static::Site.new(@build_dir, @domain, logger)
        site.render_pages
        site.render_not_found
        site.render_atom_feed
        site.render_sitemap
        site.render_templated_assets
        Nesta::Static::Assets.new(@build_dir, logger).copy_attachments
        Nesta::Static::Assets.new(@build_dir, logger).copy_public_folder
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
nesta-0.18.0 lib/nesta/commands/build.rb
nesta-0.17.0 lib/nesta/commands/build.rb
nesta-0.16.0 lib/nesta/commands/build.rb
nesta-0.15.0 lib/nesta/commands/build.rb
nesta-0.14.0 lib/nesta/commands/build.rb