Sha256: d7a0f8982e64ba5b8536ce61ddcbd6a60eb140a9cd1266e4d7f4ec5ed24b4b54

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

require 'rbconfig'



module Sidekick::Helpers::System
  def platform
    {
      :linux => /linux/,
      :darwin => /darwin/,
      :windows => /mswin|mingw|cygwin/
    }.each do |platform, regex|
      return platform if Config::CONFIG['host_os'] =~ regex
    end; :other
  end

  def gem_load?(gemname)
    begin
      require gemname
      true
    rescue LoadError; false; end
  end

  def needs(gem_name, reason)
    unless gem_load?(gem_name)
      ::Sidekick.stop "You must install the #{gem_name} gem #{reason}."
    end
  end

  def prefers(gem_name, reason)
    unless gem_load?(gem_name)
      log "Please install the #{gem_name} gem #{reason}."
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sidekick-0.6.0 lib/sidekick/helpers/system.rb