Created
May 30, 2023 04:37
-
-
Save sakuro/5f5c5e674808ac2e50e8ae0d029d5436 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
installed = { | |
mod_a: [ "1.0", "1.1", "1.2" ], | |
mod_b: [ "1.2" ], | |
} | |
wanted_to_use = { | |
mod_a: "1.1", | |
mod_b: "1.1", | |
mod_c: "1.2", | |
} | |
wanted_to_use.each do |mod, ver| | |
case installed.to_a | |
in [*, [^mod, [*, ^ver, *]], *] | |
puts "#{mod} is installed and version matches" | |
in [*, [^mod, _], *] | |
puts "#{mod} is installed and version does not match" | |
else | |
puts "#{mod} is not installed" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output