Class: JekyllGithubContent::GithubUriParser
- Inherits:
-
Object
- Object
- JekyllGithubContent::GithubUriParser
- Defined in:
- lib/jekyll_github_content.rb
Constant Summary collapse
- GITHUB_URI_ROOT =
'https://github.com/'- GITHUB_RAW_URI_ROOT =
'https://raw.githubusercontent.com'
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #get_raw_file_uri ⇒ Object
- #get_repo_uri ⇒ Object
- #get_user_uri ⇒ Object
-
#initialize(path) ⇒ GithubUriParser
constructor
A new instance of GithubUriParser.
Constructor Details
#initialize(path) ⇒ GithubUriParser
Returns a new instance of GithubUriParser.
15 16 17 18 19 20 21 |
# File 'lib/jekyll_github_content.rb', line 15 def initialize(path) relative_path = path.sub(/^https?\:\/\//, '').sub(/^github.com/, '') url_chunks = relative_path.split('/').delete_if { |e| e.empty? } @user, @repo, blob, @branch = url_chunks[0..3] @file = File.join(url_chunks[4..-1]) end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
13 14 15 |
# File 'lib/jekyll_github_content.rb', line 13 def file @file end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
13 14 15 |
# File 'lib/jekyll_github_content.rb', line 13 def repo @repo end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
13 14 15 |
# File 'lib/jekyll_github_content.rb', line 13 def user @user end |
Instance Method Details
#get_raw_file_uri ⇒ Object
23 24 25 |
# File 'lib/jekyll_github_content.rb', line 23 def get_raw_file_uri File.join(GITHUB_RAW_URI_ROOT, @user, @repo, @branch, @file) end |
#get_repo_uri ⇒ Object
31 32 33 |
# File 'lib/jekyll_github_content.rb', line 31 def get_repo_uri File.join(GITHUB_URI_ROOT, @user, @repo) end |
#get_user_uri ⇒ Object
27 28 29 |
# File 'lib/jekyll_github_content.rb', line 27 def get_user_uri File.join(GITHUB_URI_ROOT, @user) end |