<commit_before>module WatchmonkeyCli
  class Platypus
    def self.hook!(app, opts = {})
      opts = opts.reverse_merge(notifications: true)
      app.instance_eval do
        # send errors via notification center
        hook :result_dump do |robj, args, checker|
          if robj.error?
            robj.messages.each do |m|
              msg  = "#{robj.args[0].try(:name) || robj.args[0].presence || "?"}: #{m}"

              # makes no sound
              fmsg = msg.gsub('"', '\"').gsub("'", %{'"'"'})
              `osascript -e 'display notification "#{fmsg}" with title "WatchMonkey"'`

              # makes a sound
              # sync { puts "NOTIFICATION:#{msg}" }
            end
          end
        end if opts[:notifications]

        hook :wm_work_start, :wm_work_end do
          # mastermind calculation I swear :D (<-- no idea what I did here)
          # sync { puts "PROGRESS:#{((@threads.length-@threads.select{|t| t[:working] }.length.to_d) / @threads.length * 100).to_i}" }
          sync do
            active = @threads.select{|t| t[:working] }.length
            total  = @threads.select{|t| t[:working] }.length + @queue.length
            perc   = total.zero? ? 100 : (active.to_d / total * 100).to_i
            puts "PROGRESS:#{perc}"
          end
        end
      end
    end
  end
end<commit_msg>Make platypus notification type optional<commit_after>module WatchmonkeyCli
  class Platypus
    def self.hook!(app, opts = {})
      opts = opts.reverse_merge(notifications: true)
      app.instance_eval do
        # send errors via notification center
        hook :result_dump do |robj, args, checker|
          if robj.error?
            robj.messages.each do |m|
              msg  = "#{robj.args[0].try(:name) || robj.args[0].presence || "?"}: #{m}"

              case opts[:notifications]
              when 1
                # makes no sound
                fmsg = msg.gsub('"', '\"').gsub("'", %{'"'"'})
                `osascript -e 'display notification "#{fmsg}" with title "WatchMonkey"'`
              when 2
                # makes a sound
                sync { puts "NOTIFICATION:#{msg}" }
              end
            end
          end
        end if opts[:notifications]

        hook :wm_work_start, :wm_work_end do
          # mastermind calculation I swear :D (<-- no idea what I did here)
          # sync { puts "PROGRESS:#{((@threads.length-@threads.select{|t| t[:working] }.length.to_d) / @threads.length * 100).to_i}" }
          sync do
            active = @threads.select{|t| t[:working] }.length
            total  = @threads.select{|t| t[:working] }.length + @queue.length
            perc   = total.zero? ? 100 : (active.to_d / total * 100).to_i
            puts "PROGRESS:#{perc}"
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.13898788310762653, 'fraction_numerical': 0.008553100498930863, 'mean_word_length': 1.823943661971831, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '655568', 'n_tokens_mistral': 893, 'n_tokens_neox': 854, 'n_words': 218}