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
392 393 394 |
# File 'lib/hub/context.rb', line 392 def ==(other) other.respond_to?(:to_str) ? name == other.to_str : super end |
#github_url ⇒ Object
405 406 407 |
# File 'lib/hub/context.rb', line 405 def github_url urls.detect {|url| local_repo.known_host?(url.host) } end |
#project ⇒ Object
396 397 398 399 400 401 402 403 |
# File 'lib/hub/context.rb', line 396 def project urls.each { |url| if valid = GithubProject.from_url(url, local_repo) return valid end } nil end |
#uri_parse(uri) ⇒ Object
427 428 429 430 431 432 433 434 |
# File 'lib/hub/context.rb', line 427 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
409 410 411 412 413 414 415 416 417 418 |
# File 'lib/hub/context.rb', line 409 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
420 421 422 423 424 425 |
# File 'lib/hub/context.rb', line 420 def with_normalized_url(url) if url =~ %r{^[\w-]+://} || url =~ %r{^([^/]+?):} url = "ssh://#{$1}/#{$'}" if $1 yield url end end |