Class: AppInfo::Protobuf::Manifest::IntentFilter

Inherits:
Node show all
Defined in:
lib/app_info/protobuf/manifest.rb

Constant Summary collapse

TYPES =

filter types (action is required, category and data are optional)

%w[action category data].freeze
%w[http https].freeze
CATEGORY_BROWSABLE =

browsable of category

'android.intent.category.BROWSABLE'

Instance Attribute Summary

Attributes inherited from Node

#attributes, #children, #name

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Helper::Defines

#create_class, #define_instance_method

Constructor Details

This class inherits a constructor from AppInfo::Protobuf::Base

Instance Method Details

#browsable?Boolean

Returns:

  • (Boolean)


206
207
208
# File 'lib/app_info/protobuf/manifest.rb', line 206

def browsable?
  exist?(CATEGORY_BROWSABLE)
end


186
187
188
189
190
191
192
# File 'lib/app_info/protobuf/manifest.rb', line 186

def deep_links
  return unless deep_links?

  data.reject { |d| d.host.nil? }
      .map(&:host)
      .uniq
end

#deep_links?Boolean

Returns:

  • (Boolean)


182
183
184
# File 'lib/app_info/protobuf/manifest.rb', line 182

def deep_links?
  browsable? && data.any? { |d| DEEP_LINK_SCHEMES.include?(d.scheme) }
end

#exist?(name, type: nil) ⇒ Boolean

Returns:

  • (Boolean)


210
211
212
213
214
215
216
217
218
219
220
# File 'lib/app_info/protobuf/manifest.rb', line 210

def exist?(name, type: nil)
  if type.to_s.empty? && !name.start_with?('android.intent.')
    raise 'Fill type or use correct name'
  end

  type ||= name.split('.')[2]
  raise 'Not found type' unless TYPES.include?(type)

  values = send(type.to_sym).select { |e| e.name == name }
  values.empty? ? false : values
end

#schemesObject



194
195
196
197
198
199
200
# File 'lib/app_info/protobuf/manifest.rb', line 194

def schemes
  return unless schemes?

  data.select { |d| !d.scheme.nil? && !DEEP_LINK_SCHEMES.include?(d.scheme) }
      .map(&:scheme)
      .uniq
end

#schemes?Boolean

Returns:

  • (Boolean)


202
203
204
# File 'lib/app_info/protobuf/manifest.rb', line 202

def schemes?
  browsable? && data.any? { |d| !DEEP_LINK_SCHEMES.include?(d.scheme) }
end