Class: BuildTool::VCS::GitRemote

Inherits:
Object
  • Object
show all
Defined in:
lib/build-tool/vcs/git.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ GitRemote

Returns a new instance of GitRemote.



28
29
30
31
# File 'lib/build-tool/vcs/git.rb', line 28

def initialize( name )
    self.name = name
    @user = nil
end

Instance Attribute Details

#nameObject

The name for the remote



12
13
14
# File 'lib/build-tool/vcs/git.rb', line 12

def name
  @name
end

#pathObject

The path for the remote



18
19
20
# File 'lib/build-tool/vcs/git.rb', line 18

def path
  @path
end

#push_pathObject

The path to push to for the remote



24
25
26
# File 'lib/build-tool/vcs/git.rb', line 24

def push_path
  @push_path
end

#push_serverObject

The hostname to push to for the remote



21
22
23
# File 'lib/build-tool/vcs/git.rb', line 21

def push_server
  @push_server
end

#serverObject

The hostname for the remote



15
16
17
# File 'lib/build-tool/vcs/git.rb', line 15

def server
  @server
end

#userObject (readonly)

Returns the value of attribute user.



26
27
28
# File 'lib/build-tool/vcs/git.rb', line 26

def user
  @user
end

Instance Method Details

#push_urlObject

Returns the pushUrl configured or nil if not configured.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/build-tool/vcs/git.rb', line 58

def push_url
    if !push_server
        return nil
    end
    if !push_server.host
        raise ConfigurationError, "No host specified for server #{push_server.name}"
    end

    url = push_server.host
    if push_server.path
        url = "#{url}/#{push_server.path}"
    end
    if user
        url = "#{user}@#{url}"
    end
    if push_server.protocol
        url = "#{push_server.protocol}://#{url}"
    end
    if path
        url = "#{url}/#{path}"
    end
    url
end

#urlObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/build-tool/vcs/git.rb', line 33

def url
    if !server
        raise ConfigurationError, "No server specified for remote #{name}"
    end
    if !server.host
        raise ConfigurationError, "No host specified for server #{server.name}"
    end

    url = server.host
    if server.path
        url = "#{url}/#{server.path}"
    end
    if user
        url = "#{user}@#{url}"
    end
    if server.protocol
        url = "#{server.protocol}://#{url}"
    end
    if path
        url = "#{url}/#{path}"
    end
    url
end