Module: Volley::Dsl::VolleyFile

Defined in:
lib/volley/dsl/file.rb

Class Method Summary collapse

Class Method Details

.configObject

TOP LEVEL DSL METHODS



26
27
28
# File 'lib/volley/dsl/file.rb', line 26

def config
  Volley.config
end

.directory(dir) ⇒ Object



64
65
66
# File 'lib/volley/dsl/file.rb', line 64

def directory(dir)
  Volley.config.directory = dir
end

.initObject



5
6
7
8
9
10
11
# File 'lib/volley/dsl/file.rb', line 5

def init
  @loaded ||= { }

  ["/etc/Volleyfile", "~/.Volleyfile", "../../../../conf/common.volleyfile"].each do |f|
    load(f, :optional => true)
  end
end

.load(filename, options = { }) ⇒ Object



13
14
15
16
17
18
# File 'lib/volley/dsl/file.rb', line 13

def load(filename, options={ })
  file = load_file(filename)
  raise "cannot read file #{file}" unless file || options[:optional]
  config.volleyfile = file if options[:primary]
  true
end

.log(level, dest) ⇒ Object



39
40
41
# File 'lib/volley/dsl/file.rb', line 39

def log(level, dest)
  Volley::Log.add(level, dest)
end

.project(name, o = { }, &block) ⇒ Object



30
31
32
33
# File 'lib/volley/dsl/file.rb', line 30

def project(name, o={ }, &block)
  Volley::Log.debug "project: #{name}"
  Volley::Dsl::Project.project(name, o, &block)
end

.publisher(name, o = { }, &block) ⇒ Object



35
36
37
# File 'lib/volley/dsl/file.rb', line 35

def publisher(name, o={ }, &block)
  Volley::Dsl::Publisher.publisher(name, o, &block)
end

.unloadObject



20
21
22
# File 'lib/volley/dsl/file.rb', line 20

def unload
  @loaded = nil
end

.user(name) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/volley/dsl/file.rb', line 43

def user(name)
  raise "user '#@user' already specified" if @user

  cuid = Process.euid
  raise "'user #{name}' called in configuration, but process uid is not root (0)" unless cuid == 0

  begin
    pw = Etc.getpwnam(name)
  rescue ArgumentError => e
    raise "could not find user '#{name}', check your Volleyfile configuration"
  end

  nuid = pw[:uid]

  if cuid != nuid
    puts "changing user id to: #{nuid} (from #{cuid})"
    Process::UID.change_privilege(nuid)
    @user = name
  end
end