Sha256: e043524654bff0c6d1535cdc1145fa3201a6b844d74a331bd2aa38bd18b71428

Contents?: true

Size: 1.74 KB

Versions: 4

Compression:

Stored size: 1.74 KB

Contents

module Danger
  module RequestSources
    class RequestSource
      DANGER_REPO_NAME = "danger".freeze

      attr_accessor :ci_source, :environment, :scm, :host, :ignored_violations

      def self.inherited(child_class)
        available_request_sources.add child_class
        super
      end

      def self.available_request_sources
        @available_request_sources ||= Set.new
      end

      def initialize(_ci_source, _environment)
        raise "Subclass and overwrite initialize"
      end

      def validates?
        !!self.scm.origins.match(%r{#{Regexp.escape self.host}(:|/)(?<repo_slug>.+/.+?)(?:\.git)?$})
      end

      def scm
        @scm ||= nil
      end

      def host
        @host ||= nil
      end

      def ignored_violations
        @ignored_violations ||= []
      end

      def update_pull_request!(_warnings: [], _errors: [], _messages: [], _markdowns: [])
        raise "Subclass and overwrite update_pull_request!"
      end

      def setup_danger_branches
        raise "Subclass and overwrite setup_danger_branches"
      end

      def fetch_details
        raise "Subclass and overwrite initialize"
      end

      def organisation
        raise "Subclass and overwrite organisation"
      end

      def fetch_repository(_organisation: nil, _repository: nil)
        raise "Subclass and overwrite fetch_repository"
      end

      def fetch_danger_repo(_organisation: nil)
        raise "Subclass and overwrite fetch_danger_repo"
      end

      def danger_repo?(_organisation: nil, _repository: nil)
        raise "Subclass and overwrite danger_repo?"
      end

      def file_url(_organisation: nil, _repository: nil, _branch: "master", _path: nil)
        raise "Subclass and overwrite file_url"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
danger-2.0.1 lib/danger/request_source/request_source.rb
danger-2.0.0 lib/danger/request_source/request_source.rb
danger-0.10.1 lib/danger/request_source/request_source.rb
danger-0.10.0 lib/danger/request_source/request_source.rb