Icarus-Mod-Tools 2.0 → 2.0.1
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 +4 -4
- data/Gemfile.lock +3 -3
- data/lib/icarus/mod/cli/add.rb +3 -3
- data/lib/icarus/mod/cli/list.rb +4 -4
- data/lib/icarus/mod/firestore.rb +30 -31
- data/lib/icarus/mod/tools/sync/modinfo_list.rb +1 -1
- data/lib/icarus/mod/tools/sync/toolinfo_list.rb +1 -1
- data/lib/icarus/mod/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc9f1796a92ebce3c0cdac2b87012e3c411f2f04e2308dc725872daf08846416
|
4
|
+
data.tar.gz: 707de57a940c21f20f2c47853f8083a121fceed70b6a5d8bbc358038c608a805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11179ce087f3c5b1d6dc8d6a76758410513bba8d53a1a02a2b0fd44e3b3ab58c5a0f14c81667edfaffbdf129ea917bcb256b71a75a0b8bc2220ef3863ecfcb98
|
7
|
+
data.tar.gz: 45d746e5bd59b6342ec9cec813d72e520fbbc8d1cc55d41e8c725b745c377f3aaba135b56b746281a80f5a1588e66a9426a80026cf423c49a80c85f029f1d586
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
Icarus-Mod-Tools (2.0)
|
4
|
+
Icarus-Mod-Tools (2.0.1)
|
5
5
|
google-cloud-firestore (~> 2.7)
|
6
6
|
octokit (~> 6.0)
|
7
7
|
paint (~> 2.3)
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
google-cloud-env (1.6.0)
|
39
39
|
faraday (>= 0.17.3, < 3.0)
|
40
40
|
google-cloud-errors (1.3.0)
|
41
|
-
google-cloud-firestore (2.9.
|
41
|
+
google-cloud-firestore (2.9.1)
|
42
42
|
concurrent-ruby (~> 1.0)
|
43
43
|
google-cloud-core (~> 1.5)
|
44
44
|
google-cloud-firestore-v1 (~> 0.0)
|
@@ -122,7 +122,7 @@ GEM
|
|
122
122
|
rspec-core (~> 3.12.0)
|
123
123
|
rspec-expectations (~> 3.12.0)
|
124
124
|
rspec-mocks (~> 3.12.0)
|
125
|
-
rspec-core (3.12.
|
125
|
+
rspec-core (3.12.1)
|
126
126
|
rspec-support (~> 3.12.0)
|
127
127
|
rspec-expectations (3.12.2)
|
128
128
|
diff-lcs (>= 1.2.0, < 2.0)
|
data/lib/icarus/mod/cli/add.rb
CHANGED
@@ -11,7 +11,7 @@ module Icarus
|
|
11
11
|
desc "modinfo", "Adds an entry to 'meta/modinfo/list'"
|
12
12
|
def modinfo(item)
|
13
13
|
firestore = Firestore.new
|
14
|
-
payload = [firestore.
|
14
|
+
payload = [firestore.modinfo, item].flatten.compact
|
15
15
|
|
16
16
|
puts firestore.update(:modinfo, payload, merge: true) ? "Success" : "Failure"
|
17
17
|
end
|
@@ -19,7 +19,7 @@ module Icarus
|
|
19
19
|
desc "toolinfo", "Adds an entry to 'meta/toolinfo/list'"
|
20
20
|
def toolinfo(item)
|
21
21
|
firestore = Firestore.new
|
22
|
-
payload = [firestore.
|
22
|
+
payload = [firestore.toolinfo, item].flatten.compact
|
23
23
|
|
24
24
|
puts firestore.update(:toolinfo, payload, merge: true) ? "Success" : "Failure"
|
25
25
|
end
|
@@ -27,7 +27,7 @@ module Icarus
|
|
27
27
|
desc "repos", "Adds an entry to 'meta/repos/list'"
|
28
28
|
def repos(item)
|
29
29
|
firestore = Firestore.new
|
30
|
-
payload = [firestore.
|
30
|
+
payload = [firestore.repositories, item].flatten.compact
|
31
31
|
|
32
32
|
puts firestore.update(:repositories, payload, merge: true) ? "Success" : "Failure"
|
33
33
|
end
|
data/lib/icarus/mod/cli/list.rb
CHANGED
@@ -10,21 +10,21 @@ module Icarus
|
|
10
10
|
class List < SubcommandBase
|
11
11
|
desc "modinfo", "Displays data from 'meta/modinfo/list'"
|
12
12
|
def modinfo
|
13
|
-
modinfo_array = Firestore.new.
|
13
|
+
modinfo_array = Firestore.new.send(:modinfo)
|
14
14
|
puts modinfo_array
|
15
15
|
puts "Total: #{modinfo_array.count}" if verbose > 1
|
16
16
|
end
|
17
17
|
|
18
18
|
desc "toolinfo", "Displays data from 'meta/toolinfo/list'"
|
19
19
|
def toolinfo
|
20
|
-
toolinfo_array = Firestore.new.
|
20
|
+
toolinfo_array = Firestore.new.send(:toolinfo)
|
21
21
|
puts toolinfo_array
|
22
22
|
puts "Total: #{toolinfo_array.count}" if verbose > 1
|
23
23
|
end
|
24
24
|
|
25
25
|
desc "repos", "Displays data from 'meta/repos/list'"
|
26
26
|
def repos
|
27
|
-
repos = Firestore.new.
|
27
|
+
repos = Firestore.new.send(:repositories)
|
28
28
|
puts repos
|
29
29
|
puts "Total: #{repos.count}" if verbose > 1
|
30
30
|
end
|
@@ -64,7 +64,7 @@ module Icarus
|
|
64
64
|
puts "Sorted by #{sort_field}" if sort_field && verbose > 2
|
65
65
|
puts "Filtered by #{filter_field} = #{filter_value}" if filter_field && verbose > 2
|
66
66
|
|
67
|
-
items = Firestore.new.
|
67
|
+
items = Firestore.new.send(type)
|
68
68
|
|
69
69
|
# Filter by field
|
70
70
|
items.select! { |item| item.send(filter_field).downcase =~ /#{filter_value&.downcase}/ } if filter_field
|
data/lib/icarus/mod/firestore.rb
CHANGED
@@ -13,10 +13,15 @@ module Icarus
|
|
13
13
|
def initialize
|
14
14
|
@client = Google::Cloud::Firestore.new(credentials: Config.firebase.credentials.to_h)
|
15
15
|
@collections = Config.firebase.collections
|
16
|
+
@repositories = repositories
|
17
|
+
@modinfo = modinfo
|
18
|
+
@toolinfo = toolinfo
|
19
|
+
@mods = mods
|
20
|
+
@tools = tools
|
16
21
|
end
|
17
22
|
|
18
|
-
def
|
19
|
-
@
|
23
|
+
def repositories
|
24
|
+
@repositories ||= list(:repositories)
|
20
25
|
end
|
21
26
|
|
22
27
|
def modinfo
|
@@ -36,35 +41,7 @@ module Icarus
|
|
36
41
|
end
|
37
42
|
|
38
43
|
def find_by_type(type:, name:, author:)
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
def get_list(type)
|
43
|
-
raise "Invalid type: #{type} - unknown collection" unless collections.respond_to?(type)
|
44
|
-
|
45
|
-
@client.doc(collections.send(type)).get[:list]
|
46
|
-
end
|
47
|
-
|
48
|
-
def list(type)
|
49
|
-
case type.to_sym
|
50
|
-
when :modinfo, :toolinfo, :repositories
|
51
|
-
get_list(type)
|
52
|
-
when :mods, :tools
|
53
|
-
@client.col(collections.send(type)).get.map do |doc|
|
54
|
-
klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Toolinfo
|
55
|
-
klass.new(doc.data, id: doc.document_id, created: doc.create_time, updated: doc.update_time)
|
56
|
-
end
|
57
|
-
else
|
58
|
-
raise "Invalid type: #{type}"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def update_or_create(type, payload, merge:)
|
63
|
-
doc_id = payload.id || find_by_type(type:, name: payload.name, author: payload.author)&.id
|
64
|
-
|
65
|
-
return @client.doc("#{collections.send(type)}/#{doc_id}").set(payload.to_h, merge:) if doc_id
|
66
|
-
|
67
|
-
@client.col(collections.send(type)).add(payload.to_h)
|
44
|
+
instance_variable_get("@#{type}").find { |obj| obj.name == name && obj.author == author }
|
68
45
|
end
|
69
46
|
|
70
47
|
def update(type, payload, merge: false)
|
@@ -98,6 +75,28 @@ module Icarus
|
|
98
75
|
|
99
76
|
private
|
100
77
|
|
78
|
+
def list(type)
|
79
|
+
case type.to_sym
|
80
|
+
when :modinfo, :toolinfo, :repositories
|
81
|
+
@client.doc(collections.send(type)).get[:list]
|
82
|
+
when :mods, :tools
|
83
|
+
@client.col(collections.send(type)).get.map do |doc|
|
84
|
+
klass = type == :mods ? Icarus::Mod::Tools::Modinfo : Icarus::Mod::Tools::Toolinfo
|
85
|
+
klass.new(doc.data, id: doc.document_id, created: doc.create_time, updated: doc.update_time)
|
86
|
+
end
|
87
|
+
else
|
88
|
+
raise "Invalid type: #{type}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_or_create(type, payload, merge:)
|
93
|
+
doc_id = payload.id || find_by_type(type:, name: payload.name, author: payload.author)&.id
|
94
|
+
|
95
|
+
return @client.doc("#{collections.send(type)}/#{doc_id}").set(payload.to_h, merge:) if doc_id
|
96
|
+
|
97
|
+
@client.col(collections.send(type)).add(payload.to_h)
|
98
|
+
end
|
99
|
+
|
101
100
|
def pluralize(type)
|
102
101
|
type.to_s.end_with?("s") ? type.to_s : "#{type}s"
|
103
102
|
end
|
data/lib/icarus/mod/version.rb
CHANGED