module Vp module Pears class VpTheme < ::Pears::Provider::LocalFile class InvalidVpTheme < StandardError; end; THEMES = Dir[ "#{__FILE__}".split('/') .slice(0..-4) .join('/') .+('/themes/*') ] MAP = Hash[ THEMES.map do |fil| fil.split('/') .last .delete_suffix('.yml') end.zip(THEMES) ].with_indifferent_access.freeze def initialize(name, on_failure: :raise) file = MAP[name.downcase] raise InvalidVpTheme.new(name) unless file.present? super(file, on_failure: on_failure) end end ::Pears::Provider::Builder.enable_provider VpTheme end end