Class: Redcar::Project::OpenCommand

Inherits:
Command show all
Defined in:
plugins/project/lib/project/commands.rb

Overview

FIXME: XXX: The rest of this file is outright ugly. The Redcar.platform ultimately needs to return a platform object which we can dispatch to for commandlines, configuration, escaping and all that.

Direct Known Subclasses

OpenDirectoryInCommandLineCommand, OpenDirectoryInExplorerCommand

Constant Summary

Constants included from Observable

Observable::ASPECTS

Instance Attribute Summary (collapse)

Attributes inherited from Command

#error

Instance Method Summary (collapse)

Methods inherited from Command

active_changed, #environment, inherited, #inspect, norecord, record?, #run

Methods included from Sensitive

#active?, #sensitivities, #sensitivity_names, #sensitize

Methods included from Observable

#add_listener, #notify_listeners, #remove_listener

Constructor Details

- (OpenCommand) initialize(path)

A new instance of OpenCommand



250
251
252
# File 'plugins/project/lib/project/commands.rb', line 250

def initialize(path)
  @path = path
end

Instance Attribute Details

- (Object) path (readonly)

Returns the value of attribute path



248
249
250
# File 'plugins/project/lib/project/commands.rb', line 248

def path
  @path
end

Instance Method Details

- (Object) find(executable)



254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'plugins/project/lib/project/commands.rb', line 254

def find(executable)
  path = if Redcar.platform == :windows
    ENV['PATH'].split(';')
  else
    ENV['PATH'].split(':')
  end.find {|d| File.exist?(File.join(d, executable))}

  if path
    File.join(path, executable)
  else
    nil
  end
end

- (Object) run_application(app, *options)



268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'plugins/project/lib/project/commands.rb', line 268

def run_application(app, *options)
  # TODO: Investigate why Spoon doesn't seem to work on osx
  if SPOON_AVAILABLE and Redcar.platform != :osx
    ::Spoon.spawn(app, *options)
  else
    # TODO: This really needs proper escaping.
    options = options.map {|o| %{ "#{o}" } }.join(' ')
    Thread.new do
      system("#{app} #{options}")
      puts "  Finished: #{app} #{options}"
    end
  end
end