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?
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: []
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/current_gem.rb', line 42 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)
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(inst_or_uninst)
65 66 67 |
# File 'lib/current_gem.rb', line 65 def update(inst_or_uninst) symlink(find(inst_or_uninst)) 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) FU.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 |