Icarus-Mod-Tools 1.3.1 → 1.3.3

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: daeaf600cc95360b7002385ce3c955b75ef0de606893bf5b73d34ce5d76dbba7
4
- data.tar.gz: 8ca92cb968f6d7f1cd23a14fc3a393b32d8acac0ac10039b91d8265a5a8bdd9d
3
+ metadata.gz: da25ba84ba4828a4e4124bda2485f6673a23993a390b0f674f83ce8c185282c3
4
+ data.tar.gz: 1e33e3d09e97954e5639f0a0f880bad54bd7e5a79c2d650f41d2ee80cb097159
5
5
  SHA512:
6
- metadata.gz: '094d0be08425875bbdc181e3a01f70b63b082e08903ab9d8da6795e0813c85102d34a0c37e37e7de4319f8ae7d37e372b37f2cb1f4a2669d873814a9c45f9211'
7
- data.tar.gz: c9904e4b40ba8f8bd72818146c8edfa9c07d9150152aa087e9c2aa13292fd20425b4ef85426dada71e99ada4983ac40c347889c8c2bafef9e508bf0e1ebd2ee2
6
+ metadata.gz: d915eb7c9846df40a57aef8474e2681ce7a5724ca3e1f04cb8a999f4eab9c3c557ae64445cac0a809874a067866c3ca3db2f29586294b93193ac2a20fe9f7009
7
+ data.tar.gz: 3fbea0d34dc3b5d4a5e457ad4092a00a5f1529405ea4461c3e4a79aff3b73ce3c332759ad4f1ac7cbfabad38e74f4ae3b8ee763e4cd3654bbb8d7fb805ca1f12
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Icarus-Mod-Tools (1.3.1)
4
+ Icarus-Mod-Tools (1.3.3)
5
5
  google-cloud-firestore (~> 2.7)
6
6
  octokit (~> 6.0)
7
7
  thor (~> 1.2)
@@ -23,15 +23,21 @@ module Icarus
23
23
  method_option :filter, type: :array, default: [], desc: "Filter by field (name, author, etc.)"
24
24
  def mods
25
25
  valid_keys = Icarus::Mod::Tools::Modinfo::HASHKEYS + [:updated_at]
26
- sort_field = options[:sort].to_sym
27
- filter_field = options[:filter].first.to_sym
28
- filter_value = options[:filter].last.to_s
29
26
 
30
- raise "Invalid filter option" unless options[:filter]&.count == 2
27
+ sort_field = options[:sort]&.to_sym
31
28
 
32
- raise "Invalid filter field '#{filter_field}'" unless filter_field && valid_keys.include?(filter_field)
29
+ filter = !options[:filter].empty?
33
30
 
34
- raise "Invalid sort field '#{sort_field}'" unless valid_keys.include?(sort_field)
31
+ if filter
32
+ filter_field = options[:filter].first&.to_sym
33
+ filter_value = options[:filter].last&.to_s
34
+
35
+ raise Icarus::Mod::Tools::Error, "Invalid filter option #{options[:filter]}" unless options[:filter].empty? || options[:filter]&.count == 2
36
+
37
+ raise Icarus::Mod::Tools::Error, "Invalid filter field '#{filter_field}'" unless filter_field && valid_keys.include?(filter_field)
38
+ end
39
+
40
+ raise Icarus::Mod::Tools::Error, "Invalid sort field '#{sort_field}'" unless valid_keys.include?(sort_field)
35
41
 
36
42
  puts "Sorted by #{sort_field}" if sort_field && verbose > 2
37
43
  puts "Filtered by #{filter_field} = #{filter_value}" if filter_field && verbose > 2
@@ -70,7 +76,7 @@ module Icarus
70
76
  end
71
77
 
72
78
  puts "Total: #{mods.count}" if verbose?
73
- rescue StandardError => e
79
+ rescue Icarus::Mod::Tools::Error => e
74
80
  puts e.message
75
81
  exit 1
76
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
@@ -12,7 +12,7 @@ module Icarus
12
12
  def retrieve_from_url(url)
13
13
  res = Net::HTTP.get_response(URI(url))
14
14
 
15
- raise "HTTP Request failed (#{res.code}): #{res.message}" unless res&.code == "200"
15
+ raise Icarus::Mod::Tools::Error, "HTTP Request failed for #{url} (#{res.code}): #{res.message}" unless res&.code == "200"
16
16
 
17
17
  JSON.parse(res.body, symbolize_names: true)
18
18
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Icarus
4
4
  module Mod
5
- VERSION = "1.3.1"
5
+ VERSION = "1.3.3"
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.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan Young