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.



57
58
59
60
# File 'lib/build-tool/vcs/git.rb', line 57

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

Instance Attribute Details

#nameObject

The name for the remote



41
42
43
# File 'lib/build-tool/vcs/git.rb', line 41

def name
  @name
end

#pathObject

The path for the remote



47
48
49
# File 'lib/build-tool/vcs/git.rb', line 47

def path
  @path
end

#push_pathObject

The path to push to for the remote



53
54
55
# File 'lib/build-tool/vcs/git.rb', line 53

def push_path
  @push_path
end

#push_serverObject

The hostname to push to for the remote



50
51
52
# File 'lib/build-tool/vcs/git.rb', line 50

def push_server
  @push_server
end

#serverObject

The hostname for the remote



44
45
46
# File 'lib/build-tool/vcs/git.rb', line 44

def server
  @server
end

#userObject (readonly)

Returns the value of attribute user.



55
56
57
# File 'lib/build-tool/vcs/git.rb', line 55

def user
  @user
end

Instance Method Details

#push_urlObject

Returns the pushUrl configured or nil if not configured.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/build-tool/vcs/git.rb', line 87

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



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

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