module Sideload
Constants
- VERSION
Public Instance Methods
init() { |c| ... }
click to toggle source
# File lib/sideload.rb, line 15 def init c = Config.new yield(c) return c end
logger=(logger)
click to toggle source
# File lib/sideload.rb, line 11 def logger=(logger) @logger = logger end
update!(sources)
click to toggle source
# File lib/sideload.rb, line 21 def update!(sources) scope, arg, _config, validate = sources.shift mod = const_get(scope.to_s.capitalize) contents = mod.read(*arg) unless sources.empty? next_layer = update!(sources) unless next_layer.nil? (contents.keys | next_layer.keys).each do |key| if !next_layer.has_key?(key) mod.with(arg, key) do |fp, t| mod.delete(fp, t) end else mod.with(arg, key) do |fp, t| mod.write(fp, t, next_layer[key], &validate) end end end contents = mod.read(arg) end end contents.each(&Proc.new) if block_given? return contents rescue ValidationError => e if @logger @logger.error { [e.class, e.message].inspect } @logger.debug { e.backtrace.join("\n") } end return nil end