Sha256: 65e5331681f7a84a9b362d1b9970e3868e408e5745820f8de49911bfb5db5cbf

Contents?: true

Size: 1.3 KB

Versions: 14

Compression:

Stored size: 1.3 KB

Contents

module Climatic
  module ConfigLayers

    class GemLayer < Climatic::ConfigLayers::GenericLayer

      attr_reader :gem_name

      def self.gem_config_root(gem_name)
        return nil unless gem_name
        Gem.loaded_specs.each_pair do |name, spec|
          return spec.full_gem_path if name == gem_name
        end
        nil
      end

      def gem_config_root
        self.class.gem_config_root gem_name
      end


      def gem_name=(gem_name)
        @gem_name = gem_name.to_s
        rescan
        reload
      end

      def possible_sources
        [
            %w(##GEM_CONFIG_ROOT## etc ##GEM_NAME##.##EXTENSION##),
            %w(##GEM_CONFIG_ROOT## etc ##GEM_NAME## config.##EXTENSION##),
            %w(##GEM_CONFIG_ROOT## etc ##GEM_NAME## ##GEM_NAME##.##EXTENSION##),
            %w(##GEM_CONFIG_ROOT## config ##GEM_NAME##.##EXTENSION##),
            %w(##GEM_CONFIG_ROOT## config ##GEM_NAME## config.##EXTENSION##),
            %w(##GEM_CONFIG_ROOT## config ##GEM_NAME## ##GEM_NAME##.##EXTENSION##)
        ]
      end

      def perform_substitutions path_part
        return nil unless gem_config_root
        res = path_part.dup
        res.gsub! '##GEM_CONFIG_ROOT##', gem_config_root
        res.gsub! '##GEM_NAME##', gem_name if self.respond_to? :gem_name
        res
      end


    end

  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
climatic-0.2.40 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.39 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.38 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.37 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.36 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.35 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.34 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.32 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.31 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.30 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.29 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.28 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.27 lib/climatic/config_layers/gem_layer.rb
climatic-0.2.26 lib/climatic/config_layers/gem_layer.rb