Sha256: e95e5d1bb6c2e95654628e44e113b163ba01d57075ace79d487b3edad807e4b7
Contents?: true
Size: 1.18 KB
Versions: 16
Compression:
Stored size: 1.18 KB
Contents
require 'tempfile' module Dandelion module Backend class MissingFileError < StandardError; end class UnsupportedSchemeError < StandardError; end class MissingDependencyError < StandardError attr_reader :gems def initialize(gems) @gems = gems end end class Base class << self @@backends = {} def create(config) Dir.glob(File.join(File.dirname(__FILE__), 'backend', '*.rb')) { |file| require file } raise UnsupportedSchemeError unless @@backends.include?(config['scheme']) begin @@backends[config['scheme']].new(config) rescue LoadError raise MissingDependencyError.new(@@backends[config['scheme']].gem_list) end end def scheme(scheme) @@backends[scheme] = self end def gems(*gems) @gems = gems end def gem_list @gems end end protected def temp(file, data) tmp = Tempfile.new(file.gsub('/', '.')) tmp << data tmp.flush yield(tmp.path) tmp.close end end end end
Version data entries
16 entries across 16 versions & 1 rubygems