Module: TyrantManager::Paths

Extended by:
Paths
Included in:
TyrantManager, TyrantManager, Paths
Defined in:
lib/tyrant_manager/paths.rb

Instance Method Summary collapse

Instance Method Details

#bin_path(*args) ⇒ Object



24
25
26
# File 'lib/tyrant_manager/paths.rb', line 24

def bin_path( *args )
  install_path( 'bin', *args )
end

#data_path(*args) ⇒ Object



32
33
34
# File 'lib/tyrant_manager/paths.rb', line 32

def data_path( *args )
  install_path( "data", *args )
end

#home_dirObject

The home dir is the home directory of the project while it is running by default, this the same as the install_dir. But if this value is set then it affects other paths



43
44
45
# File 'lib/tyrant_manager/paths.rb', line 43

def home_dir
  @home_dir ||= install_dir
end

#home_dir=(other) ⇒ Object



47
48
49
# File 'lib/tyrant_manager/paths.rb', line 47

def home_dir=( other )
  @home_dir = File.expand_path( other )
end

#home_path(sub, *args) ⇒ Object



51
52
53
# File 'lib/tyrant_manager/paths.rb', line 51

def home_path( sub, *args )
  sub_path( home_dir, sub, *args )
end

#install_dirObject

The installation directory of the project is considered to be the parent directory of the ‘lib’ directory.



12
13
14
15
16
17
18
# File 'lib/tyrant_manager/paths.rb', line 12

def install_dir
  @install_dir ||= (
    path_parts = ::File.expand_path(__FILE__).split(::File::SEPARATOR)
    lib_index  = path_parts.rindex("lib")
    path_parts[0...lib_index].join(::File::SEPARATOR) + ::File::SEPARATOR
  )
end

#install_path(sub, *args) ⇒ Object



20
21
22
# File 'lib/tyrant_manager/paths.rb', line 20

def install_path( sub, *args )
  sub_path( install_dir, sub, *args )
end

#instances_path(*args) ⇒ Object



55
56
57
# File 'lib/tyrant_manager/paths.rb', line 55

def instances_path( *args )
  home_path( "instances", *args )
end

#lib_path(*args) ⇒ Object



28
29
30
# File 'lib/tyrant_manager/paths.rb', line 28

def lib_path( *args )
  install_path( "lib", *args )
end

#log_path(*args) ⇒ Object



59
60
61
# File 'lib/tyrant_manager/paths.rb', line 59

def log_path( *args )
  home_path( "log", *args )
end

#spec_path(*args) ⇒ Object



36
37
38
# File 'lib/tyrant_manager/paths.rb', line 36

def spec_path( *args )
  install_path( "spec", *args )
end

#sub_path(parent, sub, *args) ⇒ Object



67
68
69
70
# File 'lib/tyrant_manager/paths.rb', line 67

def sub_path( parent, sub, *args )
  sp = ::File.join( parent, sub ) + File::SEPARATOR
  sp = ::File.join( sp, *args ) if args
end

#tmp_path(*args) ⇒ Object



63
64
65
# File 'lib/tyrant_manager/paths.rb', line 63

def tmp_path( *args )
  home_path( "tmp", *args )
end