Last active
August 29, 2015 14:03
-
-
Save rgarner/89a2b0256bab41ca488c to your computer and use it in GitHub Desktop.
Futz random-ish input to import_mappings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
if ARGV.length != 1 | |
puts 'Usage: monkey-futz <host>' | |
exit 1 | |
end | |
@host = ARGV.first | |
TYPES = [:archive, | |
:archive_with_tna_url, | |
:archive_with_bad_url, | |
:redirect, | |
:unresolved, | |
:header, | |
:too_many, | |
:offsite_host, | |
# :blank, # commented out while it fails | |
:dupes, | |
:not_header] | |
@path_num = 0 | |
@new_url_num = 0 | |
def next_new_url | |
@new_url_num += 1 | |
"http://#{@host}/#{@new_url_num}" | |
end | |
def next_path_or_url | |
@path_num += 1 | |
"#{rand * 2 > 1 ? "http://#{@host}" : nil}/#{@path_num}" | |
end | |
def random_line | |
case type = TYPES.sample | |
when :archive_with_tna_url then "#{next_path_or_url},http://webarchive.nationalarchives.gov.uk/20121222101738/http://number10.gov.uk//" | |
when :archive_with_bad_url then "#{next_path_or_url},http://[][]__*" | |
when :offsite_host then "http://road.cc/,TNA" | |
when :archive then "#{next_path_or_url},TNA" | |
when :redirect then "#{next_path_or_url},#{next_new_url}" | |
when :unresolved then "#{next_path_or_url}," | |
when :header then "old_url,new_url" | |
when :too_many then "#{next_path_or_url},#{next_new_url},extra-stuff" | |
when :blank then '' | |
when :not_header then "oxd_url,nxw_url,rubbish" | |
when :dupes then u = "#{next_path_or_url},TNA"; ("#{u}\n" * 2).chomp | |
else "oops - #{type}" | |
end | |
end | |
1000.times { puts random_line } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment