Sha256: 7ad1b6a79e439853b980f21d1876b013542c8dc5d950480c29aa7335adf5b7b5

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true

module RakeSecrets
  module Mixins
    module Support
      def task_by_name(task, name)
        task.application.lookup(name, task.scope)
      end

      def task_defined?(task, name)
        !task_by_name(task, name).nil?
      end

      def ensure_task_with_name_available(task, name)
        raise_task_undefined(name) unless task_defined?(task, name)
      end

      def invoke_task_with_name(task, name, args)
        ensure_task_with_name_available(task, name)
        task_by_name(task, name).invoke(*args)
      end

      def reenable_task_with_name(task, name)
        ensure_task_with_name_available(task, name)
        task_by_name(task, name).reenable
      end

      def invoke_and_reenable_task_with_name(task, name, args)
        invoke_task_with_name(task, name, args)
        reenable_task_with_name(task, name)
      end

      def raise_task_undefined(name)
        raise(
          RakeFactory::DependencyTaskMissing,
          "The task with name #{name} does not exist."
        )
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rake_secrets-0.3.0.pre.2 lib/rake_secrets/mixins/support.rb
rake_secrets-0.3.0.pre.1 lib/rake_secrets/mixins/support.rb
rake_secrets-0.2.0 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.8 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.7 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.6 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.5 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.4 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.3 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.2 lib/rake_secrets/mixins/support.rb
rake_secrets-0.1.0.pre.1 lib/rake_secrets/mixins/support.rb