class Batali::Source
Source
of asset
Source
of asset
Source
of asset
Attributes
cache_path[RW]
@return [String] path to local cache
Public Class Methods
build(args)
click to toggle source
Build a source
@param args [Hash] @return [Source] @note uses `:type` to build concrete source
# File lib/batali/source.rb, line 77 def self.build(args) type = args.delete(:type) unless type raise ArgumentError.new "Missing required option `:type`!" end unless type.to_s.include?("::") type = [name, Bogo::Utility.camel(type)].join("::") end klass = Bogo::Utility.constantize(type) unless klass raise TypeError.new "Unknown source type provided `#{type}`!" else klass.new(args.merge(:type => type)) end end
new(args = {})
click to toggle source
Calls superclass method
# File lib/batali/source.rb, line 16 def initialize(args = {}) @cache_path = Utility.clean_path(args.delete(:cache_path)) super end
Public Instance Methods
==(s)
click to toggle source
@return [TrueClass, FalseClass]
# File lib/batali/source.rb, line 47 def ==(s) s.is_a?(Source) && attributes.map do |key, attr| key if attr[:equivalent] end.compact.all? do |key| attributes[key] == s.attributes[key] end end
asset()
click to toggle source
@return [String] directory containing contents
# File lib/batali/source.rb, line 32 def asset raise NotImplementedError.new "Abstract class" end
clean_asset(asset_path)
click to toggle source
@return [TrueClass, FalseClass]
# File lib/batali/source.rb, line 37 def clean_asset(asset_path) if cache_path && asset_path.include?(cache_path) && File.exist?(asset_path) FileUtils.rm_rf(asset_path) true else false end end
diff(s)
click to toggle source
Detect differences in equivalency
@param s [Source] @return [Smash]
# File lib/batali/source.rb, line 59 def diff(s) Smash.new.tap do |_diff| self.class.attributes.each do |k, v| if v[:equivalent] s_attrs = s.respond_to?(:attributes) ? s.attributes : {} unless attributes[k] == s_attrs[k] _diff[k] = [attributes[k], s_attrs[k]] end end end end end
unit_dependencies()
click to toggle source
@return [Array<Array<name, constraints>>]
# File lib/batali/source.rb, line 27 def unit_dependencies raise NotImplementedError.new "Abstract class" end
unit_version()
click to toggle source
@return [String]
# File lib/batali/source.rb, line 22 def unit_version raise NotImplementedError.new "Abstract class" end