Module: Voodoo

Extended by:
Voodoo
Included in:
Voodoo
Defined in:
lib/voodoo.rb,
lib/voodoo/version.rb,
lib/voodoo/commands.rb,
lib/voodoo/migration.rb,
lib/voodoo/peopletools.rb,
lib/voodoo/commands/add.rb,
lib/voodoo/commands/run.rb,
lib/voodoo/commands/list.rb,
lib/voodoo/commands/show.rb,
lib/voodoo/commands/build.rb,
lib/voodoo/commands/config.rb,
lib/voodoo/commands/remove.rb,
lib/voodoo/peopletools/sqr.rb,
lib/voodoo/commands/archive.rb,
lib/voodoo/commands/compare.rb,
lib/voodoo/commands/migrate.rb,
lib/voodoo/commands/template.rb,
lib/voodoo/peopletools/appengine.rb,
lib/voodoo/peopletools/datamover.rb,
lib/voodoo/peopletools/appdesigner.rb

Defined Under Namespace

Modules: Commands Classes: AppDesigner, AppEngine, DataMover, Migration, PeopleTools, Sqr

Constant Summary collapse

LIBPATH =
::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR
LOG =
Logger.new(STDOUT)
VERSION =
'0.0.8'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.libpath(*args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/voodoo.rb', line 23

def self.libpath( *args )
  rv =  args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
  if block_given?
    begin
      $LOAD_PATH.unshift LIBPATH
      rv = yield
    ensure
      $LOAD_PATH.shift
    end
  end
  return rv
end

.path(*args) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/voodoo.rb', line 36

def self.path( *args )
  rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
  if block_given?
    begin
      $LOAD_PATH.unshift PATH
      rv = yield
    ensure
      $LOAD_PATH.shift
    end
  end
  return rv
end

.require_all_libs_relative_to(fname, dir = nil) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/voodoo.rb', line 49

def self.require_all_libs_relative_to( fname, dir = nil )
  dir ||= ::File.basename(fname, '.*')
  search_me = ::File.expand_path(
      ::File.join(::File.dirname(fname), dir, '**', '*.rb'))

  Dir.glob(search_me).sort.each {|rb| require rb}
end

.show_debuggingObject



19
20
21
# File 'lib/voodoo.rb', line 19

def self.show_debugging
  LOG.level = Logger::DEBUG
end

Instance Method Details

#config_fileObject



65
66
67
68
# File 'lib/voodoo.rb', line 65

def config_file
  filename = File.join(Voodoo.home, 'configuration.yml')
  File.open(filename, File::CREAT|File::RDWR)
end

#configurationObject



70
71
72
# File 'lib/voodoo.rb', line 70

def configuration
  @configuration = YAML.load_file(Voodoo.config_file)
end

#env_fileObject



78
79
80
81
82
# File 'lib/voodoo.rb', line 78

def env_file
  filename = File.join(Voodoo.home, 'environments.yml')
  File.open(filename, File::CREAT|File::RDWR)
  return filename
end

#environmentsObject



84
85
86
87
88
89
90
91
# File 'lib/voodoo.rb', line 84

def environments
  list = YAML.load_file(Voodoo.env_file)
  if list
    @environments = list
  else
    @environments = {}
  end
end

#homeObject



57
58
59
60
61
62
63
# File 'lib/voodoo.rb', line 57

def home
  @home ||= (ENV['HOME'] || ENV['USERPROFILE']) + '/.voodoo'
  unless File.exists?(@home)
    Dir.mkdir(@home)
  end
  return @home
end

#write_config_file(settings) ⇒ Object



74
75
76
# File 'lib/voodoo.rb', line 74

def write_config_file(settings)
  Voodoo.config_file.write(settings.to_yaml)
end

#write_env_fileObject



93
94
95
96
97
# File 'lib/voodoo.rb', line 93

def write_env_file
  environment_file = File.open(Voodoo.env_file, 'w')
  LOG.debug("Writing environment configuration file.")
  environment_file.write(ENVIRONMENTS.to_yaml)
end