Module: Hiera::Util
- Defined in:
- lib/hiera/util.rb,
lib/hiera/util/win32.rb
Defined Under Namespace
Modules: Win32
Class Method Summary collapse
- .code_dir ⇒ Object
- .common_appdata ⇒ Object
- .config_dir ⇒ Object
- .file_alt_separator ⇒ Object
- .microsoft_windows? ⇒ Boolean
- .posix? ⇒ Boolean
- .split_key(key) ⇒ Object
- .var_dir ⇒ Object
Class Method Details
.code_dir ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/hiera/util.rb', line 27 def code_dir if microsoft_windows? File.join(common_appdata, 'PuppetLabs', 'code') else '/etc/puppetlabs/code' end end |
.common_appdata ⇒ Object
43 44 45 |
# File 'lib/hiera/util.rb', line 43 def common_appdata @common_appdata ||= Hiera::Util::Win32.get_common_appdata() end |
.config_dir ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/hiera/util.rb', line 19 def config_dir if microsoft_windows? File.join(common_appdata, 'PuppetLabs', 'puppet', 'etc') else '/etc/puppetlabs/puppet' end end |
.file_alt_separator ⇒ Object
39 40 41 |
# File 'lib/hiera/util.rb', line 39 def file_alt_separator File::ALT_SEPARATOR end |
.microsoft_windows? ⇒ Boolean
15 16 17 |
# File 'lib/hiera/util.rb', line 15 def microsoft_windows? !!file_alt_separator end |
.posix? ⇒ Boolean
10 11 12 13 |
# File 'lib/hiera/util.rb', line 10 def posix? require 'etc' Etc.getpwuid(0) != nil end |
.split_key(key) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/hiera/util.rb', line 47 def split_key(key) segments = key.split(/(?:"([^"]+)"|'([^']+)'|([^'".]+))/) if segments.empty? # Only happens if the original key was an empty string '' elsif segments.shift == '' count = segments.size raise yield('Syntax error') unless count > 0 segments.keep_if { |seg| seg != '.' } raise yield('Syntax error') unless segments.size * 2 == count + 1 segments else raise yield('Syntax error') end end |
.var_dir ⇒ Object
35 36 37 |
# File 'lib/hiera/util.rb', line 35 def var_dir File.join(code_dir, 'environments' , '%{environment}' , 'hieradata') end |