1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
begin
require 'regexp_property_values/regexp_property_values'
rescue LoadError
warn 'regexp_property_values could not load C extension, using slower Ruby'
end
require 'regexp_property_values/updater'
require 'regexp_property_values/value'
require 'regexp_property_values/version'
module RegexpPropertyValues
Error = Class.new(StandardError)
VALUES_PATH = File.join(__dir__, 'values')
ALIASES_PATH = File.join(__dir__, 'aliases')
def self.[](name)
Value.new(name)
end
def self.all_for_current_ruby
@all_for_current_ruby ||= all.select(&:supported_by_current_ruby?)
end
def self.all
@all ||= File.readlines(VALUES_PATH).map { |line| Value.new(line.chomp) }
end
def self.alias_hash
@alias_hash ||= File.readlines(ALIASES_PATH).map do |line|
line.chomp.split(';').map { |name| Value.new(name) }
end.to_h
end
def self.update
Updater.call
end
end
|