Module: CurrentGem

Extended by:
CurrentGem
Included in:
CurrentGem
Defined in:
lib/current_gem.rb,
lib/current_gem/version.rb

Defined Under Namespace

Modules: Version

Constant Summary

FU =
ENV['DRY_RUN'] ? FileUtils::DryRun : FileUtils
VERSION =
Version.to_s

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) can_symlink?



75
76
77
78
79
80
81
82
# File 'lib/current_gem.rb', line 75

def can_symlink?
  if Gem.win_platform?
    warn 'WARNING:  Unable to use symlinks on Windows, skipping...'
    false
  else
    true
  end
end

- (Object) find(arg) Also known as: []



42
43
44
45
46
47
48
# File 'lib/current_gem.rb', line 42

def find(arg)
  case arg
    when Gem::Installer, Gem::Uninstaller then find_by_installer(arg)
    when Gem::Specification               then find_by_spec(arg)
    else                                       find_by_name(arg)
  end
end

- (Object) path_for(arg)



52
53
54
55
# File 'lib/current_gem.rb', line 52

def path_for(arg)
  spec = find(arg) if can_symlink?
  current_path_for(spec) if spec
end

- (Object) update(inst_or_uninst)



62
63
64
# File 'lib/current_gem.rb', line 62

def update(inst_or_uninst)
  symlink(find(inst_or_uninst)) if can_symlink?
end

- (Object) update_all(gem_dir = Gem.dir)



66
67
68
69
70
71
72
73
# File 'lib/current_gem.rb', line 66

def update_all(gem_dir = Gem.dir)
  return unless can_symlink?

  path = base_path_for(gem_dir)
  FU.rm_r(path) if File.directory?(path)

  Gem::Specification.latest_specs.each { |spec| symlink(spec, path) }
end

- (Object) version_for(arg)



57
58
59
60
# File 'lib/current_gem.rb', line 57

def version_for(arg)
  spec = find(arg)
  spec.version if spec
end