Sha256: a15c52e3a47f31d7ae0c4697da10bf8e48fab36a10616365f886998f35bb08a0

Contents?: true

Size: 1.22 KB

Versions: 16

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

namespace :rimless do
  require 'fileutils'

  # Install a template file to the project.
  #
  # @param src [String] the template source file name
  # @param dest [Array<String>] the relative destination parts
  def install_template(src, *dest)
    src = File.join(__dir__, 'templates', src)
    dest = File.join(Dir.pwd, *dest, File.basename(src))

    return puts "#    [Skip] #{dest}" if File.exist? dest

    puts "# [Install] #{dest}"
    FileUtils.mkdir_p(File.dirname(dest))
    FileUtils.copy(src, dest)
  end

  # rubocop:disable Rails/RakeEnvironment because this is just an
  #   helper command, no need for an application bootstrap
  desc 'Install the Rimless consumer components'
  task :install do
    install_template('karafka.rb')
    install_template('application_consumer.rb', 'app', 'consumers')
    install_template('custom_consumer.rb', 'app', 'consumers')
    install_template('custom_consumer_spec.rb', 'spec', 'consumers')

    puts <<~OUTPUT
      #
      # Installation done.
      #
      # You can now configure your routes at the +karafka.rb+ file at
      # your project root. And list all routes with +rake rimless:routes+.
    OUTPUT
  end
  # rubocop:enable Rails/RakeEnvironment
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rimless-1.8.0 lib/rimless/tasks/generator.rake
rimless-1.7.7 lib/rimless/tasks/generator.rake
rimless-1.7.6 lib/rimless/tasks/generator.rake
rimless-1.7.5 lib/rimless/tasks/generator.rake
rimless-1.7.4 lib/rimless/tasks/generator.rake
rimless-1.7.3 lib/rimless/tasks/generator.rake
rimless-1.7.2 lib/rimless/tasks/generator.rake
rimless-1.7.1 lib/rimless/tasks/generator.rake
rimless-1.7.0 lib/rimless/tasks/generator.rake
rimless-1.6.0 lib/rimless/tasks/generator.rake
rimless-1.5.1 lib/rimless/tasks/generator.rake
rimless-1.5.0 lib/rimless/tasks/generator.rake
rimless-1.4.2 lib/rimless/tasks/generator.rake
rimless-1.4.1 lib/rimless/tasks/generator.rake
rimless-1.4.0 lib/rimless/tasks/generator.rake
rimless-1.3.0 lib/rimless/tasks/generator.rake