restiny 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/restiny/manifest.rb +81 -96
- data/lib/restiny/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ad23e571d4f6b91fc296e0578074983f8d6883518ffe94743a6003bbf20dfd0
|
4
|
+
data.tar.gz: 6aba22d2cfb3a8bc2f8c93d0a11ccfef63a55eaa8aaec008a3b769710d4b3ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e600c2e4a0552420404dd6aa11692613e65cd6ee7efddc7a5200f8750569e39f259d5156b25fb8baca7175f7575b870794827213548e74877c7faeea23c18e75
|
7
|
+
data.tar.gz: 2e319308c54b1e793862400bc5ff362d0570924edf372d1f07a1f06766210e031dda2c79b7db8d171588d8dc8b849c482f6bb4d0ca86902e7d739bd6c831a410
|
data/lib/restiny/manifest.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string/literal: true
|
2
|
-
|
3
2
|
require 'down'
|
4
3
|
require 'json'
|
5
4
|
require 'sqlite3'
|
@@ -8,73 +7,91 @@ require 'zip'
|
|
8
7
|
module Restiny
|
9
8
|
class Manifest
|
10
9
|
TABLES = {
|
11
|
-
'
|
12
|
-
'
|
13
|
-
'
|
14
|
-
'
|
15
|
-
'
|
16
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
20
|
-
'
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'
|
24
|
-
'
|
25
|
-
'
|
26
|
-
'
|
27
|
-
'
|
28
|
-
'
|
29
|
-
'
|
30
|
-
'
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
34
|
-
'
|
35
|
-
'
|
36
|
-
'
|
37
|
-
'
|
38
|
-
'
|
39
|
-
'
|
40
|
-
'
|
41
|
-
'
|
42
|
-
'
|
43
|
-
'
|
44
|
-
'
|
45
|
-
'
|
46
|
-
'
|
47
|
-
'
|
48
|
-
'
|
49
|
-
'
|
50
|
-
'
|
51
|
-
'
|
52
|
-
'
|
53
|
-
'
|
54
|
-
'
|
55
|
-
'
|
56
|
-
'
|
57
|
-
'
|
58
|
-
'
|
59
|
-
'
|
60
|
-
'
|
61
|
-
'
|
62
|
-
'
|
63
|
-
'
|
64
|
-
'
|
65
|
-
'
|
66
|
-
'
|
10
|
+
'Achievement': { item: 'achievement', items: 'achievements' },
|
11
|
+
'Activity': { item: 'activity', items: 'activities' },
|
12
|
+
'ActivityGraph': { item: 'activity_graph', items: 'activity_graphs' },
|
13
|
+
'ActivityMode': { item: 'activity_modes', items: 'activity_modes' },
|
14
|
+
'ActivityModifier': { item: 'activity_modifier', items: 'activity_modifiers' },
|
15
|
+
'ActivityType': { item: 'activity_type', items: 'activity_types' },
|
16
|
+
'Artifact': { item: 'artifact', items: 'artifacts' },
|
17
|
+
'Bond': { item: 'bond', items: 'bonds' },
|
18
|
+
'BreakerType': { item: 'breaker_type', items: 'breaker_types' },
|
19
|
+
'Checklist': { item: 'checklist', items: 'checklists' },
|
20
|
+
'Class': { item: 'class', items: 'classes' },
|
21
|
+
'Collectible': { item: 'collectible', items: 'collectibles' },
|
22
|
+
'DamageType': { item: 'damage_type', items: 'damage_types' },
|
23
|
+
'Destination': { item: 'destination', items: 'destinations' },
|
24
|
+
'EnergyType': { item: 'energy_type', items: 'energy_types' },
|
25
|
+
'EquipmentSlot': { item: 'equipment_slot', items: 'equipment_slots' },
|
26
|
+
'EventCard': { item: 'event_card', items: 'event_cards' },
|
27
|
+
'Faction': { item: 'faction', items: 'factions' },
|
28
|
+
'Gender': { item: 'gender', items: 'genders' },
|
29
|
+
'HistoricalStats': { item: 'historical_stat', items: 'historical_stats' },
|
30
|
+
'InventoryBucket': { item: 'inventory_bucket', items: 'inventory_buckets' },
|
31
|
+
'InventoryItem': { item: 'inventory_item', items: 'inventory_items' },
|
32
|
+
'ItemCategory': { item: 'item_category', items: 'item_categories' },
|
33
|
+
'ItemTierType': { item: 'item_tier_type', items: 'item_tier_types' },
|
34
|
+
'Location': { item: 'location', items: 'locations' },
|
35
|
+
'Lore': { item: 'lore', items: 'lore_entries' },
|
36
|
+
'MaterialRequirementSet': { item: 'material_requirement_set', items: 'material_requirement_sets' },
|
37
|
+
'MedalTier': { item: 'medal_tier', items: 'medal_tiers' },
|
38
|
+
'Metric': { item: 'metric', items: 'metrics' },
|
39
|
+
'Milestone': { item: 'milestone', items: 'milestones' },
|
40
|
+
'Objective': { item: 'objective', items: 'objectives' },
|
41
|
+
'Place': { item: 'place', items: 'places' },
|
42
|
+
'PlugSet': { item: 'plug_set', items: 'plug_sets' },
|
43
|
+
'PowerCap': { item: 'power_cap', items: 'power_caps' },
|
44
|
+
'PresentationNode': { item: 'presentation_node', items: 'presentation_nodes' },
|
45
|
+
'Progression': { item: 'progression', items: 'progression_data' },
|
46
|
+
'ProgressionLevelRequirement': { item: 'progression_level_requirement', items: 'progression_level_requirements' },
|
47
|
+
'Race': { item: 'race', items: 'races' },
|
48
|
+
'Record': { item: 'record', items: 'records' },
|
49
|
+
'ReportReasonCategory': { item: 'report_reason_category', items: 'report_reason_categories' },
|
50
|
+
'RewardSource': { item: 'reward_source', items: 'reward_sources' },
|
51
|
+
'SackRewardItemList': { item: 'sack_reward_item_list', items: 'sack_reward_item_lists' },
|
52
|
+
'SandboxPattern': { item: 'sandbox_pattern', items: 'sandbox_patterns' },
|
53
|
+
'SandboxPerk': { item: 'sandbox_perk', items: 'sandbox_perks' },
|
54
|
+
'Season': { item: 'season', items: 'seasons' },
|
55
|
+
'SeasonPass': { item: 'season_pass', items: 'season_passes' },
|
56
|
+
'SocketCategory': { item: 'socket_category', items: 'socket_categories' },
|
57
|
+
'SocketType': { item: 'socket_type', items: 'socket_types' },
|
58
|
+
'Stat': { item: 'stat', items: 'stats' },
|
59
|
+
'StatGroup': { item: 'stat_group', items: 'stat_groups' },
|
60
|
+
'TalentGrid': { item: 'talent_grid', items: 'talent_grids' },
|
61
|
+
'TraitCategory': { item: 'trait_category', items: 'trait_categories' },
|
62
|
+
'Trait': { item: 'trait', items: 'traits' },
|
63
|
+
'Unlock': { item: 'unlock', items: 'unlocks' },
|
64
|
+
'Vendor': { item: 'vendor', items: 'vendors' },
|
65
|
+
'VendorGroup': { item: 'vendor_group', items: 'vendor_groups' }
|
67
66
|
}
|
68
67
|
|
69
68
|
attr_reader :file_path
|
70
69
|
|
71
70
|
TABLES.each do |table_name, method_names|
|
72
|
-
|
73
|
-
|
71
|
+
full_table_name = "Destiny#{table_name}Definition"
|
72
|
+
|
73
|
+
define_method method_names[:item] do |hash|
|
74
|
+
query = "SELECT json FROM #{full_table_name} WHERE json_extract(json, '$.hash')=?"
|
75
|
+
|
76
|
+
result = perform_query(query, [hash])
|
77
|
+
result = JSON.parse(result[0]['json']) unless result.nil?
|
74
78
|
end
|
75
79
|
|
76
|
-
define_method method_names[:items] do |limit: nil|
|
77
|
-
|
80
|
+
define_method method_names[:items] do |limit: nil, filter_empty: false, &block|
|
81
|
+
query = "SELECT json_extract(json, '$.hash') AS hash, json_extract(json, '$.displayProperties.name') AS name
|
82
|
+
FROM #{full_table_name} "
|
83
|
+
|
84
|
+
query << "WHERE json_extract(json, '$.displayProperties.name') IS NOT NULL " if filter_empty
|
85
|
+
query << "ORDER BY json_extract(json, '$.index')"
|
86
|
+
|
87
|
+
bindings = []
|
88
|
+
|
89
|
+
if limit
|
90
|
+
query << " LIMIT ?"
|
91
|
+
bindings << limit
|
92
|
+
end
|
93
|
+
|
94
|
+
perform_query(query, bindings)
|
78
95
|
end
|
79
96
|
end
|
80
97
|
|
@@ -102,42 +119,10 @@ module Restiny
|
|
102
119
|
|
103
120
|
private
|
104
121
|
|
105
|
-
def
|
106
|
-
|
107
|
-
row_hash.each_pair do |key, value|
|
108
|
-
key = key.gsub(/(\B[A-Z])/, '_\1') if key =~ /\B[A-Z]/
|
109
|
-
output[key.downcase] = if value.is_a?(Hash)
|
110
|
-
clean_row_keys(value)
|
111
|
-
elsif value.is_a?(Array)
|
112
|
-
value.map { |item| item.is_a?(Hash) ? clean_row_keys(item) : value }
|
113
|
-
else
|
114
|
-
value
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def query_table(table_name, id: nil, limit: nil)
|
121
|
-
query = "SELECT json FROM #{table_name}"
|
122
|
-
bindings = []
|
123
|
-
|
124
|
-
if id
|
125
|
-
query << " WHERE id=?"
|
126
|
-
bindings << id
|
127
|
-
end
|
128
|
-
|
129
|
-
query << " ORDER BY json_extract(json, '$.index')" unless id
|
130
|
-
|
131
|
-
if limit
|
132
|
-
query << " LIMIT ?"
|
133
|
-
bindings << limit
|
134
|
-
end
|
135
|
-
|
136
|
-
@database.execute(query, bindings).map do |row|
|
137
|
-
Manifest::clean_row_keys(JSON.parse(row['json'])) unless row['json'].nil?
|
138
|
-
end
|
122
|
+
def perform_query(query, bindings, &block)
|
123
|
+
@database.execute(query, bindings)
|
139
124
|
rescue SQLite3::Exception => e
|
140
|
-
raise Restiny::
|
125
|
+
raise Restiny::RequestError.new("Error while querying the manifest (#{e})")
|
141
126
|
end
|
142
127
|
end
|
143
128
|
end
|
data/lib/restiny/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restiny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bogan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|