Class: AdobeCRX::UberPackage

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ UberPackage

Returns a new instance of UberPackage.



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

def initialize(name)
  @name = name
  @packages = []
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/adobe_crx/uber_package.rb', line 2

def name
  @name
end

#packagesObject

Returns the value of attribute packages.



2
3
4
# File 'lib/adobe_crx/uber_package.rb', line 2

def packages
  @packages
end

Class Method Details

.from_json(json) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adobe_crx/uber_package.rb', line 16

def self.from_json(json)
  data = JSON.parse(json)
  uber = AdobeCRX::UberPackage.new data['name']
  data['packages'].each do |p|
    package = AdobeCRX::Package.new p['name']
    uber.packages << package
    p['filters'].each do |f|
      filter = AdobeCRX::PackageFilter.new f['root']
      package.filters << filter
      f['rules'].each do |r|
        filter.rules << AdobeCRX::PackageFilterRule.new(r['modifier'], r['pattern'])
      end
    end
  end
  uber
end

Instance Method Details

#to_json(*a) ⇒ Object



9
10
11
12
13
14
# File 'lib/adobe_crx/uber_package.rb', line 9

def to_json(*a)
  {
    'name' => name,
    'packages' => packages
  }.to_json(*a)
end