<commit_before>class Oya::Handler
  include Observable

  attr_accessor :target, :interval, :startup_msg, :shutdown_msg
  @@default_options = {:interval => 1, :startup_msg => 'Watch start!', :shutdown_msg => 'Bye!'}

  def initialize(target='', params={}, &block)
    @target = target
    @@default_options.merge(params).each {|k,v| send("#{k.to_s}=", v) }
    yield self if block_given?
  end

  def self.watch(target='', params={}, &block)
    new(target, params, &block).watch
  end

  def watch
    Signal.trap(:INT) do
      notify_observers(:message => shutdown_msg, :command => ':')
      exit(1)
    end

    notify_observers(:message => startup_msg, :command => ':')
    @last_status  = current_status
    loop do
      sleep interval
      notify_observers(:changed_file => target) if target_changed?
    end
  end

  def notify_observers(params={})
    changed
    super(params.merge(:time => Time.now))
  end

  private<commit_msg>ターゲットのパスを正しく展開するよう修正<commit_after>class Oya::Handler
  include Observable

  attr_accessor :target, :interval, :startup_msg, :shutdown_msg
  @@default_options = {:interval => 1, :startup_msg => 'Watch start!', :shutdown_msg => 'Bye!'}

  def initialize(target='', params={}, &block)
    @target = File.expand_path(target)
    @@default_options.merge(params).each {|k,v| send("#{k.to_s}=", v) }
    yield self if block_given?
  end

  def self.watch(target='', params={}, &block)
    new(target, params, &block).watch
  end

  def watch
    Signal.trap(:INT) do
      notify_observers(:message => shutdown_msg, :command => ':')
      exit(1)
    end

    notify_observers(:message => startup_msg, :command => ':')
    @last_status  = current_status
    loop do
      sleep interval
      notify_observers(:changed_file => target) if target_changed?
    end
  end

  def notify_observers(params={})
    changed
    super(params.merge(:time => Time.now))
  end

  private
{'fraction_non_alphanumeric': 0.14704343275771847, 'fraction_numerical': 0.0020931449502878076, 'mean_word_length': 3.8282828282828283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, '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': '1955591', 'n_tokens_mistral': 667, 'n_tokens_neox': 641, 'n_words': 141}