Sha256: a007fe62e73f118947e39a238e62ccb4fe8025ccbdffa962f8db95c9166f7739

Contents?: true

Size: 685 Bytes

Versions: 11

Compression:

Stored size: 685 Bytes

Contents

require 'oga'

module Dryrun

  class ManifestParser

    attr_accessor :package, :launcher_activity

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

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

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

    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

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dryrun-1.3.2 lib/dryrun/manifest_parser.rb
dryrun-1.3.0 lib/dryrun/manifest_parser.rb
dryrun-1.2.1 lib/dryrun/manifest_parser.rb
dryrun-1.2.0 lib/dryrun/manifest_parser.rb
dryrun-1.1.6 lib/dryrun/manifest_parser.rb
dryrun-1.1.5 lib/dryrun/manifest_parser.rb
dryrun-1.1.4 lib/dryrun/manifest_parser.rb
dryrun-1.1.3 lib/dryrun/manifest_parser.rb
dryrun-1.1.2 lib/dryrun/manifest_parser.rb
dryrun-1.1.1 lib/dryrun/manifest_parser.rb
dryrun-1.1.0 lib/dryrun/manifest_parser.rb