class RhetButler::FileLoading

Attributes

file_set[R]
loaded_paths[R]

Public Class Methods

new(file_set) click to toggle source
# File lib/rhet-butler/file-loading.rb, line 5
def initialize(file_set)
  @file_set = file_set
  @loaded_paths = {}
end

Public Instance Methods

initialize_copy(other) click to toggle source
# File lib/rhet-butler/file-loading.rb, line 11
def initialize_copy(other)
  @file_set = other.file_set
  @loaded_paths = other.loaded_paths.dup
end
load_file(rel_path) click to toggle source
# File lib/rhet-butler/file-loading.rb, line 16
def load_file(rel_path)
  file = @file_set.find(rel_path)

  if @loaded_paths.has_key?(file.full_path)
    raise "Circular inclusion of slides: >> #{file.full_path} << #{@loaded_paths.keys.inspect}"
  else
    @loaded_paths[file.full_path] = true
  end

  begin
    return YAML.load_stream(file.contents).flatten
  rescue => ex
    puts "While processing `#{file.full_path}`"
    puts "  #{ex.class}: #{ex.message}"
    raise
  end
end