Sha256: 9de1e90f6e9d922a806920f49b67086f0ac787cf6c4d739d2dc6dee3aa06194e
Contents?: true
Size: 680 Bytes
Versions: 13
Compression:
Stored size: 680 Bytes
Contents
# frozen_string_literal: true require_relative '../checks' module Github # Methods for dealing with GitHub paths. class Paths class << self include Checks # "<owner>/<repo>/<ref>/<some_path>" PATH_PATTERN = %r{^(?:[^/]+/){3}.*[^/]$} private_constant :PATH_PATTERN # Parses a path like "<owner>/<repo>/<ref>/<some_path>" into owner, repo, ref, path. def parse_file_path(path) check_non_empty_string(path: path) raise "invalid path: #{path}" unless PATH_PATTERN.match?(path) owner, repo, ref, *path = path.split('/') path = path.join('/') [owner, repo, ref, path] end end end end
Version data entries
13 entries across 13 versions & 1 rubygems