Class: PackageCloud::Validator
- Inherits:
-
Object
- Object
- PackageCloud::Validator
- Defined in:
- lib/package_cloud/validator.rb
Instance Method Summary collapse
- #distribution_id(repo, filenames, package_type) ⇒ Object
- #distribution_id_from_url(repo, filenames) ⇒ Object
-
#initialize(client) ⇒ Validator
constructor
A new instance of Validator.
Constructor Details
#initialize(client) ⇒ Validator
Returns a new instance of Validator.
3 4 5 |
# File 'lib/package_cloud/validator.rb', line 3 def initialize(client) @client = client end |
Instance Method Details
#distribution_id(repo, filenames, package_type) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/package_cloud/validator.rb', line 14 def distribution_id(repo, filenames, package_type) if distributions[package_type] _,_,dist_sel,ver_sel = repo.split("/") # These are all 'single version' distros if (dist_sel == "python" || dist_sel == "java" || dist_sel == "node" || dist_sel == "anyfile") dist = distributions[package_type].detect { |d| d["index_name"] == dist_sel } dist["versions"].first["id"] elsif dist_sel && ver_sel dist = distributions[package_type].detect { |d| d["index_name"] == dist_sel } if dist ver = dist["versions"].detect { |v| v["index_name"] == ver_sel || v["version_number"] == ver_sel } if ver ver["id"] else puts "#{ver_sel} isn't a valid version of #{dist["display_name"]}\n\n" select_dist(repo, filenames, package_type) end else puts "#{dist_sel} isn't a valid operating system.\n\n" select_dist(repo, filenames, package_type) end else puts "#{package_type} packages require an operating system and version to be selected.\n\n" select_dist(repo, filenames, package_type) end else nil end end |
#distribution_id_from_url(repo, filenames) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/package_cloud/validator.rb', line 7 def distribution_id_from_url(repo, filenames) _,_,dist_sel,ver_sel = repo.split("/") package_type = dist_sel puts "ambiguous extensions, so using repo url to deduce package_type, package_type: #{package_type}" distribution_id(repo, filenames, package_type) end |