Class: AppInfo::Protobuf::Manifest::IntentFilter
- Inherits:
-
Node
- Object
- Base
- Node
- AppInfo::Protobuf::Manifest::IntentFilter
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
- DEEP_LINK_SCHEMES =
%w[http https].freeze
- CATEGORY_BROWSABLE =
'android.intent.category.BROWSABLE'
Instance Attribute Summary
Attributes inherited from Node
#attributes, #children, #name
Instance Method Summary
collapse
Methods inherited from Base
#initialize
#create_class, #define_instance_method
Instance Method Details
#browsable? ⇒ Boolean
218
219
220
|
# File 'lib/app_info/protobuf/manifest.rb', line 218
def browsable?
exist?(CATEGORY_BROWSABLE)
end
|
#deep_links ⇒ Object
196
197
198
199
200
201
202
|
# File 'lib/app_info/protobuf/manifest.rb', line 196
def deep_links
return unless deep_links?
data.reject { |d| d.host.nil? }
.map(&:host)
.uniq
end
|
#deep_links? ⇒ Boolean
190
191
192
193
194
|
# File 'lib/app_info/protobuf/manifest.rb', line 190
def deep_links?
return false unless respond_to?(:data)
browsable? && data.any? { |d| DEEP_LINK_SCHEMES.include?(d.scheme) }
end
|
#exist?(name, type: nil) ⇒ Boolean
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/app_info/protobuf/manifest.rb', line 222
def exist?(name, type: nil)
if type.to_s.empty? && !name.start_with?('android.intent.')
raise ProtobufParseError, 'Not found intent type'
end
type ||= name.split('.')[2]
raise ProtobufParseError, 'Not found intent type' unless TYPES.include?(type)
return false unless intent = send(type.to_sym)
values = intent.select { |e| e.name == name }
values.empty? ? false : values
end
|
#schemes ⇒ Object
210
211
212
213
214
215
216
|
# File 'lib/app_info/protobuf/manifest.rb', line 210
def schemes
return unless schemes?
data.select { |d| !d.scheme.nil? && !DEEP_LINK_SCHEMES.include?(d.scheme) }
.map(&:scheme)
.uniq
end
|
#schemes? ⇒ Boolean
204
205
206
207
208
|
# File 'lib/app_info/protobuf/manifest.rb', line 204
def schemes?
return false unless respond_to?(:data)
browsable? && data.any? { |d| !DEEP_LINK_SCHEMES.include?(d.scheme) }
end
|