module AdminModule
- File
-
client.rb
- Purpose
-
AdminModule
client object - Author
-
Jeff McAffee 07/11/2014
- File
-
command.rb
- Purpose
-
CLI
command classes - Author
-
Jeff McAffee 04/05/2015
- File
-
client_access.rb
- Purpose
-
Module providing client access helper methods for
CLI
classes. - Author
-
Jeff McAffee 07/17/2014
- File
-
config.rb
- Purpose
-
Config command
- Author
-
Jeff McAffee 06/29/2014
- File
-
dc.rb
- Purpose
-
DC
command line interface - Author
-
Jeff McAffee 04/01/2015
- File
-
gdl.rb
- Purpose
-
filedescription
- Author
-
Jeff McAffee 2014-06-28
- File
-
lock.rb
- Purpose
-
Lock command line interface
- Author
-
Jeff McAffee 2014-06-28
- File
-
ppm.rb
- Purpose
-
PPM command line interface
- Author
-
Jeff McAffee 2015-06-23
- File
-
rule.rb
- Purpose
-
Rule command line interface
- Author
-
Jeff McAffee 2014-06-28
- File
-
ruleset.rb
- Purpose
-
filedescription
- Author
-
Jeff McAffee 2014-06-28
- File
-
snapshot.rb
- Purpose
-
Snapshot command line interface
- Author
-
Jeff McAffee 2015-04-05
- File
-
stage.rb
- Purpose
-
Stage command line interface
- Author
-
Jeff McAffee 11/15/2013
- File
-
task.rb
- Purpose
-
Task command line interface
- Author
-
Jeff McAffee 2014-06-28
- File
-
config_helper.rb
- Purpose
-
Configuration
object wrapper - Author
-
Jeff McAffee 07/01/2014
- Copyright
-
Copyright © 2014, kTech Systems LLC. All rights reserved.
- Website
Constants
- CONFIG_FILE_NAME
- VERSION
Attributes
Public Class Methods
Setup admin_module configuration
Attempts to find and load a configuration file the first time it’s requested. If a config file cannot be found on in the current directory tree (moving towards trunk, not the leaves), a default configuration object is created.
If a block is provided, the configuration object is yielded to the block after the configuration is loaded/created.
# File lib/admin_module.rb, line 47 def self.configure if self.configuration.nil? unless self.load_configuration self.configuration = Configuration.new end end yield(configuration) if block_given? end
Walk up the directory tree from current working dir (pwd) till a file named .admin_module is found
Returns file path if found, nil if not.
# File lib/admin_module.rb, line 63 def self.find_config_path path = Pathname(Pathname.pwd).ascend{|d| h=d+CONFIG_FILE_NAME; break h if h.file?} end
Load the configuration from disk
Returns true if config file found and loaded, false otherwise.
# File lib/admin_module.rb, line 102 def self.load_configuration(path = nil) # If no path provided, see if we can find one in the dir tree. if path.nil? path = find_config_path end return false if path.nil? return false unless Pathname(path).exist? File.open(path, 'r') do |f| self.configuration = YAML.load(f) puts "configuration loaded from #{path}" if $debug end true end
Write configuration to disk
Writes to current working dir (pwd) if path is nil
Returns path of emitted file
# File lib/admin_module.rb, line 75 def self.save_configuration(path = nil) # If no path provided, see if we can find one in the dir tree. if path.nil? path = find_config_path end # Still no path? Use the current working dir. if path.nil? path = Pathname.pwd end unless path.to_s.end_with?('/' + CONFIG_FILE_NAME) path = Pathname(path) + CONFIG_FILE_NAME end path = Pathname(path).expand_path File.write(path, YAML.dump(configuration)) path end