Sha256: c32ab613ba29832647880684896db8e4d6a7bedb814b369e85b4bc84f6fbda25

Contents?: true

Size: 839 Bytes

Versions: 17

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

# @api private
# @since 0.15.0
module Qonfig::Loaders::EndData
  class << self
    # @param caller_location [String]
    # @return [String]
    #
    # @raise [Qonfig::SelfDataNotFoundError]
    #
    # @api private
    # @since 0.15.0
    def extract(caller_location)
      caller_file = caller_location.split(':').first

      raise(
        Qonfig::SelfDataNotFoundError,
        "Caller file does not exist! (location: #{caller_location})"
      ) unless File.exist?(caller_file)

      data_match = IO.read(caller_file).match(/\n__END__\n(?<end_data>.*)/m)
      raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless data_match

      end_data = data_match[:end_data]
      raise Qonfig::SelfDataNotFoundError, '__END__ data not found!' unless end_data

      end_data
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
qonfig-0.28.0 lib/qonfig/loaders/end_data.rb
qonfig-0.27.0 lib/qonfig/loaders/end_data.rb
qonfig-0.26.0 lib/qonfig/loaders/end_data.rb
qonfig-0.25.0 lib/qonfig/loaders/end_data.rb
qonfig-0.24.1 lib/qonfig/loaders/end_data.rb
qonfig-0.24.0 lib/qonfig/loaders/end_data.rb
qonfig-0.23.0 lib/qonfig/loaders/end_data.rb
qonfig-0.22.0 lib/qonfig/loaders/end_data.rb
qonfig-0.21.0 lib/qonfig/loaders/end_data.rb
qonfig-0.20.0 lib/qonfig/loaders/end_data.rb
qonfig-0.19.1 lib/qonfig/loaders/end_data.rb
qonfig-0.19.0 lib/qonfig/loaders/end_data.rb
qonfig-0.18.1 lib/qonfig/loaders/end_data.rb
qonfig-0.18.0 lib/qonfig/loaders/end_data.rb
qonfig-0.17.0 lib/qonfig/loaders/end_data.rb
qonfig-0.16.0 lib/qonfig/loaders/end_data.rb
qonfig-0.15.0 lib/qonfig/loaders/end_data.rb