lib/gm/notepad/table_registry.rb in gm-notepad-0.0.3 vs lib/gm/notepad/table_registry.rb in gm-notepad-0.0.4

- old
+ new

@@ -36,11 +36,11 @@ def table_names @registry.keys.sort end def fetch_table(name:) - @registry.fetch(name) + @registry.fetch(name.downcase) end def append(table_name:, line:, write:) table = nil begin @@ -60,11 +60,11 @@ def register_by_string(table_name:, string:) register(table_name: table_name, lines: string.split("\n")) end def lookup(table_name:, **kwargs) - table = @registry.fetch(table_name) + table = fetch_table(name: table_name) table.lookup(**kwargs) rescue KeyError "(undefined #{table_name})" end @@ -73,15 +73,16 @@ end private def register(table_name:, lines:, filename: nil) - raise DuplicateKeyError.new(key: table_name, object: self) if @registry.key?(table_name) + table_name = table_name.downcase + raise DuplicateKeyError.new(key: table_name, object: self) if @registry.key?(table_name.downcase) @registry[table_name] = Table.new(table_name: table_name, lines: lines, filename: filename, **config) end def default_line_evaluator - require_relative 'line_evaluator' + require 'gm/notepad/line_evaluator' LineEvaluator.new end end end end