class Autoproj::Sync::Config

Public Class Methods

new(ws) click to toggle source
# File lib/autoproj/sync/config.rb, line 4
def initialize(ws)
    @ws = ws
end

Public Instance Methods

add_remote(remote) click to toggle source
# File lib/autoproj/sync/config.rb, line 53
def add_remote(remote)
    name, config = remote_to_config(remote)
    targets = @ws.config.get('sync', Hash.new)
    targets[name] = config
    @ws.config.set('sync', targets)
    @ws.save_config
end
delete_remote(name) click to toggle source
# File lib/autoproj/sync/config.rb, line 61
def delete_remote(name)
    targets = @ws.config.get('sync', Hash.new)
    targets.delete(name)
    @ws.config.set('sync', targets)
    @ws.save_config
end
each_enabled_remote() { |remote| ... } click to toggle source
# File lib/autoproj/sync/config.rb, line 18
def each_enabled_remote
    return enum_for(__method__) unless block_given?

    each_remote do |remote|
        yield(remote) if remote.enabled?
    end
end
each_remote() { |from_uri(parse, name: name, enabled: config)| ... } click to toggle source
# File lib/autoproj/sync/config.rb, line 8
def each_remote
    return enum_for(__method__) unless block_given?

    targets = @ws.config.get('sync', Hash.new)
    targets.each do |name, config|
        yield Remote.from_uri(URI.parse(config['uri']),
            name: name, enabled: config['enabled'])
    end
end
find_remote_by_name(name) click to toggle source
# File lib/autoproj/sync/config.rb, line 34
def find_remote_by_name(name)
    targets = @ws.config.get('sync', Hash.new)
    if config = targets[name]
        remote_from_config(name, config)
    end
end
remote_by_name(name) click to toggle source
# File lib/autoproj/sync/config.rb, line 26
def remote_by_name(name)
    unless remote = find_remote_by_name(name)
        raise ArgumentError, "no remote named '#{name}', "\
            "existing remotes: #{each_remote.map(&:name).sort.join(", ")}"
    end
    remote
end
update_remote_config(name) { |new_config| ... } click to toggle source
# File lib/autoproj/sync/config.rb, line 68
def update_remote_config(name)
    targets = @ws.config.get('sync', Hash.new)
    unless (config = targets[name])
        raise ArgumentError, "There is no target called #{name}"
    end

    new_config = config.dup
    yield(new_config)
    if new_config != config
        targets[name] = new_config
        @ws.config.set('sync', targets)
        @ws.save_config
    end
end

Private Instance Methods

remote_from_config(name, config) click to toggle source
# File lib/autoproj/sync/config.rb, line 41
        def remote_from_config(name, config)
    Remote.from_uri(URI.parse(config['uri']),
        name: name, enabled: config['enabled'])
end
remote_to_config(remote) click to toggle source
# File lib/autoproj/sync/config.rb, line 46
        def remote_to_config(remote)
    [remote.name, Hash[
        'uri' => remote.uri.to_s,
        'enabled' => remote.enabled?
    ]]
end