Sha256: 24d1a78d57137357b80d90f184bb34ca444fb03380bf086a6470971396f5affc

Contents?: true

Size: 755 Bytes

Versions: 5

Compression:

Stored size: 755 Bytes

Contents

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__)

      FileUtils.rm_rf(@home_path)
      FileUtils.mkdir_p(@home_path)
      File.link(source_path, destination_path)
      File.chmod(0755, destination_path)
    end

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

      if is_intellij
        link_php_to_intellij
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vagrant-phpstorm-tunnel-0.1.1 lib/vagrant-phpstorm-tunnel/configurator.rb
vagrant-phpstorm-tunnel-0.1.0 lib/vagrant-phpstorm-tunnel/configurator.rb
vagrant-phpstorm-tunnel-0.0.7 lib/vagrant-phpstorm-tunnel/configurator.rb
vagrant-phpstorm-tunnel-0.0.6 lib/vagrant-phpstorm-tunnel/configurator.rb
vagrant-phpstorm-tunnel-0.0.5 lib/vagrant-phpstorm-tunnel/configurator.rb