Class: Envcheck
- Inherits:
-
Object
- Object
- Envcheck
- Defined in:
- lib/envcheck.rb
Constant Summary collapse
- COMMANDS =
Constants ============================================================
{ :ruby => { :version => /^ruby (\S+)/ }, :rubygems => { :bin => 'gem', :version => /(\S+)/ }, :bundler => { :bin => 'bundle', :version => /^Bundler version (.*)/ }, :passenger => { :version => /^Phusion Passenger version (\S+)/ }, :ImageMagick => { :bin => 'convert', :version => /^Version: ImageMagick (\S+)/ }, :mysql => { :version => /Ver\s+\S+\s+Distrib\s+(\S+),/ } }.freeze
Class Method Summary collapse
-
.report ⇒ Object
Class Methods ========================================================.
Instance Method Summary collapse
- #find_in_path(file) ⇒ Object
-
#initialize(options = nil) ⇒ Envcheck
constructor
Instance Methods =====================================================.
- #path ⇒ Object
- #report ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Envcheck
Instance Methods =====================================================
36 37 38 |
# File 'lib/envcheck.rb', line 36 def initialize( = nil) @options = end |
Class Method Details
.report ⇒ Object
Class Methods ========================================================
30 31 32 |
# File 'lib/envcheck.rb', line 30 def self.report self.new.report end |
Instance Method Details
#find_in_path(file) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/envcheck.rb', line 46 def find_in_path(file) return unless (file) file = file.to_s self.path.each do |path| test_path = File.(file, path) if (File.exist?(test_path)) return test_path end end nil end |
#path ⇒ Object
40 41 42 43 44 |
# File 'lib/envcheck.rb', line 40 def path @path ||= ENV['PATH'].split(/\:/).select do |path| path and path.match(/\S/) end end |
#report ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/envcheck.rb', line 61 def report summary = '' COMMANDS.each do |command, config| summary << "#{command}\n" if (bin_found = self.find_in_path(config[:bin] || command)) summary << " #{bin_found}\n" version_string = `#{bin_found} #{config[:version_flag] || '--version'}` if (match = (config[:version] and version_string.match(config[:version]))) summary << " Version #{match[1]}\n" else summary << version_string.split(/\n/).collect { |s| " #{s}\n" }.join('') end else summary << " NOT FOUND\n" end end summary end |