Class: PureMVCGen::AntChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/pure_m_v_c_gen/ant_checker.rb

Class Method Summary collapse

Class Method Details

.find_in_path(utility) ⇒ Object

Searches the path, looking for the given utility. If an executable file is found that matches the parameter, this returns true.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 11

def self.find_in_path(utility)
 path = (ENV['PATH'] || "").split(File::PATH_SEPARATOR)
 suffixes = self.on_windows? ? self.windows_executable_extensions : [""]

 path.each do |dir|
   suffixes.each do |sfx|
     file = File.join(dir, utility + sfx)
     return true if File.executable?(file)
   end
 end

 false
end

.has_ant_installed?Boolean

Determines if ANT is installed on the system



5
6
7
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 5

def self.has_ant_installed?
  AntChecker.find_in_path("ant")
end

.on_windows?Boolean



25
26
27
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 25

def self.on_windows?
 RUBY_PLATFORM =~ /mswin|mingw/
end

.windows_executable_extensionsObject



29
30
31
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 29

def self.windows_executable_extensions
 %w(.exe .bat .com .cmd)
end