Sha256: 15f40fb061c1b717c0574ffc95adade459665f00c3b5f1835ebb68638ea2c054

Contents?: true

Size: 1.86 KB

Versions: 9

Compression:

Stored size: 1.86 KB

Contents

# frozen_string_literal: true

require "refinements/struct"

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

      def self.call(...) = new(...).call

      def initialize configuration, builder: Rubysmith::Builder
        @configuration = configuration
        @builder = builder
      end

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

      private

      attr_reader :configuration, :builder

      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_temp_directory
        builder.call(configuration.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.32.0 lib/hanamismith/builders/core.rb
hanamismith-0.31.0 lib/hanamismith/builders/core.rb
hanamismith-0.30.0 lib/hanamismith/builders/core.rb
hanamismith-0.29.0 lib/hanamismith/builders/core.rb
hanamismith-0.28.1 lib/hanamismith/builders/core.rb
hanamismith-0.28.0 lib/hanamismith/builders/core.rb
hanamismith-0.27.0 lib/hanamismith/builders/core.rb
hanamismith-0.26.0 lib/hanamismith/builders/core.rb
hanamismith-0.25.0 lib/hanamismith/builders/core.rb