Class: HolePunch::DSL
Class Method Summary collapse
Instance Method Summary collapse
- #depends(id) ⇒ Object
- #eval_dsl(filename) ⇒ Object
- #group(id, &block) ⇒ Object
-
#initialize(env) ⇒ DSL
constructor
A new instance of DSL.
- #service(id, &block) ⇒ Object
Methods inherited from BaseDSL
Constructor Details
#initialize(env) ⇒ DSL
Returns a new instance of DSL.
94 95 96 |
# File 'lib/holepunch/dsl.rb', line 94 def initialize(env) super(env, Definition.new(env)) end |
Class Method Details
Instance Method Details
#depends(id) ⇒ Object
106 107 108 109 110 111 |
# File 'lib/holepunch/dsl.rb', line 106 def depends(id) id = id.to_s raise GroupError, "duplicate group id #{id}" if @model.groups.include?(id) raise HolePunchSyntaxError, "dependency group #{id} cannot have a block" if block_given? @model.add_group(SecurityGroup.new(id, dependency: true)) end |
#eval_dsl(filename) ⇒ Object
98 99 100 101 102 103 104 |
# File 'lib/holepunch/dsl.rb', line 98 def eval_dsl(filename) super(filename) @model.validate! @model rescue SyntaxError => e raise SecurityGroupsFileError, "SecurityGroups syntax error #{e..gsub("#{filename.to_s}:", 'on line ')}" end |
#group(id, &block) ⇒ Object
113 114 115 116 117 |
# File 'lib/holepunch/dsl.rb', line 113 def group(id, &block) id = id.to_s raise GroupError, "duplicate group id #{id}" if @model.groups.include?(id) @model.add_group(GroupDSL.evaluate(@env, id, &block)) end |
#service(id, &block) ⇒ Object
119 120 121 122 |
# File 'lib/holepunch/dsl.rb', line 119 def service(id, &block) id = id.to_s @model.services[id] = ServiceDSL.evaluate(@env, id, &block) end |