Sha256: e463f82ec6b5de64cba7b39a70e593e79d23adab8d76925bc5a98eba90705cad

Contents?: true

Size: 1.04 KB

Versions: 26

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'
require 'eac_ruby_utils/fs/clearable_directory'

module Ehbrs
  module CookingBook
    class Build
      require_sub __FILE__
      enable_simple_cache
      enable_listable
      lists.add_symbol :option, :target_dir

      common_constructor :project, :options, default: [{}] do
        self.options = self.class.lists.option.hash_keys_validate!(options.symbolize_keys)
      end

      def run
        target_dir.clear
        index_page.build
        recipes_pages.each(&:build)
      end

      private

      def index_page_uncached
        ::Ehbrs::CookingBook::Build::IndexPage.new(self)
      end

      def recipes_pages_uncached
        project.recipes.map do |recipe|
          ::Ehbrs::CookingBook::Build::RecipePage.new(self, recipe)
        end
      end

      def target_dir_uncached
        ::EacRubyUtils::Fs::ClearableDirectory.new(options[OPTION_TARGET_DIR] || default_target_dir)
      end

      def default_target_dir
        project.root.join('dist')
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
ehbrs-tools-0.35.1 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.35.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.34.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.33.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.32.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.31.1 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.31.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.30.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.29.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.28.3 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.28.2 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.28.1 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.28.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.27.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.26.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.25.1 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.25.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.24.0 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.23.1 lib/ehbrs/cooking_book/build.rb
ehbrs-tools-0.23.0 lib/ehbrs/cooking_book/build.rb