Class: VagrantPhpstormTunnel::Configurator
- Inherits:
-
Object
- Object
- VagrantPhpstormTunnel::Configurator
- Defined in:
- lib/vagrant-phpstorm-tunnel/configurator.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Configurator
constructor
A new instance of Configurator.
- #is_intellij ⇒ Object
- #link_php_to_intellij ⇒ Object
- #setup_environment ⇒ Object
- #tunnel_options ⇒ Object
Constructor Details
#initialize(app, env) ⇒ Configurator
Returns a new instance of Configurator.
5 6 7 8 9 10 11 12 |
# File 'lib/vagrant-phpstorm-tunnel/configurator.rb', line 5 def initialize(app, env) @app = app @env = env @vm = nil @root_path = @env[:root_path].to_s @home_path = File.join(@root_path, '.idea/vagrant') end |
Instance Method Details
#call(env) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vagrant-phpstorm-tunnel/configurator.rb', line 45 def call(env) @env = env @app.call(env) @vm = env[:machine] if is_intellij setup_environment link_php_to_intellij end end |
#is_intellij ⇒ Object
14 15 16 |
# File 'lib/vagrant-phpstorm-tunnel/configurator.rb', line 14 def is_intellij File.exist? @root_path + '/.idea' end |
#link_php_to_intellij ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/vagrant-phpstorm-tunnel/configurator.rb', line 18 def link_php_to_intellij destination_path = File.join(@home_path, 'php') source_path = File.('../../../data/php', __FILE__) File.link(source_path, destination_path) File.chmod(0755, destination_path) end |
#setup_environment ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-phpstorm-tunnel/configurator.rb', line 26 def setup_environment FileUtils.rm_rf(@home_path) FileUtils.mkdir_p(@home_path) if [:project_home] destination_path = File.join(@home_path, 'vm_project_dir') File.write(destination_path, [:project_home].to_s, mode: 'a') end if [:command_prefix] destination_path = File.join(@home_path, 'vm_command_prefix') File.write(destination_path, [:command_prefix].to_s, mode: 'a') end end |
#tunnel_options ⇒ Object
41 42 43 |
# File 'lib/vagrant-phpstorm-tunnel/configurator.rb', line 41 def !@vm.nil? ? @vm.config.phpstorm_tunnel.to_hash : {} end |