Sha256: 3deea959580e06eb8f954c8b38f7db2632497484a454548682d176c6377c6cbe

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 KB

Contents

#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 dependency(group, name, version)
      @dependencies << {
        group: group,
        name: name,
        version: version
      }
    end

    def dependencies
      @dependencies
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
transcriptic-0.2.5 lib/transcriptic/labfile.rb
transcriptic-0.2.4 lib/transcriptic/labfile.rb
transcriptic-0.2.3 lib/transcriptic/labfile.rb
transcriptic-0.2.2 lib/transcriptic/labfile.rb
transcriptic-0.2.1 lib/transcriptic/labfile.rb
transcriptic-0.2.0 lib/transcriptic/labfile.rb