Sha256: 8bb8a1fd9e89d74b3bbcee6acb1afbf18ef1ea1f31ab33b6d97fc45f3047bda3

Contents?: true

Size: 1 KB

Versions: 52

Compression:

Stored size: 1 KB

Contents

#!/usr/bin/env ruby
#
# Copyright (C) 2004 Satoru Takabayashi <satoru@namazu.org>
# You can redistribute it and/or modify it under GPL2.
#
puts "Usage: tdiary-referer-clean PATTERN FILE..." if ARGV.length == 0
pattern = Regexp.new(ARGV.shift)
file_names = ARGV

deleted_referers = []
file_names.each {|file_name|
  tmp_name = "tmp.#{Process.pid}"
  i = File.open(file_name)
  o = File.open(tmp_name, "w")

  first_line = i.gets
  o.print first_line

  while true
    date_line = i.gets
    break if date_line.nil?
    raise unless /^Date: /.match(date_line)
    blank_line = i.gets
    raise unless blank_line == "\n"

    o.print date_line
    o.print blank_line
    while line = i.gets
      if line == ".\n"
        o.print line
        next
      end
      if pattern.match(line)
        deleted_referers.push(line)
      else
        o.print line
      end
    end
  end
  i.close
  o.close

  File.rename(file_name, file_name + ".bak")
  File.rename(tmp_name, file_name)
}
deleted_referers.each {|referer| print referer }

Version data entries

52 entries across 46 versions & 2 rubygems

Version Path
tdiary-contrib-5.3.0 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.2.4 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.2.3 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.2.2 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.2.1 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.2.0 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.7 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.6 util/clean-spam/tdiary-referer-clean
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/util/clean-spam/tdiary-referer-clean
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/bundler/gems/tdiary-contrib-d1e41204db13/util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.5 util/clean-spam/tdiary-referer-clean
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.4 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.3 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.2 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.1 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.1.0 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.0.13 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.0.12 util/clean-spam/tdiary-referer-clean
tdiary-contrib-5.0.11 util/clean-spam/tdiary-referer-clean