Skip to content

Commit

Permalink
Slugify Apidea source ids
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed Nov 12, 2024
1 parent 63f21e4 commit a733e9e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion datasources/connectors/apidae.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@


class Apidae < Connector
def slugify(s)
s = s.gsub(/\s+/, ' ')
s.strip!
s.gsub!(' ', '-')
s.gsub!('&', 'and')
s = I18n.transliterate(s)
s.gsub!(/[^\w-]/u, '')
s.gsub!(/-+/, '-')
s.mb_chars.downcase.to_s
end

def setup(kiba)
kiba.source(MetadataSource, @job_id, @job_id, nil, MetadataSource::Settings.from_hash({
'schema' => [
Expand All @@ -33,7 +44,7 @@ def setup(kiba)
selections.select{ |selection|
@source_filter.nil? || selection['nom'].start_with?(@source_filter)
}.each{ |selection|
destination_id = "#{selection['id']}-#{selection['nom']}"
destination_id = "#{selection['id']}-#{slugify(selection['nom'])}"
name = selection['libelle'].transform_keys{ |key| key[('libelle'.size)..].downcase }

kiba.source(
Expand Down

0 comments on commit a733e9e

Please sign in to comment.