Sha256: 8b0b2bc208b8359ea017235444006d2ebd4c6e63d5378856f76d10c2e3f656c6

Contents?: true

Size: 859 Bytes

Versions: 7

Compression:

Stored size: 859 Bytes

Contents

# frozen_string_literal: true

module Gemsmith
  module Skeletons
    # Configures Rake support.
    class RakeSkeleton < BaseSkeleton
      def create_console_task
        cli.template "%gem_name%/lib/tasks/console.rake.tt", configuration.to_h
      end

      def create
        create_console_task
        cli.template "%gem_name%/Rakefile.tt", configuration.to_h
        configure_rakefile
      end

      private

      def rspec_task
        "spec" if configuration.create_rspec?
      end

      def rubocop_task
        "rubocop" if configuration.create_rubocop?
      end

      def default_tasks
        [rspec_task, rubocop_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

7 entries across 7 versions & 1 rubygems

Version Path
gemsmith-7.6.0 lib/gemsmith/skeletons/rake_skeleton.rb
gemsmith-7.5.0 lib/gemsmith/skeletons/rake_skeleton.rb
gemsmith-7.4.0 lib/gemsmith/skeletons/rake_skeleton.rb
gemsmith-7.3.0 lib/gemsmith/skeletons/rake_skeleton.rb
gemsmith-7.2.0 lib/gemsmith/skeletons/rake_skeleton.rb
gemsmith-7.1.0 lib/gemsmith/skeletons/rake_skeleton.rb
gemsmith-7.0.0 lib/gemsmith/skeletons/rake_skeleton.rb