vagrant-phpstorm-tunnel 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a30108c2f50668f943fbd9ca9ae7030d23195fcd
4
- data.tar.gz: 30eca830b89620109440391b186ac553dcb122da
3
+ metadata.gz: 2f69fa584205c2640712c910f852c97525fdc184
4
+ data.tar.gz: 0df7cb13f6c5636e824ffeaa68a7deca3e2ec058
5
5
  SHA512:
6
- metadata.gz: 5f31049e7fec59a76d69cc44482f30c74892629bb503fd0cef671051ac89c2add55eede65fb9f85b2c274b72e76eacc5f418e6a5617641c3b9d59da6d6d4f001
7
- data.tar.gz: ba2661a2b0bbe8912cd6e890823f71f851af68814224f0627b8454db4866aeef0f3ed49fc5b165a9790d0124ee7ca0903bce2adf1a2acb7b658fd5622dc65dcf
6
+ metadata.gz: ced344ff58500fdb3cd10d5772ab70bf662ae53d6cca742e047ca4723bfeba69197ccfb1357165fa2b7464695a8f7c57b011416cb33c57f73490e94e96f46d72
7
+ data.tar.gz: 2823e224a09a59a4a06d9f2e73d66bdf4f29b3245ef95b7552a457cc2dce21da9874346e38cae4758e665d23a74f892d419172ce00aba3e36682141995629082
data/README.md CHANGED
@@ -11,6 +11,16 @@ Installation
11
11
  vagrant plugin install vagrant-phpstorm-tunnel
12
12
  ```
13
13
 
14
+ Vagrantfile
15
+ -----------
16
+ You can configure your `project_home` path within `vagrant` machine. This is needed for proper paths mapping from `PhpStorm` during debugging (please have a look also section below).
17
+ ```ruby
18
+ Vagrant.configure('2') do |config|
19
+ (...)
20
+ config.phpstorm_tunnel.project_home = '/home/vagrant/fuboo'
21
+ end
22
+ ```
23
+
14
24
  PhpStorm
15
25
  --------
16
26
  `vagrant-phpstorm-tunnel` will create a file `.idea/vagrant/php` in your vagrant-project.
data/data/php CHANGED
@@ -20,6 +20,11 @@ if (!filter_var($hostIp, FILTER_VALIDATE_IP)) {
20
20
  throw new Exception('Cannot detect host IP, got value `' . $hostIp . '`.');
21
21
  }
22
22
 
23
+ // Detect Project Dir on Guest
24
+ $projectDirGuestFile = $homeDirHost . '/vm_project_dir';
25
+ if (file_exists($projectDirGuestFile)) {
26
+ $projectDirGuest = trim(file_get_contents($projectDirGuestFile));
27
+ }
23
28
 
24
29
  $arguments = $argv;
25
30
  array_shift($arguments);
@@ -0,0 +1,16 @@
1
+ module VagrantPhpstormTunnel
2
+ class Config < Vagrant.plugin(2, :config)
3
+
4
+ attr_accessor :project_home
5
+
6
+ def project_home=(path)
7
+ @project_home = path
8
+ end
9
+
10
+ def to_hash
11
+ {
12
+ :project_home => project_home
13
+ }
14
+ end
15
+ end
16
+ end
@@ -5,6 +5,7 @@ module VagrantPhpstormTunnel
5
5
  def initialize(app, env)
6
6
  @app = app
7
7
  @env = env
8
+ @vm = nil
8
9
 
9
10
  @root_path = @env[:root_path].to_s
10
11
  @home_path = '.idea/vagrant'
@@ -18,17 +19,31 @@ module VagrantPhpstormTunnel
18
19
  destination_path = File.join(@root_path, @home_path, 'php')
19
20
  source_path = File.expand_path('../../../data/php', __FILE__)
20
21
 
21
- FileUtils.rm_rf(@home_path)
22
- FileUtils.mkdir_p(@home_path)
23
22
  File.link(source_path, destination_path)
24
23
  File.chmod(0755, destination_path)
25
24
  end
26
25
 
26
+ def setup_environment
27
+ FileUtils.rm_rf(@home_path)
28
+ FileUtils.mkdir_p(@home_path)
29
+
30
+ if tunnel_options[:project_home]
31
+ destination_path = File.join(@root_path, @home_path, 'vm_project_dir')
32
+ File.write(destination_path, tunnel_options[:project_home].to_s, mode: 'a')
33
+ end
34
+ end
35
+
36
+ def tunnel_options
37
+ !@vm.nil? ? @vm.config.phpstorm_tunnel.to_hash : {}
38
+ end
39
+
27
40
  def call(env)
28
41
  @env = env
29
42
  @app.call(env)
43
+ @vm = env[:machine]
30
44
 
31
45
  if is_intellij
46
+ setup_environment
32
47
  link_php_to_intellij
33
48
  end
34
49
  end
@@ -1,10 +1,15 @@
1
1
  require 'vagrant-phpstorm-tunnel/configurator'
2
+ require 'vagrant-phpstorm-tunnel/config'
2
3
 
3
4
  module VagrantPhpstormTunnel
4
5
  class Plugin < Vagrant.plugin('2')
5
6
 
6
7
  name 'vagrant-phpstorm-tunnel'
7
8
 
9
+ config 'phpstorm_tunnel' do
10
+ Config
11
+ end
12
+
8
13
  %w{up provision reload}.each do |action|
9
14
  action_hook(:install_tunnel, "machine_action_#{action}".to_sym) do |hook|
10
15
  hook.append VagrantPhpstormTunnel::Configurator
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-phpstorm-tunnel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -37,6 +37,7 @@ files:
37
37
  - README.md
38
38
  - data/php
39
39
  - lib/vagrant-phpstorm-tunnel.rb
40
+ - lib/vagrant-phpstorm-tunnel/config.rb
40
41
  - lib/vagrant-phpstorm-tunnel/configurator.rb
41
42
  homepage: https://github.com/cargomedia/vagrant-phpstorm-tunnel
42
43
  licenses: