Sha256: 37b19e4e203ccbda3607fdb4d3f0257da7847855772a84160e21af9110f95176

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/console/docopt_runner'
require 'eac_cli/default_runner'

module Avm
  module Tools
    class Runner < ::EacRubyUtils::Console::DocoptRunner
      class EacRedmineBase0 < ::EacRubyUtils::Console::DocoptRunner
        class Runner < ::EacRubyUtils::Console::DocoptRunner
          include ::EacCli::DefaultRunner

          runner_definition do
            desc 'Runs a Ruby code with "rails runner".'
            arg_opt '-e', '--environment', 'Specifies the environment for the runner to operate' \
              " under (test/development/production).\n" \
              'Default: development'
            pos_arg 'code'
          end

          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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
avm-tools-0.49.0 lib/avm/tools/runner/eac_redmine_base0/runner.rb
avm-tools-0.48.0 lib/avm/tools/runner/eac_redmine_base0/runner.rb
avm-tools-0.47.0 lib/avm/tools/runner/eac_redmine_base0/runner.rb