Class: Hastie::ServerReader
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Hastie::ServerReader
- Includes:
- Thor::Actions
- Defined in:
- lib/hastie/server_reader.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#get_server_config ⇒ Object
Tries to access the servers.
-
#read_config_file ⇒ Object
Tries to access users config file loads contents into the options hash.
Class Method Details
.source_root ⇒ Object
24 25 26 |
# File 'lib/hastie/server_reader.rb', line 24 def self.source_root File.dirname(__FILE__) end |
Instance Method Details
#get_server_config ⇒ Object
Tries to access the servers
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hastie/server_reader.rb', line 41 def get_server_config say_status "note", "server root: #{[:server_root]}" # First check if the server directory exists if !File.directory? [:server_root] say_status "error", "Cannot find server directory:", :red say [:server_root] say "Please modify \'server_root\' to point to server root directory" exit(1) end # Check for config file inside server_root server_config_file = File.join([:server_root], SERVER_CONFIG_FILE) if !File.exists? server_config_file say_status "error", "Cannot find #{SERVER_CONFIG_FILE} file in server directory:", :red say server_config_file say "" say "Are you sure #{[:server_root]} is a valid server directory?" exit(1) end # Check for reports file inside server_root server_report_file = File.join([:server_root], SERVER_REPORTS_FILE) if !File.exists? server_report_file say_status "error", "Cannot find #{SERVER_REPORTS_FILE} file in server directory:", :red say server_report_file say "" say "Are you sure #{[:server_root]} is a valid server directory?" exit(1) end # merge the server config and report file # put them in their own 'namespace' to avoid # collisions with existing configs server_config = ConfigFile.load(server_config_file, :server) self. = server_config.merge(self.) server_reports = ConfigFile.load(server_report_file, :published_reports) self. = server_reports.merge(self.) end |
#read_config_file ⇒ Object
Tries to access users config file loads contents into the options hash
30 31 32 33 34 35 36 37 38 |
# File 'lib/hastie/server_reader.rb', line 30 def read_config_file say_status "note", "config file: #{self.config_file}" if !File.exists? self.config_file say "No config file found. Please create #{self.config_file}" exit(1) end config = ConfigFile.load(self.config_file) self. = config.merge(self.) end |