Sha256: e151f9b83cd01670765ba88b342246bae513a9190276fb943dadb3ebcda00725

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

#! /usr/bin/env ruby
#
# Vendors the Swot-maintained list of adademic domains into config/academic.txt
# Source: https://github.com/leereilly/swot/
#
# Usage: script/vendor-swot
#
# Will automatically fetch latest version of the list and merge
# You can check for changes and commit via `git status`
#
# It's also probably a good idea to run `script/ci-build` for good measure
#
# Note: We do this, because as a bajillion individual files, Swot takes up 30MB

require './lib/gman'
require 'swot'

# Generate array of all Swot domains
domains = Swot.all_domains
domains << Swot::ACADEMIC_TLDS

# Init the importer, builiding a DomainList
group = "Academic domains vendored from Swot v#{Swot::VERSION}"
hash = { group => domains }

importer = Gman::Importer.new(hash)
importer.logger.info "Importing from Swot v#{Swot::VERSION}"
importer.logger.info "Found #{domains.count} academic domains"

domain_list = importer.domain_list
domain_list.path = Gman.academic_list_path

# Cleanup and write
# Note: we're not using the import method, as that assume's we're writing the
# government domain list and would use Swot to ensure domains aren't academic
importer.send :normalize_domains!
domain_list.data[group] << Swot::BLACKLIST.map { |domain| "!#{domain}" }
domain_list.data[group] = domain_list.data[group].flatten
domain_list.write

importer.logger.info "Vendored #{importer.domain_list.count} academic domains."

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gman-7.0.1 script/vendor-swot
gman-7.0.0 script/vendor-swot