Sha256: df6d05b88ee2aff70432a360b03d8a1b2cbd9d382f8b0c55065fd03c3f2fcdce

Contents?: true

Size: 984 Bytes

Versions: 13

Compression:

Stored size: 984 Bytes

Contents

# frozen_string_literal: true

require "refinements/struct"

module Hanamismith
  module Builders
    # Builds project skeleton console for object inspection and exploration.
    class Console < Rubysmith::Builders::Console
      using Refinements::Struct

      def call
        return false unless settings.build_console

        super
        builder.call(settings.merge(template_path: "%project_name%/bin/console.erb"))
               .replace(/require Bundler.root.+/, %(require "hanami/prepare"))

        add_irb_autocomplete

        true
      end

      private

      def add_irb_autocomplete
        with_template.insert_before "IRB.start", <<~CODE
          unless Hanami.env? :development, :test
            ENV["IRB_USE_AUTOCOMPLETE"] ||= "false"
            puts "IRB autocomplete disabled."
          end

        CODE
      end

      def with_template
        builder.call settings.merge(template_path: "%project_name%/bin/console.erb")
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hanamismith-0.50.0 lib/hanamismith/builders/console.rb
hanamismith-0.49.1 lib/hanamismith/builders/console.rb
hanamismith-0.49.0 lib/hanamismith/builders/console.rb
hanamismith-0.48.0 lib/hanamismith/builders/console.rb
hanamismith-0.47.0 lib/hanamismith/builders/console.rb
hanamismith-0.46.0 lib/hanamismith/builders/console.rb
hanamismith-0.45.0 lib/hanamismith/builders/console.rb
hanamismith-0.44.0 lib/hanamismith/builders/console.rb
hanamismith-0.43.0 lib/hanamismith/builders/console.rb
hanamismith-0.42.0 lib/hanamismith/builders/console.rb
hanamismith-0.41.0 lib/hanamismith/builders/console.rb
hanamismith-0.40.0 lib/hanamismith/builders/console.rb
hanamismith-0.39.0 lib/hanamismith/builders/console.rb