Ornacieux (1879) - Johan Barthold Jongkind

Running Rake Tasks in a Loop

Rake tasks in a loop, will only executed once if they are not “re-enabled”. Take a look at this example: namespace :yoksis do desc 'fetches all references' task :references do mapping = { get_instruction_language: 'UnitInstructionLanguage', get_instruction_type: 'UnitInstructionType' } mapping.each do |action, klass| Rake::Task['yoksis:reference'].invoke(action, klass) end end desc 'fetch an individual reference' task :reference, %i[soap_method klass] => [:environment] do |_, args| puts args[:soap_method] puts args[:klass] end end When you run the yoksis:references task, it will only print out {get_instruction_language: 'UnitInstructionLanguage'} and will skip the second item of the mapping hash....

April 3, 2017 · 1 min · Serhat M. Dündar
Halage En Hollande (1867) - Johan Barthold Jongkind

Calculating Similarity Between Two Data With Ruby and Elasticsearch

I recently had to find similar data located in a dataset, in order to find potential duplicate records: "John Doe 123456789" "John Foe 123123123" After considering a couple of options, I’ve decided to continue with Elasticsearch, as it was already integrated in the project I was working on. The Ruby client of Elasticsearch provided a useful function on search results, records.each_with_hit, that I could abuse for this situation: file = File....

December 8, 2015 · 1 min · Serhat M. Dündar