Sha256: 8da187ecc582cb4640a0f8d4372a060abd7119ec4dd9592d3bb6b85d693d49a3

Contents?: true

Size: 455 Bytes

Versions: 12

Compression:

Stored size: 455 Bytes

Contents

require "danger/ci_source/support/repo_info"

module Danger
  class FindRepoInfoFromURL
    REGEXP = %r{
      ://[^/]+/
      (?<slug>[^/]+(/[^/]+){1,2})
      (/(pull|merge_requests|pull-requests)/)
      (?<id>\d+)
    }x

    def initialize(url)
      @url = url
    end

    def call
      matched = url.match(REGEXP)

      if matched
        RepoInfo.new(matched[:slug], matched[:id])
      end
    end

    private

    attr_reader :url
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
danger-5.9.1 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.9.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.8.2 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.8.1 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.8.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.7.1 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.7.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.6.7 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.6.6 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.6.5 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.6.4 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.6.3 lib/danger/ci_source/support/find_repo_info_from_url.rb