Module: Qonfig::Loaders::EndData Private

Defined in:
lib/qonfig/loaders/end_data.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.15.0

Class Method Summary collapse

Class Method Details

.extract(caller_location) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • caller_location (String)

Returns:

  • (String)

Raises:

Since:

  • 0.15.0



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/qonfig/loaders/end_data.rb', line 14

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