<commit_before>require 'formula'

class Vnstat < Formula
  url 'http://humdi.net/vnstat/vnstat-1.11.tar.gz'
  homepage 'http://humdi.net/vnstat/'
  md5 'a5a113f9176cd61fb954f2ba297f5fdb'

  def install
    inreplace ["src/cfg.c", "man/vnstat.1", "man/vnstatd.1", "man/vnstat.conf.5"] do |s|
      s.gsub!('/etc/vnstat.conf',    "#{etc}/vnstat.conf")
      s.gsub!('/var/lib/vnstat',     "#{var}/db/vnstat")
      s.gsub!('/var/log/vnstat.log', "#{var}/log/vnstat.log")
      s.gsub!('/var/run/vnstat.pid', "#{var}/run/vnstat.pid")
    end

    inreplace "src/Makefile" do |s|
      s.change_make_var! "CFLAGS", ENV.cflags
      s.change_make_var! "CC", ENV.cc
    end

    inreplace "cfg/vnstat.conf" do |c|
      c.gsub!('DatabaseDir "/var/lib/vnstat"', %Q{DatabaseDir "#{var}/db/vnstat"})
      c.gsub!('LogFile "/var/log/vnstat.log"', %Q{LogFile "#{var}/log/vnstat.log"})
      c.gsub!('PidFile "/var/run/vnstat.pid"', %Q{PidFile "#{var}/run/vnstat.pid"})
    end

    (var + 'db/vnstat').mkpath
    (var + 'spool/vnstat').mkpath

    system "make -C src"
    (prefix + 'etc').install "cfg/vnstat.conf"
    bin.install "src/vnstat"
    bin.install "src/vnstatd"
    man1.install "man/vnstat.1"
    man1.install "man/vnstatd.1"
    man5.install "man/vnstat.conf.5"
  end

  def caveats; <<-MSG
    To setup vnstat, run `vnstat -u -i en0' (replace en0 with the network
    interface you wish to monitor).

    You must then create a cron job to update the vnstat database.

    Run `crontab -e', and add the following:
    0-55/5 * * * * if [ -x #{bin}/vnstat ] && [ `ls #{var}/db/vnstat/ | wc -l` -ge 1 ]; then #{bin}/vnstat -u; fi
    MSG
  end
end<commit_msg>vnstat: style nit-picks<commit_after>require 'formula'

class Vnstat < Formula
  homepage 'http://humdi.net/vnstat/'
  url 'http://humdi.net/vnstat/vnstat-1.11.tar.gz'
  md5 'a5a113f9176cd61fb954f2ba297f5fdb'

  def install
    inreplace "src/cfg.c", '/etc/vnstat.conf', "#{etc}/vnstat.conf"

    inreplace "man/vnstat.1" do |s|
      s.gsub! '/etc/vnstat.conf', "#{etc}/vnstat.conf"
      s.gsub! '/var/lib/vnstat', "#{var}/db/vnstat"
    end

    inreplace "man/vnstat.conf.5", '/etc/vnstat.conf', "#{etc}/vnstat.conf"

    inreplace "cfg/vnstat.conf" do |c|
      c.gsub! 'DatabaseDir "/var/lib/vnstat"', %Q{DatabaseDir "#{var}/db/vnstat"}
      c.gsub! 'LogFile "/var/log/vnstat.log"', %Q{LogFile "#{var}/log/vnstat.log"}
      c.gsub! 'PidFile "/var/run/vnstat.pid"', %Q{PidFile "#{var}/run/vnstat.pid"}
    end

    (var+'db/vnstat').mkpath
    (var+'spool/vnstat').mkpath

    system "make", "-C", "src", "CFLAGS=#{ENV.cflags}", "CC=#{ENV.cc}"
    (prefix+'etc').install "cfg/vnstat.conf"
    bin.install "src/vnstat", "src/vnstatd"
    man1.install "man/vnstat.1", "man/vnstatd.1"
    man5.install "man/vnstat.conf.5"
  end

  def caveats; <<-EOS.undent
    To setup vnstat, run `vnstat -u -i en0' (replace en0 with the network
    interface you wish to monitor).

    You must then create a cron job to update the vnstat database.

    Run `crontab -e' and add the following:
    0-55/5 * * * * if [ -x #{bin}/vnstat ] && [ `ls #{var}/db/vnstat/ | wc -l` -ge 1 ]; then #{bin}/vnstat -u; fi
    EOS
  end
end
{'fraction_non_alphanumeric': 0.1950298836111985, 'fraction_numerical': 0.023277760301981754, 'mean_word_length': 2.901840490797546, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2436696', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1308, 'n_words': 265}