Sha256: 5087baf6411f9cee0654afa66bf1d7a63fd31e5da7053b52b73b3205091610bb

Contents?: true

Size: 806 Bytes

Versions: 5

Compression:

Stored size: 806 Bytes

Contents

require 'rhet-butler/yaml-schema'

module RhetButler
  class FileLoading
    def initialize(file_set)
      @file_set = file_set
      @loaded_paths = {}
    end
    attr_reader :loaded_paths, :file_set

    def initialize_copy(other)
      @file_set = other.file_set
      @loaded_paths = other.loaded_paths.dup
    end

    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
        raise
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rhet-butler-0.13.0 lib/rhet-butler/file-loading.rb
rhet-butler-0.12.1 lib/rhet-butler/file-loading.rb
rhet-butler-0.11.1 lib/rhet-butler/file-loading.rb
rhet-butler-0.11.0 lib/rhet-butler/file-loading.rb
rhet-butler-0.10.0 lib/rhet-butler/file-loading.rb