Sha256: 86f79c6ca1d76dc9e671c9211ac297958812b153b75cf3ada5c56fc247a0ec68

Contents?: true

Size: 822 Bytes

Versions: 1

Compression:

Stored size: 822 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-phpstorm-tunnel-0.0.4 lib/vagrant-phpstorm-tunnel/configurator.rb