Class: Nauvisian::CLI::Commands::Save::Mod::Sync::ExistingMods
- Inherits:
-
Object
- Object
- Nauvisian::CLI::Commands::Save::Mod::Sync::ExistingMods
- Includes:
- DownloadHelper, MessageHelper
- Defined in:
- lib/nauvisian/cli/commands/save/mod/sync.rb
Instance Method Summary collapse
- #exact? ⇒ Boolean
-
#initialize(mod_directory:, exact:, verbose:) ⇒ ExistingMods
constructor
A new instance of ExistingMods.
- #release_to_download(mod, version) ⇒ Object
- #verbose? ⇒ Boolean
Constructor Details
#initialize(mod_directory:, exact:, verbose:) ⇒ ExistingMods
Returns a new instance of ExistingMods.
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/nauvisian/cli/commands/save/mod/sync.rb', line 56 def initialize(mod_directory:, exact:, verbose:) @exact = exact @verbose = verbose zips = mod_directory.glob("*.zip") directories = mod_directory.entries.select(&:directory?) # [[mod, [version...]] @mods = [*zips, *directories].filter_map {|path| /(?<name>.*)_(?<version>\d+\.\d+\.\d+)(?:\.zip|$)\z/ =~ path.basename.to_s && [Nauvisian::Mod[name:], Nauvisian::Version24[version]] }.group_by(&:first).transform_values {|v| v.map(&:last) }.to_a end |
Instance Method Details
#exact? ⇒ Boolean
68 |
# File 'lib/nauvisian/cli/commands/save/mod/sync.rb', line 68 def exact? = @exact |
#release_to_download(mod, version) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/nauvisian/cli/commands/save/mod/sync.rb', line 71 def release_to_download(mod, version) "⚙ Checking #{mod.name} #{version} ... " # TODO: Take version requirement into consideration case @mods in [*, [^mod, [*, ^version, *]], *] "✓ Exact version (#{version}) exists, nothing to do" in [*, [^mod, [*versions]], *] if exact? "📥 some versions are installed but exact version (#{version}) is requested" find_release(mod, version:) elsif versions.all? {|v| v < version } "📥 all versions are older than the version in the save (#{version}), downloading the latest" find_release(mod) else "✓ newer version exists, nothing to do" end else "📥 MOD is not installed" exact? ? find_release(mod, version:) : find_release(mod) end end |
#verbose? ⇒ Boolean
69 |
# File 'lib/nauvisian/cli/commands/save/mod/sync.rb', line 69 def verbose? = @verbose |