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)
- - (Boolean) can_symlink?
- - (Object) find(arg) (also: #[])
- - (Object) path_for(arg)
- - (Object) update(inst_or_uninst)
- - (Object) update_all(gem_dir = Gem.dir)
- - (Object) version_for(arg)
Instance Method Details
- (Boolean) can_symlink?
76 77 78 79 80 81 82 83 |
# File 'lib/current_gem.rb', line 76 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: []
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/current_gem.rb', line 40 def find(arg) case arg when Gem::Installer, Gem::Uninstaller find_by_installer(arg) when Gem::Specification find_by_spec(arg) else find_by_name(arg) end end |
- (Object) path_for(arg)
53 54 55 56 |
# File 'lib/current_gem.rb', line 53 def path_for(arg) spec = find(arg) if can_symlink? current_path_for(spec) if spec end |
- (Object) update(inst_or_uninst)
63 64 65 |
# File 'lib/current_gem.rb', line 63 def update(inst_or_uninst) symlink(find(inst_or_uninst)) if can_symlink? end |
- (Object) update_all(gem_dir = Gem.dir)
67 68 69 70 71 72 73 74 |
# File 'lib/current_gem.rb', line 67 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)
58 59 60 61 |
# File 'lib/current_gem.rb', line 58 def version_for(arg) spec = find(arg) spec.version if spec end |