Sha256: 7def52d7b02c6e4641602da9b1b07db0cc9e4afc51b64797729111d9cf62e187

Contents?: true

Size: 1.1 KB

Versions: 5

Compression:

Stored size: 1.1 KB

Contents

module Danger
  module RequestSources
    class RequestSource
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
danger-0.9.1 lib/danger/request_source/request_source.rb
danger-0.9.0 lib/danger/request_source/request_source.rb
danger-0.8.4 lib/danger/request_source/request_source.rb
danger-0.8.3 lib/danger/request_source/request_source.rb
danger-0.8.2 lib/danger/request_source/request_source.rb