Sha256: 4c760a7583b20b16f0b11a910372ece3382e28abc312596c84951976359908b7

Contents?: true

Size: 432 Bytes

Versions: 59

Compression:

Stored size: 432 Bytes

Contents

require "danger/ci_source/support/repo_info"

module Danger
  class FindRepoInfoFromURL
    REGEXP = %r{
      (?<slug>[^/]+/[^/]+)
      (/(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

59 entries across 59 versions & 1 rubygems

Version Path
danger-5.4.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.3.5 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.3.4 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.3.3 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.3.2 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.3.1 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.3.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.2.2 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.2.1 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.2.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.1.1 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.1.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.0.3 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.0.2 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.0.1 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-5.0.0 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-4.3.5 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-4.3.4 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-4.3.3 lib/danger/ci_source/support/find_repo_info_from_url.rb
danger-4.3.2 lib/danger/ci_source/support/find_repo_info_from_url.rb