<commit_before>require 'fileutils'
require 'hastie/constants'
require 'hastie/config_file'
require 'thor/group'

module Hastie
  class ReportWatcher < Thor::Group
    include Thor::Actions

    desc "Watches Directory Using Jekyll"
    argument :path, :type => :string, :default => ".", :desc => "The path to the report directory"

    attr_accessor :report_dir

    # this is done just as a double check that we are in a report directory
    def check_report_file
      self.report_dir = File.expand_path(path)
      report_config_file = File.join(report_dir, Hastie.report_config_name)
      if !File.exists? report_config_file
        say_status "error","Cannot locate #{Hastie.report_config_name}.", :red
        say_status "error","Directory #{self.report_dir} is not a report.", :red
        exit(1)
      end
    end

    def set_root
      self.destination_root = self.report_dir
    end

    def read_config_file
      config_file = File.join(self.report_dir, Hastie.watch_config_file)
      if !File.exists? config_file
        say_status "error", "Cannot find #{config_file}", :red
        say_status "error","Directory #{self.report_dir} is not a report.", :red
        exit(1)
      end
      local_config = ConfigFile.load(config_file, :local)
      self.options = local_config.merge(self.options)
    end

    def start_jekyll
      port = self.options["local"]["server_port"] || "4000"
      url = "http://0.0.0.0:#{port}"
      say_status "open", url

      pid = fork do
        begin
          require 'launchy'
          sleep 4
          Launchy.open(url)
        rescue LoadError
        rescue
        end
      end<commit_msg>remove launchy. problem in linux<commit_after>require 'fileutils'
require 'hastie/constants'
require 'hastie/config_file'
require 'thor/group'

module Hastie
  class ReportWatcher < Thor::Group
    include Thor::Actions

    desc "Watches Directory Using Jekyll"
    argument :path, :type => :string, :default => ".", :desc => "The path to the report directory"

    attr_accessor :report_dir

    # this is done just as a double check that we are in a report directory
    def check_report_file
      self.report_dir = File.expand_path(path)
      report_config_file = File.join(report_dir, Hastie.report_config_name)
      if !File.exists? report_config_file
        say_status "error","Cannot locate #{Hastie.report_config_name}.", :red
        say_status "error","Directory #{self.report_dir} is not a report.", :red
        exit(1)
      end
    end

    def set_root
      self.destination_root = self.report_dir
    end

    def read_config_file
      config_file = File.join(self.report_dir, Hastie.watch_config_file)
      if !File.exists? config_file
        say_status "error", "Cannot find #{config_file}", :red
        say_status "error","Directory #{self.report_dir} is not a report.", :red
        exit(1)
      end
      local_config = ConfigFile.load(config_file, :local)
      self.options = local_config.merge(self.options)
    end

    def start_jekyll
      port = self.options["local"]["server_port"] || "4000"
      url = "http://0.0.0.0:#{port}"
      say_status "open", url

      # pid = fork do
      #   begin
      #     require 'launchy'
      #     sleep 4
      #     Launchy.open(url)
      #   rescue LoadError
      #   rescue
      #   end
      # end
{'fraction_non_alphanumeric': 0.10308660473479173, 'fraction_numerical': 0.006592747977225052, 'mean_word_length': 2.7379619260918253, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '6246980', 'n_tokens_mistral': 1058, 'n_tokens_neox': 1034, 'n_words': 273}