Class: Generamba::RambafileValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/generamba/helpers/rambafile_validator.rb

Overview

Provides methods for validating Rambafile contents

Instance Method Summary collapse

Instance Method Details

#validate(path) ⇒ Void

Method validates Rambafile contents

Parameters:

  • path (String)

    The path to a Rambafile

Returns:

  • (Void)


8
9
10
11
12
13
14
15
16
# File 'lib/generamba/helpers/rambafile_validator.rb', line 8

def validate(path)
  file_contents = open(path).read
  preferences = file_contents.empty? ? {} : YAML.load(file_contents).to_hash

  unless preferences[TEMPLATES_KEY]
    puts "You can't run *generamba gen* without any templates installed. Add their declarations to a Rambafile and run *generamba template install*.".red
    exit
  end
end