class Bard::Config

Attributes

project_name[R]
servers[R]

Public Class Methods

new(project_name, path: nil, source: nil) click to toggle source
# File lib/bard/config.rb, line 5
def initialize project_name, path: nil, source: nil
  @project_name = project_name
  @servers = {
    local: Server.new(
      project_name,
      :local,
      false,
      "./",
      ["#{project_name}.local"],
    ),
    gubs: Server.new(
      project_name,
      :gubs,
      "botandrose@cloud.hackett.world:22022",
      "Sites/#{project_name}",
      false,
    ),
    ci: Server.new(
      project_name,
      :ci,
      "jenkins@staging.botandrose.com:22022",
      "jobs/#{project_name}/workspace",
      false,
    ),
    staging: Server.new(
      project_name,
      :staging,
      "www@staging.botandrose.com:22022",
      project_name,
      ["#{project_name}.botandrose.com"],
    ),
  }
  if path && File.exist?(path)
    source = File.read(path)
  end
  if source
    instance_eval source
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/bard/config.rb, line 52
def [] key
  key = key.to_sym
  if @servers[key].nil? && key == :production
    key = :staging
  end
  @servers[key]
end
backup(*args) click to toggle source
# File lib/bard/config.rb, line 68
def backup *args
  if args.length == 1
    @backup = args.first
  elsif args.length == 0
    return @backup if defined?(@backup)
    @backup = true
  else
    raise ArgumentError
  end
end
data(*paths) click to toggle source
# File lib/bard/config.rb, line 60
def data *paths
  if paths.length == 0
    Array(@data)
  else
    @data = paths
  end
end
server(key, &block) click to toggle source
# File lib/bard/config.rb, line 47
def server key, &block
  key = key.to_sym
  @servers[key] = Server.define(project_name, key, &block)
end