Permalink
Browse files

reverting last commit, better ssh config file reading

  • Loading branch information...
1 parent f7a74bb commit 895be6e4dab1a0221d6c7f232aff9bc08abb88c9 @goldmann goldmann committed Nov 24, 2009
Showing with 10 additions and 6 deletions.
  1. +3 −3 lib/cantiere/config.rb
  2. +7 −3 lib/cantiere/ssh/ssh-config.rb
View
@@ -75,10 +75,10 @@ def initialize( project_config = Hash.new )
end
if File.exists?( CONFIG_FILE )
- @definition = YAML.load_file( CONFIG_FILE )
- raise "Your config file (#{CONFIG_FILE}) has incorrect format. Please correct it." if @definition.nil?
+ @data = YAML.load_file( CONFIG_FILE )
+ raise "Your config file (#{CONFIG_FILE}) has incorrect format. Please correct it." if @data.nil?
else
- @definition = {}
+ @data = {}
end
@build_arch = ENV['CANTIERE_ARCH'].nil? ? @arch : ENV['CANTIERE_ARCH']
@@ -32,15 +32,19 @@ def initialize( config )
@options['sftp_overwrite'] = false
@options['sftp_default_permissions'] = 0644
+ raise ValidationError, "Specified configuration file (#{CONFIG_FILE}) doesn't exists. #{DEFAULT_HELP_TEXT[:general]}" unless File.exists?( CONFIG_FILE )
+
+ @config_file = YAML.load_file( CONFIG_FILE )
+
validate
end
def validate
- raise ValidationError, "Specified configuration file (#{CONFIG_FILE}) doesn't exists. #{DEFAULT_HELP_TEXT[:general]}" unless File.exists?( CONFIG_FILE )
- raise ValidationError, "No 'ssh' section in config file in configuration file '#{CONFIG_FILE}'. #{DEFAULT_HELP_TEXT[:general]}" if @config.definition['ssh'].nil?
+ raise ValidationError, "Your config file (#{CONFIG_FILE}) has incorrect format. Please correct it." if @config_file.nil?
+ raise ValidationError, "No 'ssh' section in config file in configuration file '#{CONFIG_FILE}'. #{DEFAULT_HELP_TEXT[:general]}" if @config_file['ssh'].nil?
# we need only ssh section
- @cfg = @config.definition['ssh']
+ @cfg = @config_file['ssh']
raise ValidationError, "Host not specified in configuration file '#{CONFIG_FILE}' in ssh section. #{DEFAULT_HELP_TEXT[:general]}" if @cfg['host'].nil?
raise ValidationError, "Username not specified in configuration file '#{CONFIG_FILE}' in ssh section. #{DEFAULT_HELP_TEXT[:general]}" if @cfg['username'].nil?

0 comments on commit 895be6e

Please sign in to comment.