<commit_before>require 'fileutils'

module VagrantPhpStormTunnel
  class Configurator
    def initialize(app, env)
      @app = app
      @env = env

      @root_path = @env[:root_path].to_s
    end

    def is_intellij
      File.exist? @root_path + '/.idea'
    end

    def link_php_to_intellij
      destination_path = @root_path + '/.idea/vagrant/php'
      source_path = File.expand_path('../../../data/php', __FILE__)

      if !File.exist? destination_path
        FileUtils.mkdir_p(File.dirname(destination_path))
        File.link(source_path, destination_path)
        File.chmod(0755, destination_path)
      end
    end

    def call(env)
      @env = env
      @app.call(env)

      if !is_intellij
        raise "Cannot detect intellij environment at #{@root_path}"
      end

      link_php_to_intellij
    end
  end
end
<commit_msg>Refactored configuration.rb<commit_after>require 'fileutils'

module VagrantPhpstormTunnel
  class Configurator
    def initialize(app, env)
      @app = app
      @env = env

      @root_path = @env[:root_path].to_s
      @home_path = '.idea/vagrant'
    end

    def is_intellij
      File.exist? @root_path + '/.idea'
    end

    def link_php_to_intellij
      destination_path = File.join(@root_path, @home_path, 'php')
      source_path = File.expand_path('../../../data/php', __FILE__)

      if !File.exist? destination_path
        FileUtils.mkdir_p(File.dirname(destination_path))
        File.link(source_path, destination_path)
        File.chmod(0755, destination_path)
      end
    end

    def call(env)
      @env = env
      @app.call(env)

      if is_intellij
        link_php_to_intellij
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10142348754448399, 'fraction_numerical': 0.004744958481613286, 'mean_word_length': 2.4498977505112474, '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': '4902616', 'n_tokens_mistral': 591, 'n_tokens_neox': 571, 'n_words': 116}