Module: Sprinkle::Verifiers::Ruby

Defined in:
lib/sprinkle/verifiers/ruby.rb

Overview

Ruby Verifiers

The verifiers in this module are ruby specific.

Instance Method Summary collapse

Instance Method Details

#has_gem(name, version = nil) ⇒ Object

Checks if a gem exists by calling “sudo gem list” and grepping against it.



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sprinkle/verifiers/ruby.rb', line 19

def has_gem(name, version=nil)
  name = name.to_s
  version = version.nil? ? '' : version.gsub('.', '\.')
  if RUBY_PLATFORM =~ /win32/
    command = "gem list | findstr /r /c:\"^#{name} (.*#{version}.*)$\""
    command << ' > NUL 2>&1' unless logger.debug?
  else
    command = "sudo gem list | grep -e '^#{name} (.*#{version}.*)$'"
  end
  @commands << command
end

#ruby_can_load(*files) ⇒ Object

Checks if ruby can require the files given. rubygems is always included first.



11
12
13
14
15
16
# File 'lib/sprinkle/verifiers/ruby.rb', line 11

def ruby_can_load(*files)
  # Always include rubygems first
  files = files.unshift('rubygems').collect { |x| "require '#{x}'" }
  
  @commands << "ruby -e \"#{files.join(';')}\""
end