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



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

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

#data_path(*args) ⇒ Object



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

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



38
39
40
# File 'lib/tyrant_manager/paths.rb', line 38

def home_dir
  @home_dir ||= install_dir
end

#home_dir=(other) ⇒ Object



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

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

#home_path(sub, *args) ⇒ Object



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

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.



7
8
9
10
11
12
13
# File 'lib/tyrant_manager/paths.rb', line 7

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



15
16
17
# File 'lib/tyrant_manager/paths.rb', line 15

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

#instances_path(*args) ⇒ Object



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

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

#lib_path(*args) ⇒ Object



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

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

#log_path(*args) ⇒ Object



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

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

#spec_path(*args) ⇒ Object



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

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

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



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

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



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

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