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 collapse
- 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
- #can_symlink? ⇒ Boolean
- #find(arg) ⇒ Object (also: #[])
- #path_for(arg) ⇒ Object
- #update(installer) ⇒ Object
- #update_all(gem_dir = Gem.dir) ⇒ Object
- #version_for(arg) ⇒ Object
Instance Method Details
#can_symlink? ⇒ Boolean
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 |
#find(arg) ⇒ Object 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 |
#path_for(arg) ⇒ Object
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 |
#update(installer) ⇒ Object
65 66 67 |
# File 'lib/current_gem.rb', line 65 def update(installer) symlink(find(installer)) if can_symlink? end |
#update_all(gem_dir = Gem.dir) ⇒ Object
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 |
#version_for(arg) ⇒ Object
60 61 62 63 |
# File 'lib/current_gem.rb', line 60 def version_for(arg) spec = find(arg) spec.version if spec end |