Class: AdobeCRX::UberPackageManager

Inherits:
Object
  • Object
show all
Defined in:
lib/adobe_crx/uber_package_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ UberPackageManager

Returns a new instance of UberPackageManager.



4
5
6
# File 'lib/adobe_crx/uber_package_manager.rb', line 4

def initialize(client)
  @client = client
end

Instance Method Details

#export_uber_package(uber_package_definition, dest_dir = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/adobe_crx/uber_package_manager.rb', line 27

def export_uber_package(uber_package_definition, dest_dir = nil)
  manifest_file = File.open(uber_package_definition, "rb")
  uber = AdobeCRX::UberPackage.from_json manifest_file.read
  
  uber_dir = dest_dir ? dest_dir : "#{Dir.tmpdir}/uber_packages/#{uber.name}"
  FileUtils.mkpath uber_dir
  
  #export the packages to the uber_dir 
  uber.packages.each do |package|
    puts "exporting #{package.name}..."
    @client.export_package package, "#{uber_dir}/#{package.name}.zip"
  end
end

#generate_uber_package_definition(name, root_path, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/adobe_crx/uber_package_manager.rb', line 8

def generate_uber_package_definition(name, root_path, options = {})
  opts = {
    :target_package_size => 0,
    :root_package_depth => 1 #if 0, what's the point of creating an uber package?
  }.merge(options)
  
  root_node = get_node_structure(root_path, opts, 0)
  
  uber = AdobeCRX::UberPackage.new name
  root_package = AdobeCRX::Package.new "#{name}-root"
  uber.packages << root_package
  root_filter = AdobeCRX::PackageFilter.new root_path
  root_package.filters << root_filter
  root_package.properties[:size] = root_node.size
  process_node_for_uber(name, root_node, uber.packages, root_package, opts, 0)
  
  JSON.pretty_generate(JSON.parse(uber.to_json))
end

#import_uber_package(uber_package_definition, uber_package_dir) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/adobe_crx/uber_package_manager.rb', line 41

def import_uber_package(uber_package_definition, uber_package_dir)
  manifest_file = File.open(uber_package_definition, "rb")
  uber = AdobeCRX::UberPackage.from_json manifest_file.read
  
  #import the packages to the target crx instance
  uber.packages.each do |package|
    puts "importing #{package.name}..."
    p_file = "#{uber_package_dir}/#{package.name}.zip"
    if File.exist? p_file
      @client.import_package p_file
    else
      puts "ERROR: package does not exist at '#{p_file}'"
    end 
  end
end