Class: CloneGitFile::GithubRepoParser
- Inherits:
-
Object
- Object
- CloneGitFile::GithubRepoParser
- Defined in:
- lib/clone_git_file/github_repo_parser.rb
Instance Method Summary collapse
-
#initialize(file) ⇒ GithubRepoParser
constructor
A new instance of GithubRepoParser.
- #parse ⇒ Object
- #valid_url? ⇒ Boolean
Constructor Details
#initialize(file) ⇒ GithubRepoParser
Returns a new instance of GithubRepoParser.
5 6 7 |
# File 'lib/clone_git_file/github_repo_parser.rb', line 5 def initialize(file) @file = file end |
Instance Method Details
#parse ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/clone_git_file/github_repo_parser.rb', line 9 def parse abort("Error: That url is not valid") unless valid_url? data = OpenStruct.new data.repo_url = parse_repo_url data.repo_name = parse_repo_name data.github_username = parse_github_username data.file_relative_path = parse_file_relative_path data.branch_name = parse_branch_name data end |
#valid_url? ⇒ Boolean
20 21 22 |
# File 'lib/clone_git_file/github_repo_parser.rb', line 20 def valid_url? !!@file.match(%r{.+github\.com/[^/]+/[^/]+}) end |