Get started
At the end of this page you will have:
- a real, government-published sanctions list, synced onto your own disk;
- a name on that list, screened and scored, with the reasons that produced the score;
- a name that is not on it, and the one thing an empty result actually means.
One path, no choices along the way. Where you want to know why a step is what it is, Explanation answers it; where you want to do something other than the one path, Guides does.
Install
Section titled “Install”gem "active_sanction"$ bundle installRuby 3.1 or newer.
Configure a store
Section titled “Configure a store”A sync needs somewhere to put what it downloads. Name a directory:
ActiveSanction.configure do |c| c.storage_dir = "./sanctions-data" c.sources = [:un_consolidated]endSync one list
Section titled “Sync one list”un_consolidated — the UN Security Council’s list — is one file and the
smallest of the seven this gem reads, so this step takes seconds rather than
minutes.
report = ActiveSanction.sync!puts report1 source in 2.83s: 1 updated un_consolidated updated 1011 records just fetched 2.83sRead the sync report
Section titled “Read the sync report”report.updated.map(&:source) # => [:un_consolidated]report[:un_consolidated].record_count # => 1011report[:un_consolidated].age # => 0A sync tells you what it did. Hold onto that; it pays off once this is running on a schedule.
Screen a name that matches
Section titled “Screen a name that matches”Bosco Ntaganda has been on this list since 2005.
hit = ActiveSanction.screen(name: "Bosco Ntaganda", type: :individual).first
hit.score # => 100.0hit.matched_name.value # => "Bosco Ntaganda"Read the explanation
Section titled “Read the explanation”The score is the sum of these:
hit.explanation.map(&:to_s)# => ["+100.0 name: matched alias \"Bosco Ntaganda\" (aka)"]Screen a name that does not match
Section titled “Screen a name that does not match”ActiveSanction.screen(name: "Daniel Ashworth", type: :individual)# => []An empty array means nothing over the threshold in the list you hold — it does not mean not sanctioned.
Where to go next
Section titled “Where to go next”- Guides — for the next job: adding a source, choosing a store, syncing on a schedule.
- Reference — the seven lists, one uniform block each.
- Explanation — why a score is what it is, and where the gem ends and the service begins.