Module: Ec2ssh::Dsl::Parser

Defined in:
lib/ec2ssh/dsl.rb

Class Method Summary collapse

Class Method Details

.parse(dsl_str) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/ec2ssh/dsl.rb', line 46

def self.parse(dsl_str)
  dsl = Dsl.new
  dsl.instance_eval dsl_str
  dsl._result.tap {|result| validate result }
rescue SyntaxError => e
  raise DotfileSyntaxError, e.to_s
end

.parse_file(path) ⇒ Object

Raises:



54
55
56
57
# File 'lib/ec2ssh/dsl.rb', line 54

def self.parse_file(path)
  raise DotfileNotFound, path.to_s unless File.exist?(path)
  parse File.read(path)
end

.validate(result) ⇒ Object



59
60
61
62
63
# File 'lib/ec2ssh/dsl.rb', line 59

def self.validate(result)
  if result.aws_keys && result.profiles
    raise DotfileValidationError, "`aws_keys` and `profiles` doesn't work together in dotfile."
  end
end