Sha256: bee91b23907bd128b57544de07acfbf1ecf0d22f4b289fb9da77b1a9edb5a5db

Contents?: true

Size: 943 Bytes

Versions: 1

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

module Gemsmith
  module Generators
    # Generates Rake support.
    class Rake < Base
      def run
        cli.template "%gem_name%/Rakefile.tt", configuration
        configure_rakefile
      end

      private

      def rspec_task
        "spec" if configuration.dig(:generate, :rspec)
      end

      def reek_task
        "reek" if configuration.dig(:generate, :reek)
      end

      def rubocop_task
        "rubocop" if configuration.dig(:generate, :rubocop)
      end

      def scss_lint_task
        "scss_lint" if configuration.dig(:generate, :scss_lint)
      end

      def default_tasks
        [rspec_task, reek_task, rubocop_task, scss_lint_task].compact
      end

      def configure_rakefile
        return if default_tasks.empty?
        cli.append_to_file "%gem_name%/Rakefile",
                           %(\ntask default: %w[#{default_tasks.join(" ")}]\n)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemsmith-9.0.0 lib/gemsmith/generators/rake.rb