Class: GitIt::UrlGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/git-it/url_generator.rb

Overview

Link generator compatible with GitHub like site UI

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository_url) ⇒ UrlGenerator

all you need is the repository url



9
10
11
12
13
14
15
16
17
# File 'lib/git-it/url_generator.rb', line 9

def initialize(repository_url)
  @repository_url = repository_url

  @repo = /^git@(.*):(.*)\/(.*).git$/.match(@repository_url)

  @site = @repo[1]
  @user = @repo[2]
  @proj = @repo[3]
end

Instance Attribute Details

#repository_urlObject (readonly)

[email protected]:more-ron/git-it.git



6
7
8
# File 'lib/git-it/url_generator.rb', line 6

def repository_url
  @repository_url
end

Instance Method Details

#branch_url(branch_name) ⇒ Object



20
21
22
# File 'lib/git-it/url_generator.rb', line 20

def branch_url(branch_name)
  "https://#{@site}/#{@user}/#{@proj}/tree/#{branch_name}"
end

#compare_branches_url(to, from = "master") ⇒ Object



25
26
27
# File 'lib/git-it/url_generator.rb', line 25

def compare_branches_url(to, from = "master")
  "https://#{@site}/#{@user}/#{@proj}/compare/#{from}...#{to}"
end

#pull_request_url(source, destination = "master") ⇒ Object



30
31
32
# File 'lib/git-it/url_generator.rb', line 30

def pull_request_url(source, destination = "master")
  "https://#{@site}/#{@user}/#{@proj}/pull/new/#{@user}:#{destination}...#{source}"
end

#test_url(branch_name) ⇒ Object



35
36
37
# File 'lib/git-it/url_generator.rb', line 35

def test_url(branch_name)
  "https://circleci.com/gh/#{@user}/#{@proj}/tree/#{branch_name}"
end