Icarus-Mod-Tools 1.8.2.1 → 2.0

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: f5300a7aec66d731f9bea8dfec09626928ff51e0e611b3a6173f9c2ed5c4ebd8
4
- data.tar.gz: c5bd016ddf8c8d4dd6631ae57c8202bed96ae4da587c8ab3999bbc5d656ed14d
3
+ metadata.gz: aba02b8c9f3f8a95dfaff8dc2a13914d9ec71153da336e2dc2ab954d6e5d6560
4
+ data.tar.gz: aad3f90f121957a893282dfc91cd424e21ecdbb155ecde1135f35644f86e8a3d
5
5
  SHA512:
6
- metadata.gz: 4a7f0fce56f5ce4471763c001895af4308deaeb7bee335c08d9bc350d79daaf2c3c23accc546213472f0047b3e45c3deab5fd6d15a338084ff0df3378bc9a0e7
7
- data.tar.gz: 4536666a6b5bbfd6ed61f0d3f97a6f05a33e377a5d7e211a4394e413c1721c6c0f312c774e04d926cb07075bfc5dbca7546f824c101568d343080fb6a266f8b6
6
+ metadata.gz: 54dd466afe7f4f01a2deb0999752cc298ee52a2b1f4da0e1abf26c82677ecabf1a9f293765dc081d6f5c5e05ea017c57da1cbf9ac114a287df922c8ab40ba696
7
+ data.tar.gz: b6f4a7bf87a62d190928cbf42ca57864c8651a2f7e353869e6221364f7f3e2c7ce59e51b69818636afe99c1ada9dfdbde4dcc29a43981b6caeab913856d1a779
data/CHANGES.md CHANGED
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## History (reverse chronological order)
6
6
 
7
+ ### v1.9 - 2023-01-28
8
+
9
+ - Renamed `Progs` to `Tools`
10
+
7
11
  ### v1.8 - 2023-01-27
8
12
 
9
13
  - Added support for `proginfo.json` files
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Icarus-Mod-Tools (1.8.2.1)
4
+ Icarus-Mod-Tools (2.0)
5
5
  google-cloud-firestore (~> 2.7)
6
6
  octokit (~> 6.0)
7
7
  paint (~> 2.3)
@@ -51,6 +51,7 @@ GEM
51
51
  gapic-common (>= 0.16.0, < 2.a)
52
52
  google-cloud-errors (~> 1.0)
53
53
  google-protobuf (3.21.12-x86_64-darwin)
54
+ google-protobuf (3.21.12-x86_64-linux)
54
55
  googleapis-common-protos (1.4.0)
55
56
  google-protobuf (~> 3.14)
56
57
  googleapis-common-protos-types (~> 1.2)
@@ -67,6 +68,9 @@ GEM
67
68
  grpc (1.51.0-x86_64-darwin)
68
69
  google-protobuf (~> 3.21)
69
70
  googleapis-common-protos-types (~> 1.0)
71
+ grpc (1.51.0-x86_64-linux)
72
+ google-protobuf (~> 3.21)
73
+ googleapis-common-protos-types (~> 1.0)
70
74
  guard (2.18.0)
71
75
  formatador (>= 0.2.4)
72
76
  listen (>= 2.7, < 4.0)
@@ -82,7 +86,7 @@ GEM
82
86
  guard-compat (~> 1.1)
83
87
  rspec (>= 2.99.0, < 4.0)
84
88
  json (2.6.3)
85
- jwt (2.6.0)
89
+ jwt (2.7.0)
86
90
  listen (3.8.0)
87
91
  rb-fsevent (~> 0.10, >= 0.10.3)
88
92
  rb-inotify (~> 0.9, >= 0.9.10)
data/README.md CHANGED
@@ -71,7 +71,7 @@ Options:
71
71
  Commands:
72
72
  imt add help [COMMAND] # Describe subcommands or one specific subcommand
73
73
  imt add modinfo # Adds an entry to 'meta/modinfo/list'
74
- imt add proginfo # Adds an entry to 'meta/proginfo/list'
74
+ imt add toolinfo # Adds an entry to 'meta/toolinfo/list'
75
75
  imt add repos # Adds an entry to 'meta/repos/list'
76
76
 
77
77
  Options:
@@ -89,8 +89,8 @@ Commands:
89
89
  imt list help [COMMAND] # Describe subcommands or one specific subcommand
90
90
  imt list modinfo # Displays data from 'meta/modinfo/list'
91
91
  imt list mods # Displays data from 'mods'
92
- imt list proginfo # Displays data from 'meta/proginfo/list'
93
- imt list progs # Displays data from 'progs'
92
+ imt list toolinfo # Displays data from 'meta/toolinfo/list'
93
+ imt list tools # Displays data from 'tools'
94
94
  imt list repos # Displays data from 'meta/repos/list'
95
95
 
96
96
  Options:
@@ -109,8 +109,8 @@ Commands:
109
109
  imt sync help [COMMAND] # Describe subcommands or one specific subcommand
110
110
  imt sync modinfo # Reads from 'meta/repos/list' and Syncs any modinfo files we find (github only for now)
111
111
  imt sync mods # Reads from 'meta/modinfo/list' and updates the 'mods' database accordingly
112
- imt sync proginfo # Reads from 'meta/repos/list' and Syncs any proginfo files we find (github only for now)
113
- imt sync progs # Reads from 'meta/proginfo/list' and updates the 'progs' database accordingly
112
+ imt sync toolinfo # Reads from 'meta/repos/list' and Syncs any toolinfo files we find (github only for now)
113
+ imt sync tools # Reads from 'meta/toolinfo/list' and updates the 'tools' database accordingly
114
114
 
115
115
  Options:
116
116
  -C, [--config=CONFIG] # Path to the config file
@@ -14,10 +14,10 @@
14
14
  },
15
15
  "collections": {
16
16
  "modinfo": "meta/modinfo",
17
- "proginfo": "meta/proginfo",
17
+ "toolinfo": "meta/toolinfo",
18
18
  "repositories": "meta/repos",
19
19
  "mods": "mods",
20
- "progs": "progs"
20
+ "tools": "tools"
21
21
  }
22
22
  },
23
23
  "github": {
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "firestore"
4
+ require "tools/modinfo"
4
5
 
5
6
  module Icarus
6
7
  module Mod
@@ -15,12 +16,12 @@ module Icarus
15
16
  puts firestore.update(:modinfo, payload, merge: true) ? "Success" : "Failure"
16
17
  end
17
18
 
18
- desc "proginfo", "Adds an entry to 'meta/proginfo/list'"
19
- def proginfo(item)
19
+ desc "toolinfo", "Adds an entry to 'meta/toolinfo/list'"
20
+ def toolinfo(item)
20
21
  firestore = Firestore.new
21
- payload = [firestore.list(:proginfo), item].flatten.compact
22
+ payload = [firestore.list(:toolinfo), item].flatten.compact
22
23
 
23
- puts firestore.update(:proginfo, payload, merge: true) ? "Success" : "Failure"
24
+ puts firestore.update(:toolinfo, payload, merge: true) ? "Success" : "Failure"
24
25
  end
25
26
 
26
27
  desc "repos", "Adds an entry to 'meta/repos/list'"
@@ -30,6 +31,29 @@ module Icarus
30
31
 
31
32
  puts firestore.update(:repositories, payload, merge: true) ? "Success" : "Failure"
32
33
  end
34
+
35
+ desc "mod", "Adds an entry to 'mods'"
36
+ method_option :modinfo, type: :string, required: true, default: "modinfo.json", desc: "Path to the modinfo.json file"
37
+ def mod
38
+ firestore = Firestore.new
39
+ data = options[:modinfo]
40
+
41
+ if data.nil? || !File.exist?(data)
42
+ warn "Invalid data file: #{data}"
43
+ exit 1
44
+ end
45
+
46
+ JSON.parse(File.read(data), symbolize_names: true)[:mods].each do |mod|
47
+ modinfo = Icarus::Mod::Tools::Modinfo.new(mod)
48
+
49
+ unless modinfo.valid?
50
+ warn "Invalid modinfo: #{modinfo.errors}"
51
+ exit 1
52
+ end
53
+
54
+ puts firestore.update(:mod, modinfo, merge: true) ? "Success" : "Failure"
55
+ end
56
+ end
33
57
  end
34
58
  end
35
59
  end
@@ -15,11 +15,11 @@ module Icarus
15
15
  puts "Total: #{modinfo_array.count}" if verbose > 1
16
16
  end
17
17
 
18
- desc "proginfo", "Displays data from 'meta/proginfo/list'"
19
- def proginfo
20
- proginfo_array = Firestore.new.list(:proginfo)
21
- puts proginfo_array
22
- puts "Total: #{proginfo_array.count}" if verbose > 1
18
+ desc "toolinfo", "Displays data from 'meta/toolinfo/list'"
19
+ def toolinfo
20
+ toolinfo_array = Firestore.new.list(:toolinfo)
21
+ puts toolinfo_array
22
+ puts "Total: #{toolinfo_array.count}" if verbose > 1
23
23
  end
24
24
 
25
25
  desc "repos", "Displays data from 'meta/repos/list'"
@@ -36,16 +36,16 @@ module Icarus
36
36
  list_for_type(:mods)
37
37
  end
38
38
 
39
- desc "progs", "Displays data from 'progs'"
39
+ desc "tools", "Displays data from 'tools'"
40
40
  method_option :sort, type: :string, default: "name", desc: "Sort by field (name, author, etc.)"
41
41
  method_option :filter, type: :array, default: [], desc: "Filter by field (name, author, etc.)"
42
- def progs
43
- list_for_type(:progs)
42
+ def tools
43
+ list_for_type(:tools)
44
44
  end
45
45
 
46
46
  no_commands do
47
47
  def list_for_type(type)
48
- klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Proginfo
48
+ klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Toolinfo
49
49
  valid_keys = klass::HASHKEYS + [:updated_at]
50
50
  sort_field = options[:sort]&.to_sym
51
51
  filter = !options[:filter].empty?
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "tools/sync/modinfo"
4
- require "tools/sync/proginfo"
3
+ require "tools/sync/modinfo_list"
4
+ require "tools/sync/toolinfo_list"
5
5
  require "tools/sync/mods"
6
- require "tools/sync/progs"
6
+ require "tools/sync/tools"
7
7
 
8
8
  module Icarus
9
9
  module Mod
@@ -17,11 +17,11 @@ module Icarus
17
17
 
18
18
  desc "all", "Run all sync jobs"
19
19
  def all
20
- puts "Running Proginfo Sync..." if verbose?
21
- invoke :proginfo
20
+ puts "Running Toolinfo Sync..." if verbose?
21
+ invoke :toolinfo
22
22
 
23
- puts "Running Progs Sync..." if verbose?
24
- invoke :progs
23
+ puts "Running Tools Sync..." if verbose?
24
+ invoke :tools
25
25
 
26
26
  puts "Running Modinfo Sync..." if verbose?
27
27
  invoke :modinfo
@@ -35,9 +35,9 @@ module Icarus
35
35
  sync_info(:modinfo)
36
36
  end
37
37
 
38
- desc "proginfo", "Reads from 'meta/repos/list' and Syncs any proginfo files we find (github only for now)"
39
- def proginfo
40
- sync_info(:proginfo)
38
+ desc "toolinfo", "Reads from 'meta/repos/list' and Syncs any toolinfo files we find (github only for now)"
39
+ def toolinfo
40
+ sync_info(:toolinfo)
41
41
  end
42
42
 
43
43
  desc "mods", "Reads from 'meta/modinfo/list' and updates the 'mods' database accordingly"
@@ -46,10 +46,10 @@ module Icarus
46
46
  sync_list(:mods)
47
47
  end
48
48
 
49
- desc "progs", "Reads from 'meta/proginfo/list' and updates the 'progs' database accordingly"
50
- method_option :check, type: :boolean, default: false, desc: "Validate proginfo without applying changes"
51
- def progs
52
- sync_list(:progs)
49
+ desc "tools", "Reads from 'meta/toolinfo/list' and updates the 'tools' database accordingly"
50
+ method_option :check, type: :boolean, default: false, desc: "Validate toolinfo without applying changes"
51
+ def tools
52
+ sync_list(:tools)
53
53
  end
54
54
 
55
55
  no_commands do
@@ -58,7 +58,7 @@ module Icarus
58
58
  end
59
59
 
60
60
  def sync_info(type)
61
- sync = (type == :modinfo ? Icarus::Mod::Tools::Sync::Modinfo : Icarus::Mod::Tools::Sync::Proginfo).new(client: firestore)
61
+ sync = (type == :modinfo ? Icarus::Mod::Tools::Sync::ModinfoList : Icarus::Mod::Tools::Sync::ToolinfoList).new(client: firestore)
62
62
 
63
63
  puts "Retrieving repository Data..." if verbose?
64
64
  repositories = sync.repositories
@@ -83,7 +83,9 @@ module Icarus
83
83
  end
84
84
 
85
85
  def sync_list(type)
86
- sync = (type == :mods ? Icarus::Mod::Tools::Sync::Mods : Icarus::Mod::Tools::Sync::Progs).new(client: firestore)
86
+ sync = (type == :mods ? Icarus::Mod::Tools::Sync::Mods : Icarus::Mod::Tools::Sync::Tools).new(client: firestore)
87
+
88
+ puts "Syncing #{type} to #{Config.firebase.collections.send(type)}" if verbose > 1
87
89
 
88
90
  puts "Retrieving Info Data..." if verbose?
89
91
  info_array = sync.info_array
@@ -12,9 +12,9 @@ module Icarus
12
12
  validate(:modinfo)
13
13
  end
14
14
 
15
- desc "proginfo", "Reads proginfo data from 'meta/proginfo/list' and Validates syntax of progfiles"
16
- def proginfo
17
- validate(:proginfo)
15
+ desc "toolinfo", "Reads Toolinfo data from 'meta/toolinfo/list' and Validates syntax of toolfiles"
16
+ def toolinfo
17
+ validate(:toolinfo)
18
18
  end
19
19
 
20
20
  no_commands do
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "google/cloud/firestore"
4
4
  require "tools/modinfo"
5
- require "tools/proginfo"
5
+ require "tools/toolinfo"
6
6
 
7
7
  module Icarus
8
8
  module Mod
@@ -23,16 +23,16 @@ module Icarus
23
23
  @modinfo ||= list(:modinfo)
24
24
  end
25
25
 
26
- def proginfo
27
- @proginfo ||= list(:proginfo)
26
+ def toolinfo
27
+ @toolinfo ||= list(:toolinfo)
28
28
  end
29
29
 
30
30
  def mods
31
31
  @mods ||= list(:mods)
32
32
  end
33
33
 
34
- def progs
35
- @progs ||= list(:progs)
34
+ def tools
35
+ @tools ||= list(:tools)
36
36
  end
37
37
 
38
38
  def find_by_type(type:, name:, author:)
@@ -47,11 +47,11 @@ module Icarus
47
47
 
48
48
  def list(type)
49
49
  case type.to_sym
50
- when :modinfo, :proginfo, :repositories
50
+ when :modinfo, :toolinfo, :repositories
51
51
  get_list(type)
52
- when :mods, :progs
52
+ when :mods, :tools
53
53
  @client.col(collections.send(type)).get.map do |doc|
54
- klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Proginfo
54
+ klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Toolinfo
55
55
  klass.new(doc.data, id: doc.document_id, created: doc.create_time, updated: doc.update_time)
56
56
  end
57
57
  else
@@ -71,12 +71,12 @@ module Icarus
71
71
  raise "You must specify a payload to update" if payload&.empty? || payload.nil?
72
72
 
73
73
  case type.to_sym
74
- when :modinfo, :proginfo
74
+ when :modinfo, :toolinfo
75
75
  update_array = (send(type) + [payload]).flatten.uniq
76
76
  response = @client.doc(collections.send(type)).set({ list: update_array }, merge:) if update_array.any?
77
77
  when :repositories
78
78
  response = @client.doc(collections.repositories).set({ list: payload }, merge:)
79
- when :mod, :prog
79
+ when :mod, :tool
80
80
  response = update_or_create(pluralize(type), payload, merge:)
81
81
  else
82
82
  raise "Invalid type: #{type}"
@@ -87,7 +87,7 @@ module Icarus
87
87
 
88
88
  def delete(type, payload)
89
89
  case type.to_sym
90
- when :mod, :prog
90
+ when :mod, :tool
91
91
  response = @client.doc("#{collections.send(pluralize(type))}/#{payload.id}").delete
92
92
  else
93
93
  raise "Invalid type: #{type}"
@@ -3,11 +3,11 @@
3
3
  module Icarus
4
4
  module Mod
5
5
  module Tools
6
- # Base class for Modinfo and Proginfo
6
+ # Base class for Modinfo and Toolinfo
7
7
  class Baseinfo
8
8
  attr_reader :data, :id, :created_at, :updated_at
9
9
 
10
- HASHKEYS = %i[name author version compatibility description fileType fileURL imageURL readmeURL].freeze
10
+ HASHKEYS = %i[name author version compatibility description files imageURL readmeURL].freeze
11
11
 
12
12
  def initialize(data, id: nil, created: nil, updated: nil)
13
13
  @id = id
@@ -52,14 +52,14 @@ module Icarus
52
52
  end
53
53
 
54
54
  def valid?
55
- @warnings << "Version should be a version string" unless validate_version(version)
55
+ validate_version
56
+ validate_files if @data.key?(:files)
57
+ validate_filetype(fileType) if @data.key?(:fileType)
56
58
 
57
59
  %w[name author description].each do |key|
58
60
  @errors << "#{key.capitalize} cannot be blank" unless validate_string(@data[key.to_sym])
59
61
  end
60
62
 
61
- @errors << "Invalid fileType: #{fileType || "blank"}" unless validate_filetype(fileType)
62
-
63
63
  %w[fileURL imageURL readmeURL].each do |key|
64
64
  @errors << "Invalid URL #{key.capitalize}: #{@data[key.to_sym] || "blank"}" unless validate_url(@data[key.to_sym])
65
65
  end
@@ -67,12 +67,20 @@ module Icarus
67
67
  !errors?
68
68
  end
69
69
 
70
+ def file_types
71
+ files&.keys || []
72
+ end
73
+
74
+ def file_urls
75
+ files&.values || []
76
+ end
77
+
70
78
  def method_missing(method_name, *_args, &_block)
71
- @data[method_name.to_sym]&.strip
79
+ @data[method_name.to_sym] if @data.keys.include?(method_name.to_sym)
72
80
  end
73
81
 
74
82
  def respond_to_missing?(method_name, include_private = false)
75
- HASHKEYS.include?(method_name.to_sym) || super
83
+ @data.keys.include?(method_name.to_sym) || super
76
84
  end
77
85
 
78
86
  private
@@ -81,22 +89,32 @@ module Icarus
81
89
  /(zip|pak|exmodz?)/i
82
90
  end
83
91
 
92
+ def validate_string(string)
93
+ !(string.nil? || string.empty?)
94
+ end
95
+
84
96
  def validate_url(url)
85
97
  return true if url.nil? || url.empty?
86
98
 
87
99
  url =~ URI::DEFAULT_PARSER.make_regexp
88
100
  end
89
101
 
90
- def validate_filetype(filetype)
91
- filetype.match?(filetype_pattern)
102
+ def validate_files
103
+ @errors << "files cannot be blank" if @data.key?(:files) && @data[:files].keys.empty?
104
+
105
+ file_types.each { |file_type| validate_filetype(file_type) }
106
+
107
+ file_urls.each do |file_url|
108
+ @errors << "Invalid URL: #{file_url}" unless validate_url(file_url)
109
+ end
92
110
  end
93
111
 
94
- def validate_string(string)
95
- !(string.nil? || string.empty?)
112
+ def validate_filetype(file_type)
113
+ @errors << "Invalid fileType: #{file_type.upcase}" unless file_type&.match?(filetype_pattern)
96
114
  end
97
115
 
98
- def validate_version(version)
99
- version =~ /\d+\.\d+[.\d+]?/
116
+ def validate_version
117
+ @warnings << "Version should be a version string" unless version =~ /^\d+[.\d+]*/
100
118
  end
101
119
  end
102
120
  end
@@ -7,7 +7,25 @@ module Icarus
7
7
  module Tools
8
8
  # Sync methods
9
9
  class Modinfo < Baseinfo
10
- HASHKEYS = %i[name author version compatibility description long_description fileType fileURL imageURL readmeURL].freeze
10
+ HASHKEYS = %i[name author version compatibility description long_description files fileType fileURL imageURL readmeURL].freeze
11
+
12
+ def to_h
13
+ HASHKEYS.each_with_object({}) do |key, hash|
14
+ next if key == :files && @data[:files].nil?
15
+ next if %i[fileType fileURL].include?(key.to_sym) && !@data[:files].nil?
16
+ next if key == :long_description && @data[:long_description].nil?
17
+
18
+ hash[key] = @data[key]
19
+ end
20
+ end
21
+
22
+ def file_types
23
+ files&.keys || [@data[:fileType] || "pak"]
24
+ end
25
+
26
+ def file_urls
27
+ files&.values || [@data[:fileURL]].compact
28
+ end
11
29
 
12
30
  # rubocop:disable Naming/MethodName
13
31
  def fileType
@@ -13,6 +13,8 @@ module Icarus
13
13
  # Sync helper methods
14
14
  module Helpers
15
15
  def retrieve_from_url(url)
16
+ raise RequestFailed, "Invalid URI: '#{url}'" unless url && url =~ URI::DEFAULT_PARSER.make_regexp
17
+
16
18
  res = Net::HTTP.get_response(URI(url))
17
19
 
18
20
  raise RequestFailed, "HTTP Request failed for #{url} (#{res.code}): #{res.message}" unless res&.code == "200"
@@ -9,7 +9,7 @@ module Icarus
9
9
  module Tools
10
10
  module Sync
11
11
  # Sync methods
12
- class Modinfo
12
+ class ModinfoList
13
13
  include Helpers
14
14
 
15
15
  def initialize(client: nil)
@@ -21,7 +21,7 @@ module Icarus
21
21
 
22
22
  def info_array
23
23
  @info_array ||= @firestore.modinfo.map do |url|
24
- retrieve_from_url(url)[:mods].map { |mod| Tools::Modinfo.new(mod) if mod[:name] =~ /[a-z0-9]+/i }
24
+ retrieve_from_url(url)[:mods].map { |mod| Icarus::Mod::Tools::Modinfo.new(mod) if mod[:name] =~ /[a-z0-9]+/i }
25
25
  rescue Icarus::Mod::Tools::Sync::RequestFailed
26
26
  warn "Skipped; Failed to retrieve #{url}"
27
27
  next
@@ -9,7 +9,7 @@ module Icarus
9
9
  module Tools
10
10
  module Sync
11
11
  # Sync methods
12
- class Proginfo
12
+ class ToolinfoList
13
13
  include Helpers
14
14
 
15
15
  def initialize(client: nil)
@@ -22,11 +22,11 @@ module Icarus
22
22
  @firestore.repos
23
23
  end
24
24
 
25
- def update(proginfo_array)
26
- @firestore.update(:proginfo, proginfo_array)
25
+ def update(toolinfo_array)
26
+ @firestore.update(:toolinfo, toolinfo_array)
27
27
  end
28
28
 
29
- def proginfo(url)
29
+ def toolinfo(url)
30
30
  retrieve_from_url(url)
31
31
  end
32
32
 
@@ -37,15 +37,15 @@ module Icarus
37
37
  case repo
38
38
  when /github/
39
39
  @github.repository = repo
40
- proginfo_url = @github.find("proginfo.json")
40
+ toolinfo_url = @github.find("toolinfo.json")
41
41
 
42
- unless proginfo_url
43
- puts "Skipped...no proginfo.json" if verbose
42
+ unless toolinfo_url
43
+ puts "Skipped...no toolinfo.json" if verbose
44
44
  next
45
45
  end
46
46
 
47
47
  puts "Found!" if verbose
48
- proginfo_url
48
+ toolinfo_url
49
49
  else
50
50
  puts "Skipped...repository type not supported yet" if verbose
51
51
  end
@@ -8,20 +8,22 @@ module Icarus
8
8
  module Tools
9
9
  module Sync
10
10
  # Sync methods
11
- class Progs
11
+ class Tools
12
12
  include Helpers
13
13
 
14
14
  def initialize(client: nil)
15
15
  @firestore = client || Firestore.new
16
16
  end
17
17
 
18
- def progs
19
- @firestore.progs
18
+ def tools
19
+ @firestore.tools
20
20
  end
21
21
 
22
22
  def info_array
23
- @info_array ||= @firestore.proginfo.map do |url|
24
- retrieve_from_url(url)[:programs].map { |prog| Tools::Proginfo.new(prog) if prog[:name] =~ /[a-z0-9]+/i }
23
+ @info_array ||= @firestore.toolinfo.map do |url|
24
+ next unless url
25
+
26
+ retrieve_from_url(url)[:tools].map { |tool| Icarus::Mod::Tools::Toolinfo.new(tool) if tool[:name] =~ /[a-z0-9]+/i }
25
27
  rescue Icarus::Mod::Tools::Sync::RequestFailed
26
28
  warn "Skipped; Failed to retrieve #{url}"
27
29
  next
@@ -31,20 +33,20 @@ module Icarus
31
33
  end.flatten.compact
32
34
  end
33
35
 
34
- def find(proginfo)
35
- @firestore.find_by_type(type: "progs", name: proginfo.name, author: proginfo.author)&.id
36
+ def find(toolinfo)
37
+ @firestore.find_by_type(type: "tools", name: toolinfo.name, author: toolinfo.author)&.id
36
38
  end
37
39
 
38
- def find_info(proginfo)
39
- @info_array.find { |prog| prog.name == proginfo.name }
40
+ def find_info(toolinfo)
41
+ @info_array.find { |tool| tool.name == toolinfo.name }
40
42
  end
41
43
 
42
- def update(proginfo)
43
- @firestore.update(:prog, proginfo, merge: false)
44
+ def update(toolinfo)
45
+ @firestore.update(:tool, toolinfo, merge: false)
44
46
  end
45
47
 
46
- def delete(proginfo)
47
- @firestore.delete(:prog, proginfo)
48
+ def delete(toolinfo)
49
+ @firestore.delete(:tool, toolinfo)
48
50
  end
49
51
  end
50
52
  end
@@ -6,7 +6,9 @@ module Icarus
6
6
  module Mod
7
7
  module Tools
8
8
  # Sync methods
9
- class Proginfo < Baseinfo
9
+ class Toolinfo < Baseinfo
10
+ HASHKEYS = %i[name author version compatibility description fileType fileURL imageURL readmeURL].freeze
11
+
10
12
  # rubocop:disable Naming/MethodName
11
13
  def fileType
12
14
  @data[:fileType] || "zip"
@@ -11,8 +11,8 @@ module Icarus
11
11
  @array = case type
12
12
  when :modinfo
13
13
  Sync::Mods.new.info_array
14
- when :proginfo
15
- Sync::Progs.new.info_array
14
+ when :toolinfo
15
+ Sync::Tools.new.info_array
16
16
  else
17
17
  raise ArgumentError, "Invalid type: #{type}"
18
18
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Icarus
4
4
  module Mod
5
- VERSION = "1.8.2.1"
5
+ VERSION = "2.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Icarus-Mod-Tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2.1
4
+ version: '2.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Donovan Young
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-28 00:00:00.000000000 Z
11
+ date: 2023-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-firestore
@@ -99,12 +99,12 @@ files:
99
99
  - lib/icarus/mod/tools.rb
100
100
  - lib/icarus/mod/tools/baseinfo.rb
101
101
  - lib/icarus/mod/tools/modinfo.rb
102
- - lib/icarus/mod/tools/proginfo.rb
103
102
  - lib/icarus/mod/tools/sync/helpers.rb
104
- - lib/icarus/mod/tools/sync/modinfo.rb
103
+ - lib/icarus/mod/tools/sync/modinfo_list.rb
105
104
  - lib/icarus/mod/tools/sync/mods.rb
106
- - lib/icarus/mod/tools/sync/proginfo.rb
107
- - lib/icarus/mod/tools/sync/progs.rb
105
+ - lib/icarus/mod/tools/sync/toolinfo_list.rb
106
+ - lib/icarus/mod/tools/sync/tools.rb
107
+ - lib/icarus/mod/tools/toolinfo.rb
108
108
  - lib/icarus/mod/tools/validator.rb
109
109
  - lib/icarus/mod/version.rb
110
110
  - sig/database/sync/sync.rbs