Sha256: 0eee1ad8c1e19c5930c20183b93e8f4a48291c8460de03d71273179cf03c21c6

Contents?: true

Size: 1.89 KB

Versions: 2

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

require "refinements/struct"

module Hanamismith
  module Builders
    # Builds project skeleton foundation.
    class Core < Rubysmith::Builders::Abstract
      using Refinements::Struct

      def call
        private_methods.grep(/\Aadd_/).sort.each { |method| __send__ method }
        configuration
      end

      private

      def add_action
        builder.call(configuration.merge(template_path: "%project_name%/app/action.rb.erb")).render
      end

      def add_repository
        builder.call(configuration.merge(template_path: "%project_name%/app/repository.rb.erb"))
               .render
      end

      def add_view
        builder.call(configuration.merge(template_path: "%project_name%/app/view.rb.erb")).render
      end

      def add_application_configuration
        builder.call(configuration.merge(template_path: "%project_name%/config/app.rb.erb")).render
      end

      def add_routes_configuration
        builder.call(configuration.merge(template_path: "%project_name%/config/routes.rb.erb"))
               .render
      end

      def add_settings_configuration
        builder.call(configuration.merge(template_path: "%project_name%/config/settings.rb.erb"))
               .render
      end

      def add_types
        path = "%project_name%/lib/%project_path%/types.rb.erb"
        builder.call(configuration.merge(template_path: path)).render
      end

      def add_migrate_directory
        builder.call(configuration.merge(template_path: "%project_name%/db/migrate")).make_path
      end

      def add_public_http_errors
        %w[404 500].each do |code|
          path = "%project_name%/public/#{code}.html.erb"
          builder.call(configuration.merge(template_path: path)).render
        end
      end

      def add_temp_directory
        builder.call(configuration.merge(template_path: "%project_name%/tmp")).make_path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanamismith-0.38.0 lib/hanamismith/builders/core.rb
hanamismith-0.37.0 lib/hanamismith/builders/core.rb