Sha256: 87380108ad4e045a58ec571d7bdb99b981197ce31e40cad3033189f30a6f4b59

Contents?: true

Size: 872 Bytes

Versions: 33

Compression:

Stored size: 872 Bytes

Contents

module Vp
  module Pears
    class VpTheme < ::Pears::Provider::LocalFile
      class InvalidVpTheme < StandardError; end;

      # Get all
      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)
      rescue InvalidVpTheme => e
        if on_failure == :null
          @data = {}
        else
          raise e
        end
      end
    end

    ::Pears::Provider::Builder.enable_provider VpTheme
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
vp-themes-0.2.21 lib/vp/pears/vp_theme.rb
vp-themes-0.2.19 lib/vp/pears/vp_theme.rb
vp-themes-0.2.18 lib/vp/pears/vp_theme.rb
vp-themes-0.2.17 lib/vp/pears/vp_theme.rb
vp-themes-0.2.16 lib/vp/pears/vp_theme.rb
vp-themes-0.2.15 lib/vp/pears/vp_theme.rb
vp-themes-0.2.12 lib/vp/pears/vp_theme.rb
vp-themes-0.2.11 lib/vp/pears/vp_theme.rb
vp-themes-0.2.10 lib/vp/pears/vp_theme.rb
vp-themes-0.2.9 lib/vp/pears/vp_theme.rb
vp-themes-0.2.8 lib/vp/pears/vp_theme.rb
vp-themes-0.2.7 lib/vp/pears/vp_theme.rb
vp-themes-0.2.6 lib/vp/pears/vp_theme.rb
vp-themes-0.2.5 lib/vp/pears/vp_theme.rb
vp-themes-0.2.3 lib/vp/pears/vp_theme.rb
vp-themes-0.2.2 lib/vp/pears/vp_theme.rb
vp-themes-0.1.23 lib/vp/pears/vp_theme.rb
vp-themes-0.2.1 lib/vp/pears/vp_theme.rb
vp-themes-0.1.22 lib/vp/pears/vp_theme.rb
vp-themes-0.2.0 lib/vp/pears/vp_theme.rb