Class: ConfCtl::ConfDir

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/confctl/conf_dir.rb

Instance Method Summary collapse

Constructor Details

#initializeConfDir

Returns a new instance of ConfDir.



28
29
30
# File 'lib/confctl/conf_dir.rb', line 28

def initialize
  @cache = ConfCache.new(self)
end

Instance Method Details

#cache_dirString

Path to configuration-specific cache directory

Returns:

  • (String)


52
53
54
# File 'lib/confctl/conf_dir.rb', line 52

def cache_dir
  @cache_dir ||= File.join(path, '.confctl')
end

#changed?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/confctl/conf_dir.rb', line 72

def changed?
  !unchanged?
end

#generation_dirString

Path to directory with build generations

Returns:

  • (String)


58
59
60
# File 'lib/confctl/conf_dir.rb', line 58

def generation_dir
  @generation_dir ||= File.join(cache_dir, 'generations')
end

#hashString

Unique hash identifying the configuration based on its filesystem path

Returns:

  • (String)


40
41
42
# File 'lib/confctl/conf_dir.rb', line 40

def hash
  @hash ||= Digest::SHA256.hexdigest(path)
end

#log_dirString

Path to configuration-specific log directory

Returns:

  • (String)


64
65
66
# File 'lib/confctl/conf_dir.rb', line 64

def log_dir
  @log_dir ||= File.join(cache_dir, 'logs')
end

#pathString

Path to the directory containing cluster configuration

Returns:

  • (String)


34
35
36
# File 'lib/confctl/conf_dir.rb', line 34

def path
  @path ||= File.realpath(Dir.pwd)
end

#short_hashString

Shorter prefix of #hash

Returns:

  • (String)


46
47
48
# File 'lib/confctl/conf_dir.rb', line 46

def short_hash
  @short_hash ||= hash[0..7]
end

#state_mtimeObject



80
81
82
# File 'lib/confctl/conf_dir.rb', line 80

def state_mtime
  @cache.mtime
end

#unchanged?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/confctl/conf_dir.rb', line 76

def unchanged?
  @cache.uptodate?
end

#update_stateObject



84
85
86
# File 'lib/confctl/conf_dir.rb', line 84

def update_state
  @cache.update
end

#user_script_dirObject



68
69
70
# File 'lib/confctl/conf_dir.rb', line 68

def user_script_dir
  @user_script_dir ||= File.join(path, 'scripts')
end