Module: Merb::RakeHelper

Extended by:
GemManagement
Defined in:
lib/merb-core/tasks/merb_rake_helper.rb

Class Method Summary collapse

Methods included from GemManagement

clobber, ensure_bin_wrapper_for, ensure_bin_wrapper_for_installed_gems, install_gem, install_gem_from_cache, install_gem_from_source, install_pkg, package, package_all, partition_dependencies, rake, thor, uninstall_gem, which

Methods included from ColorfulMessages

#error, #info, #note, #success, #warning

Class Method Details

.install(name, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 8

def self.install(name, options = {})
  defaults = { :cache => false }
  defaults[:install_dir] = ENV['GEM_DIR'] if ENV['GEM_DIR']
  opts = defaults.merge(options)
  dir = if File.directory?(subdir = File.join(Dir.pwd, name))
    subdir
  else
    Dir.pwd
  end
  install_gem_from_source(dir, name, opts)
  ensure_wrapper(opts[:install_dir] || Gem.default_dir, name)
end

.install_package(pkg, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 21

def self.install_package(pkg, options = {})
  defaults = { :cache => false }
  defaults[:install_dir] = ENV['GEM_DIR'] if ENV['GEM_DIR']
  opts = defaults.merge(options)
  # Needs to be executed from the directory that contains all packages
  Dir.chdir(File.dirname(pkg_file = File.expand_path(pkg))) do 
    install_gem(pkg_file, opts)
  end
  name = File.basename(pkg, '.gem')[/^(.*?)-([\d\.]+)$/, 1]
  ensure_wrapper(opts[:install_dir] || Gem.default_dir, name)
end

.sudoObject



39
40
41
42
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 39

def self.sudo
  ENV['MERB_SUDO'] ||= "sudo"
  sudo = windows? ? "" : ENV['MERB_SUDO']
end

.uninstall(name, options = {}) ⇒ Object



33
34
35
36
37
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 33

def self.uninstall(name, options = {})
  defaults = { :ignore => true, :executables => true }
  defaults[:install_dir] = ENV['GEM_DIR'] if ENV['GEM_DIR']
  uninstall_gem(name, defaults.merge(options))
end

.windows?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/merb-core/tasks/merb_rake_helper.rb', line 44

def self.windows?
  (PLATFORM =~ /win32|cygwin/) rescue nil
end