Sha256: 19903019754c8e91b4a3ee182927659a43afea1868a10cd2e8ae60d814d512ae

Contents?: true

Size: 1.78 KB

Versions: 9

Compression:

Stored size: 1.78 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 }
        true
      end

      private

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

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

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

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

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

      def add_settings_configuration
        builder.call(settings.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(settings.merge(template_path: path)).render
      end

      def add_migrate_directory
        builder.call(settings.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(settings.merge(template_path: path)).render
        end
      end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hanamismith-0.47.0 lib/hanamismith/builders/core.rb
hanamismith-0.46.0 lib/hanamismith/builders/core.rb
hanamismith-0.45.0 lib/hanamismith/builders/core.rb
hanamismith-0.44.0 lib/hanamismith/builders/core.rb
hanamismith-0.43.0 lib/hanamismith/builders/core.rb
hanamismith-0.42.0 lib/hanamismith/builders/core.rb
hanamismith-0.41.0 lib/hanamismith/builders/core.rb
hanamismith-0.40.0 lib/hanamismith/builders/core.rb
hanamismith-0.39.0 lib/hanamismith/builders/core.rb