Class: GitMarkdown::RemoteParser
- Inherits:
-
Object
- Object
- GitMarkdown::RemoteParser
- Defined in:
- lib/git/markdown/remote_parser.rb
Constant Summary collapse
- PATTERNS =
{ github: %r{(?:github\.com|github\.enterprise)[/:]([^/]+)/([^/]+?)(?:\.git)?$}, gitlab: %r{gitlab\.com[/:]([^/]+)/([^/]+?)(?:\.git)?$} }
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #full_name ⇒ Object
-
#initialize(url) ⇒ RemoteParser
constructor
A new instance of RemoteParser.
- #valid? ⇒ Boolean
Constructor Details
#initialize(url) ⇒ RemoteParser
Returns a new instance of RemoteParser.
12 13 14 15 |
# File 'lib/git/markdown/remote_parser.rb', line 12 def initialize(url) @url = url parse! end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
10 11 12 |
# File 'lib/git/markdown/remote_parser.rb', line 10 def owner @owner end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
10 11 12 |
# File 'lib/git/markdown/remote_parser.rb', line 10 def provider @provider end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
10 11 12 |
# File 'lib/git/markdown/remote_parser.rb', line 10 def repo @repo end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/git/markdown/remote_parser.rb', line 10 def url @url end |
Class Method Details
.from_git_remote(remote = "origin") ⇒ Object
21 22 23 24 25 26 |
# File 'lib/git/markdown/remote_parser.rb', line 21 def self.from_git_remote(remote = "origin") url = git_remote_url(remote) return nil if url.nil? || url.empty? new(url) end |
.parse(url) ⇒ Object
17 18 19 |
# File 'lib/git/markdown/remote_parser.rb', line 17 def self.parse(url) new(url) end |
Instance Method Details
#full_name ⇒ Object
32 33 34 |
# File 'lib/git/markdown/remote_parser.rb', line 32 def full_name "#{@owner}/#{@repo}" if valid? end |
#valid? ⇒ Boolean
28 29 30 |
# File 'lib/git/markdown/remote_parser.rb', line 28 def valid? !@provider.nil? end |