#require 'transcriptic/downloader' module Transcriptic class Labfile extend Forwardable class << self def from_file(file) content = File.read(file) object = new(file) object.load(content) rescue Errno::ENOENT => e raise FileNotFound, "No Labfile found at: #{file}" end end def initialize(path) @filepath = path @options = Hash.new @dependencies = [] end def load(content) begin instance_eval(content) rescue => e puts e raise LabfileReadError.new(e) end self end def sha @sha ||= Digest::SHA1.hexdigest File.read(filepath.to_s) end def options @options end def name(name = nil) @options[:name] = name end def author(name) @options[:author] = name end def email(email) @options[:email] = email end def version(arg) @options[:version] = arg end def description(desc) @options[:description] = desc end def group(grp) @options[:group] = grp end def dependency(group, name, version) @dependencies << { group: group, name: name, version: version } end def dependencies @dependencies end end end