class Dry::System::MagicCommentsParser

Constants

COERCIONS
COMMENT_RE
VALID_LINE_RE

Public Class Methods

call(file_name) click to toggle source
# File lib/dry/system/magic_comments_parser.rb, line 14
def self.call(file_name)
  {}.tap do |options|
    File.foreach(file_name) do |line|
      break unless line =~ VALID_LINE_RE

      if (comment = line.match(COMMENT_RE))
        options[comment[:name].to_sym] = coerce(comment[:value])
      end
    end
  end
end
coerce(value) click to toggle source
# File lib/dry/system/magic_comments_parser.rb, line 26
def self.coerce(value)
  COERCIONS.fetch(value) { value }
end