Class: PureMVCGen::AntChecker
- Inherits:
-
Object
- Object
- PureMVCGen::AntChecker
- Defined in:
- lib/pure_m_v_c_gen/ant_checker.rb
Class Method Summary collapse
-
.find_in_path(utility) ⇒ Object
Searches the path, looking for the given utility.
- .get_path ⇒ Object
-
.get_windows_ant ⇒ Object
Locates the ant executable or BAT file and returns the full path to it.
-
.has_ant_installed? ⇒ Boolean
Determines if ANT is installed on the system.
- .on_windows? ⇒ Boolean
- .windows_executable_extensions ⇒ Object
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 = self.get_path 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 |
.get_path ⇒ Object
25 26 27 |
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 25 def self.get_path (ENV['PATH'] || "").split(File::PATH_SEPARATOR) end |
.get_windows_ant ⇒ Object
Locates the ant executable or BAT file and returns the full path to it
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 30 def self.get_windows_ant ext = %w(.exe .bat) path = self.get_path path.each do |dir| ext.each do |sfx| file = File.join(dir, "ant" + sfx) return File.(file) if File.executable?(file) end end nil 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
44 45 46 |
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 44 def self.on_windows? RUBY_PLATFORM =~ /mswin|mingw/ end |
.windows_executable_extensions ⇒ Object
48 49 50 |
# File 'lib/pure_m_v_c_gen/ant_checker.rb', line 48 def self.windows_executable_extensions %w(.exe .bat .com .cmd) end |