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

Parameters:

  • filepath (String)


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/asker/loader/project_loader.rb', line 34

def self.load_from_string(filepath)
  project = ProjectData.instance
  unless File.exist?(filepath)
    Logger.error "ProjectLoader: #{filepath} not found!"
    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