mmi 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b06278de132f8f2d3579987335931bdafe56470aef8641b7157b78922d12bd99
4
- data.tar.gz: 046a5c00f73f2ae5151411572978ef1af74662136d72a82ad30e2570e12c0523
3
+ metadata.gz: ac664a5f071c4eeb437b6e1f501130373baa722e3e97277bd627de91db6340b0
4
+ data.tar.gz: ec0937a098b99dd02302ee3c0256ad1d6e3e3e6f14e7ef72e76dfb7924e52beb
5
5
  SHA512:
6
- metadata.gz: 252ff8dcf6dfc7ece06c47300903e4bd3cf50ede5c7b82b8bcaf8ef7bdbd63b35f72a9a02d553c050e2a81fd17941523d7814435eb3c34e55f0071e6a073d1c5
7
- data.tar.gz: 57127da3df65211b4b4b1afa2899f404f95da5a9c14ba4067da24749ae5261ec6d0003d60e66d7f9eafcf3ad7b577b19b89600ef174e3d35276e64c79c5eb960
6
+ metadata.gz: 7eac5b99470ab80d174bdac020fd0f2872907d2bc2fc117ac102806d5dc6a2a58e410b6f96811376a0d8c32d8970c155b119ecf1d6620436211769b011676b4b
7
+ data.tar.gz: 600c32a227d7458a3f034e00c40347fd35bf11a4699f76ebd35521d9ee5a366e55740b70cfe8122ab96b468c9b985131cfc7218468231ed0c5c9edb8a04ce7ad
@@ -160,7 +160,18 @@ module Mmi
160
160
  end
161
161
  when Mmi::Source::Modrinth
162
162
  mod_version = CLI::UI::Prompt.ask('Choose a version.') do |handler|
163
- asset.cached_mod_versions.select do |version|
163
+ version_filter_parameters =
164
+ case processor.parsed_modloader
165
+ when Mmi::Modloader::Fabric
166
+ {
167
+ loader: 'fabric',
168
+ game_version: processor.parsed_modloader.mcversion,
169
+ }
170
+ else
171
+ {}
172
+ end
173
+
174
+ asset.cached_mod_versions(**version_filter_parameters).select do |version|
164
175
  version['files'].any?
165
176
  end.each do |version|
166
177
  handler.option("#{version['name']} (for game versions #{version['game_versions'].join('/')})") do
@@ -3,15 +3,11 @@ require 'open-uri'
3
3
 
4
4
  module Mmi
5
5
  module ModrinthApi
6
- BASE_URL = URI('https://api.modrinth.com/api/v1/')
6
+ BASE_URL = URI('https://api.modrinth.com/v2/')
7
7
 
8
8
  class << self
9
- def mod(name)
10
- JSON.parse((BASE_URL + "mod/#{CGI.escape(name)}").open.read)
11
- end
12
-
13
- def mod_versions(mod_id)
14
- JSON.parse((BASE_URL + "mod/#{mod_id}/version").open.read)
9
+ def project_versions(mod_slug, loader: nil, game_version: nil)
10
+ JSON.parse((BASE_URL + "project/#{mod_slug}/version?#{URI.encode_www_form(loaders: (%Q{["#{loader}"]} if loader), game_versions: (%Q{["#{game_version}"]} if game_version))}").open.read)
15
11
  end
16
12
  end
17
13
  end
@@ -42,18 +42,16 @@ module Mmi
42
42
  end
43
43
  end
44
44
 
45
- def cached_mod_id
46
- @cached_mod_id ||= Mmi::ModrinthApi.mod(self.name)['id']
47
- end
48
-
49
- def cached_mod_versions
50
- @cached_mod_versions ||= Mmi::ModrinthApi.mod_versions(cached_mod_id)
45
+ def cached_mod_versions(loader: nil, game_version: nil)
46
+ (@cached_mod_versions ||= Hash.new)[{loader: loader, game_version: game_version}] ||= Mmi::ModrinthApi.project_versions(self.name, loader: loader, game_version: game_version)
51
47
  end
52
48
 
53
49
  def download_url
54
50
  cached_mod_versions.select do |version|
55
51
  version['name'] == self.version
56
- end.first['files'].select do |files|
52
+ end.map do |version|
53
+ version['files']
54
+ end.flatten(1).select do |files|
57
55
  files['filename'] == self.version_file
58
56
  end.first['url'].gsub(/ /, '%20')
59
57
  end
data/lib/mmi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mmi
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mmi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - expeehaa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2024-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cli-ui
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '4.22'
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday-retry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: pry
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -185,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
199
  - !ruby/object:Gem::Version
186
200
  version: '0'
187
201
  requirements: []
188
- rubygems_version: 3.3.3
202
+ rubygems_version: 3.5.9
189
203
  signing_key:
190
204
  specification_version: 4
191
205
  summary: Program to install minecraft modloaders, mods and other assets through a