<commit_before>require 'drb/drb'
require 'yaml'

require 'cli/mrkmctl_options'
require 'misc/murakumo_const'

# オプションをパース
options = mrkmctl_parse_args

# リモートオブジェクトを生成
there = DRbObject.new_with_uri("drbunix:#{options[:socket]}")

cmd, arg = options[:command]

# 各コマンドの処理
begin
  case cmd
  # 一覧表示
  when :list
    records = if arg.kind_of?(String)
                # 引数がある場合はフィルタリング
                there.list_records.select {|r| r[0..1].any?{|i| i.start_with?(arg) } }
              else
                there.list_records
              end

    puts <<-EOF
IP address       TTL     Priority  Activity  Hostname
---------------  ------  ---------  --------  ----------
    EOF
    records.each do |r|
      priority = case r[3]
                 when Murakumo::ORIGIN
                   'Origin'
                 when Murakumo::MASTER
                   'Master'
                 when Murakumo::SECONDARY
                   'Secondary'
                 else
                   'Backup'
                 end

      r[3] = priority
      r[4] = (r[4] == Murakumo::ACTIVE ? 'Active' : 'Inactive')
      puts '%-15s  %6d  %-9s  %-8s  %s' % r.values_at(0, 2, 3, 4, 1)<commit_msg>improve filtering<commit_after>require 'drb/drb'
require 'yaml'

require 'cli/mrkmctl_options'
require 'misc/murakumo_const'

# オプションをパース
options = mrkmctl_parse_args

# リモートオブジェクトを生成
there = DRbObject.new_with_uri("drbunix:#{options[:socket]}")

cmd, arg = options[:command]

# 各コマンドの処理
begin
  case cmd
  # 一覧表示
  when :list
    # レコードの取得
    records = there.list_records

    # 値の書き換え
    records.each do |r|
      priority = case r[3]
                 when Murakumo::ORIGIN
                   'Origin'
                 when Murakumo::MASTER
                   'Master'
                 when Murakumo::SECONDARY
                   'Secondary'
                 else
                   'Backup'
                 end

      r[3] = priority
      r[4] = (r[4] == Murakumo::ACTIVE ? 'Active' : 'Inactive')
    end

    if arg.kind_of?(String)
      # 引数がある場合はフィルタリング（TTLを除く）
      records = records.select {|r| r.values_at(0, 1, 3, 4).any?{|i| i.to_s.downcase.start_with?(arg.to_s.downcase) } }
    end

    puts <<-EOF
IP address       TTL     Priority  Activity  Hostname
---------------  ------  ---------  --------  ----------
    EOF
    records.each do |r|
      puts '%-15s  %6d  %-9s  %-8s  %s' % r.values_at(0, 2, 3, 4, 1)
{'fraction_non_alphanumeric': 0.1502288805659592, 'fraction_numerical': 0.014148980441115273, 'mean_word_length': 1.5711229946524063, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1156819', 'n_tokens_mistral': 936, 'n_tokens_neox': 902, 'n_words': 169}