Sha256: a43a9b8324f9727bae66cdcf8c072579011f9f61cb75e51e495c4348ef956969

Contents?: true

Size: 425 Bytes

Versions: 27

Compression:

Stored size: 425 Bytes

Contents

module Vidar
  class Interpolation
    INTERPOLATION_PATTERN = /\{\{(\w+)\}\}/

    class << self
      def call(string, getter)
        return unless string
        fail ArgumentError, "getter must respond_to get." unless getter.respond_to?(:get)

        string.gsub(INTERPOLATION_PATTERN) do |match|
          getter.get($1) || ENV[$1] || match # rubocop:disable Style/PerlBackrefs
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
vidar-1.13.4 lib/vidar/interpolation.rb
vidar-1.13.3 lib/vidar/interpolation.rb
vidar-1.13.2 lib/vidar/interpolation.rb
vidar-1.13.1 lib/vidar/interpolation.rb
vidar-1.13.0 lib/vidar/interpolation.rb
vidar-1.13.0.rc1 lib/vidar/interpolation.rb
vidar-1.12.1 lib/vidar/interpolation.rb
vidar-1.12.0 lib/vidar/interpolation.rb
vidar-1.11.0 lib/vidar/interpolation.rb
vidar-1.10.0 lib/vidar/interpolation.rb
vidar-1.9.4 lib/vidar/interpolation.rb
vidar-1.9.3 lib/vidar/interpolation.rb
vidar-1.9.2 lib/vidar/interpolation.rb
vidar-1.9.1 lib/vidar/interpolation.rb
vidar-1.9.0 lib/vidar/interpolation.rb
vidar-1.8.0 lib/vidar/interpolation.rb
vidar-1.8.0.rc4 lib/vidar/interpolation.rb
vidar-1.7.0 lib/vidar/interpolation.rb
vidar-1.6.0 lib/vidar/interpolation.rb
vidar-1.5.4 lib/vidar/interpolation.rb