Sha256: 15bddd0979326033d338d7225ac53c9cdc5cbc5c4ee053407e37085c2e533776

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

def run_turbo_install_template(path)
  system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../install/#{path}.rb",  __dir__)}"
end

def redis_installed?
  system('which redis-server')
end

def switch_on_redis_if_available
  if redis_installed?
    Rake::Task["turbo:install:redis"].invoke
  else
    puts "Run turbo:install:redis to switch on Redis and use it in development for turbo streams"
  end
end

namespace :turbo do
  desc "Install Turbo into the app"
  task :install do
    if defined?(Webpacker::Engine)
      Rake::Task["turbo:install:webpacker"].invoke
    else
      Rake::Task["turbo:install:asset_pipeline"].invoke
    end
  end

  namespace :install do
    desc "Install Turbo into the app with asset pipeline"
    task :asset_pipeline do
      run_turbo_install_template "turbo_with_asset_pipeline"
      switch_on_redis_if_available
    end

    desc "Install Turbo into the app with webpacker"
    task :webpacker do
      run_turbo_install_template "turbo_with_webpacker"
      switch_on_redis_if_available
    end

    desc "Switch on Redis and use it in development"
    task :redis do
      run_turbo_install_template "turbo_needs_redis"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turbo-rails-0.7.10 lib/tasks/turbo_tasks.rake