Class: Dependencies::Repository
- Defined in:
- lib/bowline/dependencies/lib/dependencies/repository.rb
Instance Method Summary collapse
- #gem(name, versions = []) ⇒ Object
- #gems ⇒ Object
- #index ⇒ Object
-
#initialize(base) ⇒ Repository
constructor
A new instance of Repository.
- #install(gem) ⇒ Object
- #installed ⇒ Object
- #reload_index! ⇒ Object
- #search(gem) ⇒ Object
- #uninstall(name, version) ⇒ Object
Constructor Details
#initialize(base) ⇒ Repository
Returns a new instance of Repository.
3 4 5 6 7 8 9 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 3 def initialize(base) @paths = { :gems => File.join(base), :bin => File.join(base, 'bin'), :specs => File.join(base, 'specifications') } end |
Instance Method Details
#gem(name, versions = []) ⇒ Object
19 20 21 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 19 def gem(name, versions=[]) ::Gem::Dependency.new(name, versions) end |
#gems ⇒ Object
61 62 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 61 def gems end |
#index ⇒ Object
11 12 13 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 11 def index @index ||= reload_index! end |
#install(gem) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 27 def install(gem) reload_index! return if index.search(gem).last installer = ::Gem::DependencyInstaller.new( :bin_dir => @paths[:bin], :install_dir => @paths[:gems], :user_install => false) begin installer.install gem.name, gem.version_requirements rescue ::Gem::GemNotFoundException => e puts "Cannot find #{gem.name} #{gem.version_requirements}" rescue ::Gem::RemoteFetcher::FetchError => e puts "Problem with fetch, retrying..." retry end end |
#installed ⇒ Object
57 58 59 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 57 def installed Dir[File.join(@paths[:gems], 'gems', '*')].map! { |n| File.basename(n) } end |
#reload_index! ⇒ Object
15 16 17 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 15 def reload_index! @index = ::Gem::SourceIndex.new.load_gems_in(@paths[:specs]) end |
#search(gem) ⇒ Object
23 24 25 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 23 def search(gem) index.search(gem) end |
#uninstall(name, version) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bowline/dependencies/lib/dependencies/repository.rb', line 46 def uninstall(name, version) uninstaller = ::Gem::Uninstaller.new(name, :version => version, :bin_dir => @paths[:bin], :install_dir => @paths[:gems], :ignore => true, :executables => true ) uninstaller.uninstall end |