Class: Hub::Context::Remote
- Inherits:
-
Struct
- Object
- Struct
- Hub::Context::Remote
- Defined in:
- lib/hub/context.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #github_url ⇒ Object
- #project ⇒ Object
- #uri_parse(uri) ⇒ Object
- #urls ⇒ Object
- #with_normalized_url(url) ⇒ Object
Instance Method Details
#==(other) ⇒ Object
388 389 390 |
# File 'lib/hub/context.rb', line 388 def ==(other) other.respond_to?(:to_str) ? name == other.to_str : super end |
#github_url ⇒ Object
401 402 403 |
# File 'lib/hub/context.rb', line 401 def github_url urls.detect {|url| local_repo.known_host?(url.host) } end |
#project ⇒ Object
392 393 394 395 396 397 398 399 |
# File 'lib/hub/context.rb', line 392 def project urls.each { |url| if valid = GithubProject.from_url(url, local_repo) return valid end } nil end |
#uri_parse(uri) ⇒ Object
423 424 425 426 427 428 429 430 |
# File 'lib/hub/context.rb', line 423 def uri_parse uri uri = URI.parse uri if uri.host != local_repo.default_host ssh = local_repo.ssh_config uri.host = ssh.get_value(uri.host, :HostName) { uri.host } end uri end |
#urls ⇒ Object
405 406 407 408 409 410 411 412 413 414 |
# File 'lib/hub/context.rb', line 405 def urls @urls ||= raw_urls.map do |url| with_normalized_url(url) do |normalized| begin uri_parse(normalized) rescue URI::InvalidURIError end end end.compact end |
#with_normalized_url(url) ⇒ Object
416 417 418 419 420 421 |
# File 'lib/hub/context.rb', line 416 def with_normalized_url(url) if url =~ %r{^[\w-]+://} || url =~ %r{^([^/]+?):} url = "ssh://#{$1}/#{$'}" if $1 yield url end end |