Class: Depot::FlatpakRef
- Inherits:
-
Object
- Object
- Depot::FlatpakRef
- Defined in:
- lib/depot/packages/flatpak_ref.rb
Defined Under Namespace
Classes: FormatError
Constant Summary collapse
- GROUP =
"Flatpak Ref"- BOOLEAN_KEYS =
%w[IsRuntime].freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #branch ⇒ Object
- #display_name ⇒ Object
- #fields ⇒ Object
- #gpg_key? ⇒ Boolean
-
#initialize(path) ⇒ FlatpakRef
constructor
A new instance of FlatpakRef.
- #name ⇒ Object
- #remote_name ⇒ Object
- #runtime? ⇒ Boolean
- #runtime_repo ⇒ Object
- #title ⇒ Object
- #url ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ FlatpakRef
Returns a new instance of FlatpakRef.
10 11 12 |
# File 'lib/depot/packages/flatpak_ref.rb', line 10 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/depot/packages/flatpak_ref.rb', line 8 def path @path end |
Instance Method Details
#branch ⇒ Object
28 29 30 |
# File 'lib/depot/packages/flatpak_ref.rb', line 28 def branch fields["Branch"] || "master" end |
#display_name ⇒ Object
36 37 38 |
# File 'lib/depot/packages/flatpak_ref.rb', line 36 def display_name title.to_s.sub(/\s+from\s+\S+\z/i, "").then { |value| value.empty? ? name : value } end |
#fields ⇒ Object
20 21 22 |
# File 'lib/depot/packages/flatpak_ref.rb', line 20 def fields @fields ||= parse end |
#gpg_key? ⇒ Boolean
56 57 58 |
# File 'lib/depot/packages/flatpak_ref.rb', line 56 def gpg_key? fields["GPGKey"].to_s.strip != "" end |
#name ⇒ Object
24 25 26 |
# File 'lib/depot/packages/flatpak_ref.rb', line 24 def name fields["Name"] end |
#remote_name ⇒ Object
44 45 46 |
# File 'lib/depot/packages/flatpak_ref.rb', line 44 def remote_name fields["SuggestRemoteName"] end |
#runtime? ⇒ Boolean
40 41 42 |
# File 'lib/depot/packages/flatpak_ref.rb', line 40 def runtime? fields["IsRuntime"] == true end |
#runtime_repo ⇒ Object
52 53 54 |
# File 'lib/depot/packages/flatpak_ref.rb', line 52 def runtime_repo fields["RuntimeRepo"] end |
#title ⇒ Object
32 33 34 |
# File 'lib/depot/packages/flatpak_ref.rb', line 32 def title fields["Title"] end |
#url ⇒ Object
48 49 50 |
# File 'lib/depot/packages/flatpak_ref.rb', line 48 def url fields["Url"] end |
#valid? ⇒ Boolean
14 15 16 17 18 |
# File 'lib/depot/packages/flatpak_ref.rb', line 14 def valid? fields.fetch("Name", "").to_s != "" && fields.fetch("Url", "").to_s != "" rescue FormatError false end |