Class: Sem::Helpers::GitUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/sem/helpers/git_url.rb

Constant Summary collapse

SSH_PATTERN =

example: [email protected]:renderedtext/cli.git

%r{^git@(.+)\..+\:(.+)\/(.+)\.git$}
GITHUB_HTTP_PATTERN =
%r{^(https:\/\/)?github.com/(.+)/(.+)$}
BITBUCKET_HTTP_PATTERN =
%r{^(https:\/\/)?bitbucket.org/(.+)/(.+)$}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ GitUrl

Returns a new instance of GitUrl.



11
12
13
# File 'lib/sem/helpers/git_url.rb', line 11

def initialize(url)
  @repo_provider, @repo_owner, @repo_name = parse(url)
end

Instance Attribute Details

#repo_nameObject (readonly)

Returns the value of attribute repo_name.



7
8
9
# File 'lib/sem/helpers/git_url.rb', line 7

def repo_name
  @repo_name
end

#repo_ownerObject (readonly)

Returns the value of attribute repo_owner.



8
9
10
# File 'lib/sem/helpers/git_url.rb', line 8

def repo_owner
  @repo_owner
end

#repo_providerObject (readonly)

Returns the value of attribute repo_provider.



9
10
11
# File 'lib/sem/helpers/git_url.rb', line 9

def repo_provider
  @repo_provider
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/sem/helpers/git_url.rb', line 15

def valid?
  @repo_name && @repo_provider && @repo_owner
end