Sha256: a015c96a9f9f0de4ed839e2378c642d36c865d1ecc619171e5680b11845c30ef

Contents?: true

Size: 1.23 KB

Versions: 39

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/console/docopt_runner'
require 'eac_ruby_utils/core_ext'

module Avm
  module Rails
    module Runners
      class Runner < ::EacRubyUtils::Console::DocoptRunner
        enable_console_speaker
        enable_simple_cache

        DOC = <<~DOC
          Runs a Ruby code with "rails runner".

          Usage:
            __PROGRAM__ [options] <code>
            __PROGRAM__ --version
            __PROGRAM__ -h | --help

          Options:
            -h --help         Show this screen.
            -e --environment  Specifies the environment for the runner to
                              operate (test/development/production). Default: "development".
        DOC

        def run
          infov 'Runner arguments', runner_args
          infov 'Environment', context(:instance).host_env
          runner_command.system!
        end

        def runner_command_uncached
          context(:instance).bundle(*bundle_args)
        end

        def bundle_args
          %w[exec rails runner] + runner_args
        end

        def runner_args
          options.fetch('--environment').if_present([]) { |v| ['--environment', v] } +
            [options.fetch('<code>')]
        end
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
avm-tools-0.74.0 lib/avm/rails/runners/runner.rb
avm-tools-0.73.0 lib/avm/rails/runners/runner.rb
avm-tools-0.72.0 lib/avm/rails/runners/runner.rb
avm-tools-0.71.0 lib/avm/rails/runners/runner.rb
avm-tools-0.70.2 lib/avm/rails/runners/runner.rb
avm-tools-0.70.1 lib/avm/rails/runners/runner.rb
avm-tools-0.70.0 lib/avm/rails/runners/runner.rb
avm-tools-0.69.3 lib/avm/rails/runners/runner.rb
avm-tools-0.69.2 lib/avm/rails/runners/runner.rb
avm-tools-0.69.1 lib/avm/rails/runners/runner.rb
avm-tools-0.69.0 lib/avm/rails/runners/runner.rb
avm-tools-0.68.0 lib/avm/rails/runners/runner.rb
avm-tools-0.67.0 lib/avm/rails/runners/runner.rb
avm-tools-0.66.0 lib/avm/rails/runners/runner.rb
avm-tools-0.65.0 lib/avm/rails/runners/runner.rb
avm-tools-0.64.2 lib/avm/rails/runners/runner.rb
avm-tools-0.64.1 lib/avm/rails/runners/runner.rb
avm-tools-0.64.0 lib/avm/rails/runners/runner.rb
avm-tools-0.63.0 lib/avm/rails/runners/runner.rb
avm-tools-0.62.4 lib/avm/rails/runners/runner.rb