Sha256: f126e08d12757732621cda2fc8c4c778396cd565f3e7fc56d1327d44162c65f8

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

require "bundler"

class Terminalwire::InstallGenerator < Rails::Generators::Base
  source_root File.expand_path("templates", __dir__)

  argument :binary_name, type: :string, required: true, banner: "binary_name"

  def create_terminal_files
    template "application_terminal.rb.tt", Rails.root.join("app/terminal/application_terminal.rb")
  end

  def create_binary_files
    copy_file "bin/terminalwire", binary_path
    chmod binary_path, 0755, verbose: false
  end

  def add_route
    route <<~ROUTE
      match "/terminal",
        to: Terminalwire::WebSocket::ThorServer.new(ApplicationTerminal),
        via: [:get, :connect]
    ROUTE
  end

  def print_post_install_message
    say ""
    say "Terminalwire has been successfully installed!", :green
    say "Run `#{binary_path.relative_path_from(Rails.root)}` to verify everything is in working order. For support visit https://terminalwire.com."
    say ""
  end

  private

  def binary_path
    Rails.root.join("bin", binary_name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
terminalwire-0.1.1 lib/generators/terminalwire/install/install_generator.rb