Class: API::RemoteSourceVCS

Inherits:
Object
  • Object
show all
Defined in:
lib/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ RemoteSourceVCS

Returns a new instance of RemoteSourceVCS.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/api.rb', line 18

def initialize(url)
  @url = url

  if url =~ API::SOURCE_URL_PATTERN[:golang_org]
    url = API::GolangOrg.new(url).repo_url
  end
  @vcs = if url =~ API::SOURCE_URL_PATTERN[:github]
           API::Github.new(url)
         elsif url =~ API::SOURCE_URL_PATTERN[:git_kernel_org]
           API::GitKernelOrg.new(url)
         elsif url =~ API::SOURCE_URL_PATTERN[:bitbucket]
           API::Bitbucket.new(url)
         elsif url =~ API::SOURCE_URL_PATTERN[:google_source_com]
           API::GoogleSourceCom.new(url)
         elsif url =~ API::SOURCE_URL_PATTERN[:code_google_com]
           API::CodeGoogleCom.new(url)
         elsif url =~ API::SOURCE_URL_PATTERN[:go_pkg_in]
           API::GoPkgIn.new(url)
         else
           nil
           # raise "Unknown repostory: #{url}"
         end
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



17
18
19
# File 'lib/api.rb', line 17

def url
  @url
end

#vcsObject (readonly)

Returns the value of attribute vcs.



17
18
19
# File 'lib/api.rb', line 17

def vcs
  @vcs
end

Instance Method Details

#get_homepageObject



46
47
48
49
50
51
52
# File 'lib/api.rb', line 46

def get_homepage
  homepage = nil
  if @vcs.class == API::GoPkgIn
    homepage = @url
  end
  homepage
end

#get_last_commitObject



42
43
44
# File 'lib/api.rb', line 42

def get_last_commit
  @vcs.last_commits
end