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

SPEC_DIR =
ENV['CURRENT_GEM_SPEC_DIR'] || 'specifications'
CURR_DIR =
ENV['CURRENT_GEM_CURR_DIR'] || 'current'
FileUtils =
ENV['DRY_RUN'] ? ::FileUtils::DryRun : ::FileUtils
VERSION =
Version.to_s

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) can_symlink?



78
79
80
81
82
83
84
85
# File 'lib/current_gem.rb', line 78

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: []



45
46
47
48
49
50
51
# File 'lib/current_gem.rb', line 45

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)



55
56
57
58
# File 'lib/current_gem.rb', line 55

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

- (Object) update(installer)



65
66
67
# File 'lib/current_gem.rb', line 65

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

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



69
70
71
72
73
74
75
76
# File 'lib/current_gem.rb', line 69

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

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

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

- (Object) version_for(arg)



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

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