Class: BuildTool::Repository

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

Overview

Encapsulates a source code repository.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from MJ::Mixins::InheritedAttributes

included

Constructor Details

#initialize(name) ⇒ Repository

Create a repository object



48
49
50
51
52
53
54
55
56
57
58
# File 'lib/build-tool/repository.rb', line 48

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

Instance Attribute Details

#name ⇒ Object (readonly)

Repository name



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

def name
  @name
end

#path ⇒ String

The path on the server.



26
# File 'lib/build-tool/repository.rb', line 26

inherited_attr_accessor :path

#server ⇒ Object



22
# File 'lib/build-tool/repository.rb', line 22

inherited_attr_accessor :server

#sshkey ⇒ Object

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



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

def sshkey
    # 1. Our SSH-Key
    return @sshkey if @sshkey
    # 2. Our Servers SSH-Key
    return server.sshkey if @server
    # 3. Our Parents SSH-Key
    return parent.sshkey if @parent
    # 4. Nothing
    return nil
end

#user ⇒ String

The user required to connect to the repository.



30
# File 'lib/build-tool/repository.rb', line 30

inherited_attr_accessor :user

Instance Method Details

#url ⇒ String

Returns the url for this repository.

Raises:



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/build-tool/repository.rb', line 63

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

    url = server.url( user )
    if path
        url = "#{url}/#{path}"
    end
    url
end