Module: Inception::CliHelpers::Settings
Constant Summary collapse
- CONFIG_DIRECTORY =
".inception_server"
Instance Method Summary collapse
- #local_settings ⇒ Object
- #migrate_old_settings ⇒ Object
- #reload_settings! ⇒ Object
-
#save_settings! ⇒ Object
Saves current nested ReadWriteSettings into pure Hash-based YAML file Recreates accessors on ReadWriteSettings object (since something has changed).
- #settings ⇒ Object
-
#settings_dir ⇒ Object
The base directory for holding the manifest settings file and private keys.
- #settings_path ⇒ Object
- #settings_ssh_dir ⇒ Object
Instance Method Details
#local_settings ⇒ Object
54 55 56 57 |
# File 'lib/inception/cli_helpers/settings.rb', line 54 def local_settings path = File.join(Dir.pwd, CONFIG_DIRECTORY) Dir.exists?(path) ? path : nil end |
#migrate_old_settings ⇒ Object
50 51 52 |
# File 'lib/inception/cli_helpers/settings.rb', line 50 def migrate_old_settings settings end |
#reload_settings! ⇒ Object
45 46 47 48 |
# File 'lib/inception/cli_helpers/settings.rb', line 45 def reload_settings! @settings = nil settings end |
#save_settings! ⇒ Object
Saves current nested ReadWriteSettings into pure Hash-based YAML file Recreates accessors on ReadWriteSettings object (since something has changed)
40 41 42 43 |
# File 'lib/inception/cli_helpers/settings.rb', line 40 def save_settings! File.open(settings_path, "w") { |f| f << settings.to_nested_hash.to_yaml } settings.create_accessors! end |
#settings ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/inception/cli_helpers/settings.rb', line 26 def settings @settings ||= begin unless File.exists?(settings_path) mkdir_p(settings_ssh_dir) File.open(settings_path, "w") { |file| file << "--- {}" } end chmod(0600, settings_path) chmod(0700, settings_ssh_dir) if File.directory?(settings_ssh_dir) ReadWriteSettings.new(settings_path) end end |
#settings_dir ⇒ Object
The base directory for holding the manifest settings file and private keys
Defaults to ~/.inception_server; and can be overridden with either:
-
$SETTINGS - to a folder (supported method)
14 15 16 |
# File 'lib/inception/cli_helpers/settings.rb', line 14 def settings_dir @settings_dir ||= local_settings || File.(ENV["SETTINGS"] || "~/#{CONFIG_DIRECTORY}") end |
#settings_path ⇒ Object
22 23 24 |
# File 'lib/inception/cli_helpers/settings.rb', line 22 def settings_path @settings_path ||= File.join(settings_dir, "settings.yml") end |
#settings_ssh_dir ⇒ Object
18 19 20 |
# File 'lib/inception/cli_helpers/settings.rb', line 18 def settings_ssh_dir File.join(settings_dir, "ssh") end |