Class: Dryrun::ManifestParser

Inherits:
Object
  • Object
show all
Defined in:
lib/dryrun/manifest_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest_file) ⇒ ManifestParser

Returns a new instance of ManifestParser.



9
10
11
12
13
14
# File 'lib/dryrun/manifest_parser.rb', line 9

def initialize(manifest_file)
  doc = Oga.parse_xml(manifest_file)

  @package = get_package(doc)
  @launcher_activity = get_launcher_activity(doc)
end

Instance Attribute Details

#launcher_activityObject

Returns the value of attribute launcher_activity.



7
8
9
# File 'lib/dryrun/manifest_parser.rb', line 7

def launcher_activity
  @launcher_activity
end

#packageObject

Returns the value of attribute package.



7
8
9
# File 'lib/dryrun/manifest_parser.rb', line 7

def package
  @package
end

Instance Method Details

#get_launcher_activity(doc) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dryrun/manifest_parser.rb', line 20

def get_launcher_activity(doc)
  activities = doc.css('activity')
  activities.each do |child|
    intent_filter = child.css('intent-filter')

    if !intent_filter.nil? && !intent_filter.empty?
      return child.attr('android:name').value
    end
  end
  false
end

#get_package(doc) ⇒ Object



16
17
18
# File 'lib/dryrun/manifest_parser.rb', line 16

def get_package(doc)
  doc.xpath('//manifest').attr('package').first.value
end