Class: Icarus::Mod::Tools::Sync::Mods
- Inherits:
-
Object
- Object
- Icarus::Mod::Tools::Sync::Mods
- Includes:
- Helpers
- Defined in:
- lib/icarus/mod/tools/sync/mods.rb
Overview
Sync methods
Instance Method Summary collapse
- #delete(modinfo) ⇒ Object
- #find(modinfo) ⇒ Object
- #find_info(modinfo) ⇒ Object
- #info_array ⇒ Object
-
#initialize(client: nil) ⇒ Mods
constructor
A new instance of Mods.
- #mods ⇒ Object
- #update(modinfo) ⇒ Object
Methods included from Helpers
Constructor Details
Instance Method Details
#delete(modinfo) ⇒ Object
46 47 48 |
# File 'lib/icarus/mod/tools/sync/mods.rb', line 46 def delete(modinfo) @firestore.delete(:mod, modinfo) end |
#find(modinfo) ⇒ Object
34 35 36 |
# File 'lib/icarus/mod/tools/sync/mods.rb', line 34 def find(modinfo) @firestore.find_by_type(type: "mods", name: modinfo.name, author: modinfo.)&.id end |
#find_info(modinfo) ⇒ Object
38 39 40 |
# File 'lib/icarus/mod/tools/sync/mods.rb', line 38 def find_info(modinfo) @info_array.find { |mod| mod.name == modinfo.name } end |
#info_array ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/icarus/mod/tools/sync/mods.rb', line 22 def info_array @info_array ||= @firestore.modinfo.map do |url| retrieve_from_url(url)[:mods].map { |mod| Icarus::Mod::Tools::Modinfo.new(mod) if mod[:name].match?(/[a-z0-9]+/i) } rescue Icarus::Mod::Tools::Sync::RequestFailed warn "Skipped; Failed to retrieve #{url}" next rescue JSON::ParserError => e warn "Skipped; Invalid JSON: #{e.}" next end.flatten.compact end |
#mods ⇒ Object
18 19 20 |
# File 'lib/icarus/mod/tools/sync/mods.rb', line 18 def mods @firestore.mods end |
#update(modinfo) ⇒ Object
42 43 44 |
# File 'lib/icarus/mod/tools/sync/mods.rb', line 42 def update(modinfo) @firestore.update(:mod, modinfo, merge: false) end |