Class: Railsmdb::CryptShared::Catalog Private
- Inherits:
-
Object
- Object
- Railsmdb::CryptShared::Catalog
- Defined in:
- lib/railsmdb/crypt_shared/catalog.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A utility method for querying a catalog listing.
Instance Attribute Summary collapse
-
#listing ⇒ Hash
readonly
private
The current listing.
Class Method Summary collapse
-
.current ⇒ Catalog
private
Return a Catalog instance representing the current listing.
Instance Method Summary collapse
-
#download_criteria ⇒ Hash
private
Returns the download criteria (arch/target/edition) for the current host.
-
#downloads(criteria = {}) {|Hash| ... } ⇒ Object
private
Queries the listing data using the given criteria, yielding the corresponding download data.
-
#initialize(listing) ⇒ Catalog
constructor
private
Create a new Catalog instance from the giving listing.
-
#optimal_download_url_for_this_host(which = 'crypt_shared') ⇒ Array<String, String>
private
Queries the listing for all downloads that match the platform criteria for the current host.
Constructor Details
#initialize(listing) ⇒ Catalog
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new Catalog instance from the giving listing.
27 28 29 |
# File 'lib/railsmdb/crypt_shared/catalog.rb', line 27 def initialize(listing) @listing = listing end |
Instance Attribute Details
#listing ⇒ Hash (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the current listing.
22 23 24 |
# File 'lib/railsmdb/crypt_shared/catalog.rb', line 22 def listing @listing end |
Class Method Details
.current ⇒ Catalog
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return a Catalog instance representing the current listing.
16 17 18 |
# File 'lib/railsmdb/crypt_shared/catalog.rb', line 16 def current new(Listing.fetch) end |
Instance Method Details
#download_criteria ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the download criteria (arch/target/edition) for the current host.
80 81 82 83 84 85 86 |
# File 'lib/railsmdb/crypt_shared/catalog.rb', line 80 def download_criteria { arch: platform_arch, target: platform_target, edition: 'enterprise' } end |
#downloads(criteria = {}) {|Hash| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Queries the listing data using the given criteria, yielding the corresponding download data.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/railsmdb/crypt_shared/catalog.rb', line 45 def downloads(criteria = {}) download_criteria = criteria.delete(:downloads) || {} listing['versions'].each do |version| next unless hash_matches?(version, criteria) version['downloads'].each do |download| next unless hash_matches?(download, download_criteria) yield download end end self end |
#optimal_download_url_for_this_host(which = 'crypt_shared') ⇒ Array<String, String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Queries the listing for all downloads that match the platform criteria for the current host.
68 69 70 71 72 73 74 |
# File 'lib/railsmdb/crypt_shared/catalog.rb', line 68 def optimal_download_url_for_this_host(which = 'crypt_shared') downloads(production_release: true, downloads: download_criteria) do |dl| return [ dl[which]['url'], dl[which]['sha256'] ] end nil end |