Method: ProjectLoader.load_from_string

Defined in:
lib/asker/loader/project_loader.rb

.load_from_string(filepath) ⇒ Object

Load project from filepath. Options:

  • HAML filepath

  • XML filepath

  • YAML filepath

rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize

Parameters:

  • filepath (String)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/asker/loader/project_loader.rb', line 46

def self.load_from_string(filepath)
  project = Project.instance
  unless File.exist?(filepath)
    msg = Rainbow("[ERROR] #{filepath} not found!").red.bright
    Logger.verboseln msg
    exit 1
  end

  if File.extname(filepath) == '.haml' || File.extname(filepath) == '.xml'
    project.set(:inputdirs, File.dirname(filepath))
    project.set(:process_file, File.basename(filepath))
    return project
  elsif File.extname(filepath) == '.yaml'
    return load_from_yaml(filepath)
  end
  error_loading(filepath)
end