Class: Gesund::Dsl
- Inherits:
-
Object
- Object
- Gesund::Dsl
- Defined in:
- lib/gesund/dsl.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.evaluate(gesundfile) ⇒ Object
3 4 5 6 |
# File 'lib/gesund/dsl.rb', line 3 def self.evaluate(gesundfile) builder = new builder.eval_gesundfile(gesundfile) end |
Instance Method Details
#check(name, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gesund/dsl.rb', line 20 def check(name, = {}) camel_name = name.to_s.split('_').map(&:capitalize).join begin check_class = Gesund::Checks.const_get(camel_name) rescue NameError => e e.backtrace.join =~ /Gesundfile:(\d+)/ print "ERROR Gesundfile:#{$1}: " puts "#{e.}" exit 1 end raise Gesund::Errors::CheckNotFound unless check_class @checks << check_class.new() if check_class end |
#eval_gesundfile(gesundfile) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/gesund/dsl.rb', line 8 def eval_gesundfile(gesundfile) @checks = [] begin contents = File.read(gesundfile.to_s) rescue => e puts "ERROR reading Gesundfile: #{e.}" exit 1 end instance_eval(contents, gesundfile.to_s, 1) return @checks end |