From a62d814aafaff5b6c85da023a8f23d9190ba36ce Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Sat, 3 Jun 2023 21:18:50 -0300 Subject: [PATCH] Added missing file, refactored normalize_name out --- c-historico/handler.cr | 13 +++++++++---- c-historico/shard.yml | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 c-historico/shard.yml diff --git a/c-historico/handler.cr b/c-historico/handler.cr index 5fb1f31..cc571cf 100644 --- a/c-historico/handler.cr +++ b/c-historico/handler.cr @@ -27,6 +27,14 @@ class Handler nombres = [] of String + def normalize_name(s) + # Remove diacritics, turn lowercase + normalized = s.unicode_normalize(:nfkd).chars + normalized.reject! { |c| + !c.ascii_letter? + }.join("").downcase + end + def run(request : HTTP::Request) unless (body = request.body).nil? query = JSON.parse(body) @@ -40,10 +48,7 @@ class Handler # Remove all diacritics and whatnot nombres = nombres.map { |n| - normalized = n.unicode_normalize(:nfkd).chars - normalized.reject! { |c| - !c.ascii_letter? - }.join("").downcase + normalize_name n } puts "Processing #{nombres}" diff --git a/c-historico/shard.yml b/c-historico/shard.yml new file mode 100644 index 0000000..c7bc28d --- /dev/null +++ b/c-historico/shard.yml @@ -0,0 +1,6 @@ +name: historico +version: 0.1.0 + +dependencies: + ishi: + github: toddsundsted/ishi