<commit_before>if RUBYMOTION_ENV == "development"
  module Kernel
    def pm_live_screens(opts={})
      @screen_timer.invalidate if @screen_timer
      @screen_timer = nil
      if opts == false || opts.to_s.downcase == "off"
        "Live reloading of PM screens is now off."
      else
        @screen_timer = pm_live_watch("#{pm_app_root_path}/app/screens/**/*.rb", opts) do |reloaded_file, new_code|
          screen_names = pm_parse_screen_names(new_code)
          puts "Reloaded #{screen_names.join(", ")} #{screen}." if opts[:debug]
          vcs = pm_all_view_controllers(UIApplication.sharedApplication.delegate.window.rootViewController)
          puts "Found #{vcs.map(&:to_s).join(", ")}." if opts[:debug]
          vcs.each do |vc|
            if pm_is_in_ancestry?(vc, screen_names)
              puts "Sending :on_live_reload to #{vc.inspect}." if opts[:debug]
              vc.send(:on_live_reload) if vc.respond_to?(:on_live_reload)
            end
          end
        end
        "Live reloading of PM screens is now on."
      end
    end

    def pm_live_watch(path_query, opts={}, &callback)
      # Get list of screen files
      puts path_query if opts[:debug]
      live_file_paths = Dir.glob(path_query)
      puts live_file_paths if opts[:debug]

      live_files = live_file_paths.inject({}) do |out, live_file_path_file|
        out[live_file_path_file] = Time.now
        out
      end

      live_reload_timer = pm_live_reload_timer_every(opts[:interval] || 0.5) do
        live_file_changed = false<commit_msg>Move root path into pm_live_watch<commit_after>if RUBYMOTION_ENV == "development"
  module Kernel
    def pm_live_screens(opts={})
      @screen_timer.invalidate if @screen_timer
      @screen_timer = nil
      if opts == false || opts.to_s.downcase == "off"
        "Live reloading of PM screens is now off."
      else
        @screen_timer = pm_live_watch("app/screens/**/*.rb", opts) do |reloaded_file, new_code|
          screen_names = pm_parse_screen_names(new_code)
          puts "Reloaded #{screen_names.join(", ")} #{screen}." if opts[:debug]
          vcs = pm_all_view_controllers(UIApplication.sharedApplication.delegate.window.rootViewController)
          puts "Found #{vcs.map(&:to_s).join(", ")}." if opts[:debug]
          vcs.each do |vc|
            if pm_is_in_ancestry?(vc, screen_names)
              puts "Sending :on_live_reload to #{vc.inspect}." if opts[:debug]
              vc.send(:on_live_reload) if vc.respond_to?(:on_live_reload)
            end
          end
        end
        "Live reloading of PM screens is now on."
      end
    end

    def pm_live_watch(path_query, opts={}, &callback)
      # Get list of screen files
      puts path_query if opts[:debug]
      live_file_paths = Dir.glob("#{pm_app_root_path}/#{path_query}")
      puts live_file_paths if opts[:debug]

      live_files = live_file_paths.inject({}) do |out, live_file_path_file|
        out[live_file_path_file] = Time.now
        out
      end

      live_reload_timer = pm_live_reload_timer_every(opts[:interval] || 0.5) do
        live_file_changed = false
{'fraction_non_alphanumeric': 0.11139646869983949, 'fraction_numerical': 0.0012841091492776886, 'mean_word_length': 2.7678355501813785, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5078851', 'n_tokens_mistral': 1020, 'n_tokens_neox': 1019, 'n_words': 223}