Sha256: 49d6a29a6c4dd39c0094f2388aa8a4048f6670bac8952036fda8b36f88495cfe

Contents?: true

Size: 1.28 KB

Versions: 41

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

require 'eac_cli/definition'
require 'eac_cli/docopt/runner_extension'
require 'eac_cli/parser'
require 'eac_ruby_utils/core_ext'

module EacCli
  module Runner
    require_sub __FILE__
    extend ::ActiveSupport::Concern

    class << self
      def alias_runner_class_methods(klass, from_suffix, to_suffix)
        %i[create run].each do |method|
          alias_class_method(klass, build_method_name(method, from_suffix),
                             build_method_name(method, to_suffix))
        end
      end

      def runner?(object)
        object.is_a?(::Class) && object.included_modules.include?(::EacCli::Runner)
      end

      private

      def alias_class_method(klass, from, to)
        sklass = klass.singleton_class
        return unless sklass.method_defined?(from)

        sklass.send(:alias_method, to, from)
      end

      def build_method_name(name, suffix)
        ss = suffix.if_present('') { |s| "#{s}_" }
        "#{ss}#{name}"
      end
    end

    the_module = self
    included do
      the_module.alias_runner_class_methods(self, '', 'original')

      extend AfterClassMethods
      include InstanceMethods
      ::EacCli::Docopt::RunnerExtension.check(self)
      include ActiveSupport::Callbacks
      define_callbacks :run
    end
  end
end

Version data entries

41 entries across 41 versions & 3 rubygems

Version Path
avm-tools-0.95.0 vendor/eac_cli/lib/eac_cli/runner.rb
eac_cli-0.16.2 lib/eac_cli/runner.rb
eac_cli-0.16.1 lib/eac_cli/runner.rb
avm-tools-0.94.3 vendor/eac_cli/lib/eac_cli/runner.rb
eac_cli-0.16.0 lib/eac_cli/runner.rb
avm-tools-0.94.2 vendor/eac_cli/lib/eac_cli/runner.rb
avm-tools-0.94.1 vendor/eac_cli/lib/eac_cli/runner.rb
eac_cli-0.15.1 lib/eac_cli/runner.rb
eac_cli-0.15.0 lib/eac_cli/runner.rb
ehbrs-tools-0.20.0 vendor/eac_cli/lib/eac_cli/runner.rb
avm-tools-0.94.0 vendor/eac_cli/lib/eac_cli/runner.rb
eac_cli-0.14.0 lib/eac_cli/runner.rb
avm-tools-0.93.0 vendor/eac_cli/lib/eac_cli/runner.rb
eac_cli-0.13.0 lib/eac_cli/runner.rb
avm-tools-0.92.0 vendor/eac_cli/lib/eac_cli/runner.rb
avm-tools-0.91.0 vendor/eac_cli/lib/eac_cli/runner.rb
avm-tools-0.90.0 vendor/eac_cli/lib/eac_cli/runner.rb
avm-tools-0.89.0 vendor/eac_cli/lib/eac_cli/runner.rb
avm-tools-0.88.0 vendor/eac_cli/lib/eac_cli/runner.rb
eac_cli-0.12.6 lib/eac_cli/runner.rb