Class: BPM::Local

Inherits:
Repository show all
Defined in:
lib/bpm/local.rb

Instance Attribute Summary

Attributes inherited from Repository

#creds

Instance Method Summary collapse

Methods inherited from Repository

#dependency_for, #initialize, #logged_in?

Constructor Details

This class inherits a constructor from BPM::Repository

Instance Method Details

#installed(packages) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/bpm/local.rb', line 39

def installed(packages)
  specs = LibGems.source_index.search dependency_for(packages)

  specs.map do |spec|
    [spec.name, spec.version, spec.original_platform]
  end
end

#pack(path, email = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bpm/local.rb', line 12

def pack(path, email=nil)
  package_path = File.dirname(File.expand_path path)
  cur_pwd = Dir.pwd

  FileUtils.cd package_path if package_path != cur_pwd
  package = BPM::Package.new(nil, :email => (email || creds.email), :standalone => true)
  package.json_path = File.basename path
  
  
  if package.valid?
    silence do
      LibGems::Builder.new(package.to_spec).build
    end
  end

  FileUtils.cd cur_pwd if package_path != cur_pwd
  package
end

#preferred_version(package, vers) ⇒ Object



47
48
49
50
51
# File 'lib/bpm/local.rb', line 47

def preferred_version(package, vers)
  dep = LibGems::Dependency.new package, vers
  specs = LibGems.source_index.search dep
  specs.last.version.to_s
end

#source_root(package, vers) ⇒ Object



53
54
55
56
57
58
# File 'lib/bpm/local.rb', line 53

def source_root(package, vers)
  dep = LibGems::Dependency.new package, vers
  specs = LibGems.source_index.search dep
  spec = specs.last
  spec && File.join(spec.installation_path, 'gems', "#{spec.name}-#{spec.version}")
end

#uninstall(package) ⇒ Object



5
6
7
8
9
10
# File 'lib/bpm/local.rb', line 5

def uninstall(package)
  LibGems::Uninstaller.new(package).uninstall
  true
rescue LibGems::InstallError
  false
end

#unpack(path, target) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/bpm/local.rb', line 31

def unpack(path, target)
  package = BPM::Package.new
  package.fill_from_gemspec(path)
  unpack_dir = File.expand_path(File.join(Dir.pwd, target, package.full_name))
  LibGems::Installer.new(path, :unpack => true).unpack unpack_dir
  package
end