Class: BuildTool::Repository

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

Overview

Encapsulates a source code repository.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Repository

Create a repository



24
25
26
27
28
29
30
31
# File 'lib/build-tool/repository.rb', line 24

def initialize(name)
    if name.nil?
        raise StandardError, "The repository name has to be set"
    end
    @name = name
    @server = nil
    @sshkey = nil
end

Instance Attribute Details

#nameObject (readonly)

Repository name



9
10
11
# File 'lib/build-tool/repository.rb', line 9

def name
  @name
end

#pathObject

The relative path on the server



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

def path
  @path
end

#serverObject

The server this repository is hosted



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

def server
  @server
end

#sshkeyObject

Return the ssh key needed to access this repository. If the repository has no key we check the associated server.



35
36
37
38
39
40
41
42
43
# File 'lib/build-tool/repository.rb', line 35

def sshkey
    return @sshkey if @sshkey

    if !server
        return nil
    end

    return server.sshkey
end

#userObject

The relative path on the server



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

def user
  @user
end

Instance Method Details

#urlObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/build-tool/repository.rb', line 45

def url
    if !server
        raise ConfigurationError, "No server specified for repository #{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