Sha256: 3a474bae66e1430047ef85c3fe2fda672346fa3c3f4701c8856fa46b965a3cf3

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 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 '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

1 entries across 1 versions & 1 rubygems

Version Path
gman-7.0.2 script/vendor-swot