Class: TBM::ConfigParser
- Inherits:
-
Object
- Object
- TBM::ConfigParser
- Defined in:
- lib/TBM/config_parser.rb
Constant Summary collapse
- CONFIG_FILE =
The configuration file used for parsing config.
File.( '~/.tbm' )
- GATEWAY_PATTERN =
/^([^@]+)(@([^@]+))?$/
Class Method Summary collapse
-
.parse ⇒ Config
Parses the tunnel boring machine configuration to get a list of targets which can be invoked to bore tunnels.
Class Method Details
.parse ⇒ Config
Parses the tunnel boring machine configuration to get a list of targets which can be invoked to bore tunnels.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/TBM/config_parser.rb', line 16 def self.parse config = Config.new if File.file? CONFIG_FILE config_data = YAML.load_file( CONFIG_FILE ) case config_data when Hash parse_gateways( config_data, config ) if config_data.is_a? Hash else config.errors << "Cannot parse TBM configuration of type: #{config_data.class}" end else config.errors << "No configuration file found. Specify your tunnels in YAML form in: ~/.tunnels" end return config rescue Psych::SyntaxError => pse config.errors << "TBM config is invalid YAML: #{pse}" return config end |