Icarus-Mod-Tools 1.3.2 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78fcf7a73092b07f142e4d227f108081a5dbadeeeef6a972ec1cb0f9ba064233
4
- data.tar.gz: 88139f274dcf2fc0a716cc17b58b8a7f89364aa7dd1f9f7209aafaa9280952fa
3
+ metadata.gz: 6116efa6067d7083fa0bd8702fa0b5e69f3fb5050b4fb9e8109c5d058e2b44ed
4
+ data.tar.gz: f9b7796983c16913ac855ff74c7cd519765a431678ab6d08f03fab14474d6e93
5
5
  SHA512:
6
- metadata.gz: 835fa42f41b672cc7b025f3aca5e58e39b398ea0ed38889b34094446c21c3611d06304936d42cea5fe8602563b2d70fa3adeda1114ae18023fd64fe335745267
7
- data.tar.gz: 2b315fb5e807cd0ba223544a1ffa47f5c64aa452228047f75e507b3522b4b9c85580c10b21c844bee1778978b66d42ca061a1b5ca2b4a28f20c2c3d386c0499f
6
+ metadata.gz: 22fedc2ac796efe006680fc5248c33fb01f003b03af14e59a1332fc586b7341dcdda36219e0ec0f00db9d5b790a1fe37062208c5d84ea604d585c391a32dc18c
7
+ data.tar.gz: ffc80856c30d74b07aa1b5255cfc304f9eb30d9b1277866d862f7ebb833db8cc04e16d67c6f784ad7b9257df8804183b4c6ded9586cfad8d99b93d4740acd6ce
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Icarus-Mod-Tools (1.3.2)
4
+ Icarus-Mod-Tools (1.3.4)
5
5
  google-cloud-firestore (~> 2.7)
6
6
  octokit (~> 6.0)
7
7
  thor (~> 1.2)
@@ -32,12 +32,12 @@ module Icarus
32
32
  filter_field = options[:filter].first&.to_sym
33
33
  filter_value = options[:filter].last&.to_s
34
34
 
35
- raise "Invalid filter option" unless options[:filter].empty? || options[:filter]&.count == 2
35
+ raise Icarus::Mod::Tools::Error, "Invalid filter option #{options[:filter]}" unless options[:filter].empty? || options[:filter]&.count == 2
36
36
 
37
- raise "Invalid filter field '#{filter_field}'" unless filter_field && valid_keys.include?(filter_field)
37
+ raise Icarus::Mod::Tools::Error, "Invalid filter field '#{filter_field}'" unless filter_field && valid_keys.include?(filter_field)
38
38
  end
39
39
 
40
- raise "Invalid sort field '#{sort_field}'" unless valid_keys.include?(sort_field)
40
+ raise Icarus::Mod::Tools::Error, "Invalid sort field '#{sort_field}'" unless valid_keys.include?(sort_field)
41
41
 
42
42
  puts "Sorted by #{sort_field}" if sort_field && verbose > 2
43
43
  puts "Filtered by #{filter_field} = #{filter_value}" if filter_field && verbose > 2
@@ -76,7 +76,7 @@ module Icarus
76
76
  end
77
77
 
78
78
  puts "Total: #{mods.count}" if verbose?
79
- rescue StandardError => e
79
+ rescue Icarus::Mod::Tools::Error => e
80
80
  puts e.message
81
81
  exit 1
82
82
  end
@@ -15,12 +15,12 @@ module Icarus
15
15
  puts "Retrieving repository Data..." if verbose?
16
16
  repositories = modinfo_sync.repositories
17
17
 
18
- raise "Unable to find any repositories!" unless repositories.any?
18
+ raise Icarus::Mod::Tools::Error, "Unable to find any repositories!" unless repositories.any?
19
19
 
20
20
  puts "Retrieving modinfo Array..." if verbose?
21
21
  modinfo_array = modinfo_sync.modinfo_data(repositories, verbose: verbose > 1)&.map(&:download_url)&.compact
22
22
 
23
- raise "Unable to find any modinfo.json files!" unless modinfo_array&.any?
23
+ raise Icarus::Mod::Tools::Error, "Unable to find any modinfo.json files!" unless modinfo_array&.any?
24
24
 
25
25
  puts "Saving to Firestore..." if verbose?
26
26
  response = modinfo_sync.update(modinfo_array)
@@ -67,6 +67,9 @@ module Icarus
67
67
  end
68
68
 
69
69
  puts "Deleted #{delete_array.count} outdated mods" if verbose?
70
+ rescue Icarus::Mod::Tools::Error => e
71
+ warn e.message
72
+ exit 1
70
73
  end
71
74
  end
72
75
  end
@@ -21,7 +21,10 @@ module Icarus
21
21
  def modinfo_array
22
22
  @modinfo_array ||= @firestore.modinfo_array.map do |url|
23
23
  retrieve_from_url(url)[:mods].map { |mod| Modinfo.new(mod) }
24
- end.flatten
24
+ rescue RequestFailed => e
25
+ warn "Failed to retrieve modinfo: #{e.message}"
26
+ next
27
+ end.flatten.compact
25
28
  end
26
29
 
27
30
  def find_mod(modinfo)
@@ -9,10 +9,12 @@ module Icarus
9
9
  module Tools
10
10
  # Sync helper methods
11
11
  module SyncHelpers
12
+ class RequestFailed < StandardError; end
13
+
12
14
  def retrieve_from_url(url)
13
15
  res = Net::HTTP.get_response(URI(url))
14
16
 
15
- raise "HTTP Request failed (#{res.code}): #{res.message}" unless res&.code == "200"
17
+ raise RequestFailed, "HTTP Request failed for #{url} (#{res.code}): #{res.message}" unless res&.code == "200"
16
18
 
17
19
  JSON.parse(res.body, symbolize_names: true)
18
20
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Icarus
4
4
  module Mod
5
- VERSION = "1.3.2"
5
+ VERSION = "1.3.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Icarus-Mod-Tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan Young