Sha256: ec76380ba46d9a3e792d0007ff83f4e71688dba39d8b58577f1f8473d1e12fc2

Contents?: true

Size: 1.95 KB

Versions: 7

Compression:

Stored size: 1.95 KB

Contents

# frozen_string_literal: true

require 'rake_factory'

require_relative '../tasks'

module RakeGithub
  module TaskSets
    class Repository < RakeFactory::TaskSet
      prepend RakeFactory::Namespaceable

      parameter :repository, required: true
      parameter :access_token, required: true
      parameter :deploy_keys, default: []

      parameter :deploy_keys_namespace, default: :deploy_keys
      parameter :deploy_keys_destroy_task_name, default: :destroy
      parameter :deploy_keys_provision_task_name, default: :provision
      parameter :deploy_keys_ensure_task_name, default: :ensure

      task Tasks::DeployKeys::Provision,
           name: RakeFactory::DynamicValue.new { |ts|
             ts.deploy_keys_provision_task_name
           }
      task Tasks::DeployKeys::Destroy,
           name: RakeFactory::DynamicValue.new { |ts|
             ts.deploy_keys_destroy_task_name
           }
      task Tasks::DeployKeys::Ensure,
           name: RakeFactory::DynamicValue.new { |ts|
             ts.deploy_keys_ensure_task_name
           },
           provision_task_name: RakeFactory::DynamicValue.new { |ts|
             ts.deploy_keys_provision_task_name
           },
           destroy_task_name: RakeFactory::DynamicValue.new { |ts|
             ts.deploy_keys_destroy_task_name
           }
      task Tasks::PullRequests::Merge

      def define_on(application)
        around_define(application) do
          self.class.tasks.each do |task_definition|
            namespace = resolve_namespace(task_definition)

            application.in_namespace(namespace) do
              task_definition
                .for_task_set(self)
                .define_on(application)
            end
          end
        end
      end

      private

      def resolve_namespace(task_definition)
        case task_definition.klass.to_s
        when /DeployKeys/ then deploy_keys_namespace
        when /PullRequests/ then :pull_requests
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rake_github-0.16.0.pre.2 lib/rake_github/task_sets/repository.rb
rake_github-0.16.0.pre.1 lib/rake_github/task_sets/repository.rb
rake_github-0.15.0 lib/rake_github/task_sets/repository.rb
rake_github-0.14.0.pre.2 lib/rake_github/task_sets/repository.rb
rake_github-0.14.0.pre.1 lib/rake_github/task_sets/repository.rb
rake_github-0.13.0 lib/rake_github/task_sets/repository.rb
rake_github-0.12.0.pre.6 lib/rake_github/task_sets/repository.rb