Class: Github::Paths

Inherits:
Object
  • Object
show all
Extended by:
Checks
Defined in:
app/github/paths.rb

Overview

Methods for dealing with GitHub paths.

Class Method Summary collapse

Methods included from Checks

check_boolean, check_enumerable_of, check_is_a, check_non_empty_string, check_non_nil, check_positive_integer

Class Method Details

.parse_file_path(path) ⇒ Object

Parses a path like “<owner>/<repo>/<ref>/<some_path>” into owner, repo, ref, path.



16
17
18
19
20
21
22
23
24
# File 'app/github/paths.rb', line 16

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