Module: OSGi::PackageResolvingStrategies

Defined in:
lib/buildr4osgi/osgi/resolving_strategies.rb

Overview

Functions declared on this module are used to select bundles exporting a particular package. Functions must have the signature (package, bundles)

where 
  package: the name of the package
  bundles: an array of bundles

Class Method Summary collapse

Class Method Details

.all(package, bundles) ⇒ Object

Default module function that selects all the matching bundles to the dependencies. This is the default function.



53
54
55
56
# File 'lib/buildr4osgi/osgi/resolving_strategies.rb', line 53

def all(package, bundles)
  warn "*** SPLIT PACKAGE: #{package} is exported by <#{bundles.join(", ")}>"
  return bundles
end

.prompt(package, bundles) ⇒ Object

Default module function that prompts the user to select the bundle(s) he’d like to select as dependencies.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/buildr4osgi/osgi/resolving_strategies.rb', line 29

def prompt(package, bundles)
  bundle = nil
  while (bundle.nil?)
    puts "This package #{package} is exported by all the bundles present.\n" +
          "Choose a bundle amongst those presented or press A to select them all:\n" + bundles.sort! {|a, b| a.version <=> b.version }.
    collect {|b| "\t#{bundles.index(b) +1}. #{b.name} #{b.version}"}.join("\n")
    number = $stdin.gets.chomp
    begin
      return bundles if (number == 'A')
      number = number.to_i
      number -= 1
      bundle = bundles[number] if number >= 0 # no negative indexing here.
      puts "Invalid index" if number < 0
    rescue Exception => e
      puts "Invalid index"
      #do nothing
    end
  end
  [bundle]
end