svelte-on-rails 23.1.12 → 23.2.0
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f04dacbd659f04a33d94aaae3d17751a7ccbbe071b0aec6d88dfac7ba9820f9
|
|
4
|
+
data.tar.gz: 70a3562c852eaad7ca76078259417a51e5d823f7bd47d6c1726574b4b34bca5a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07eae817097ddc9f94c5a39f7dfc2878fcc3ffcdd86c6d07f0d805a9e8d7cabdfd63e3a8d14867d367d54a2c1e3a4cc006d47abddc76791d554ff8ec0c3afb78
|
|
7
|
+
data.tar.gz: e8e47d44da5e38081281828d2393b2b0efe7ffd5f40ca421e8f277faf7e132261dbc3783c7aa19bbff0ad17e555ce0f642af840f2f8accdd61738dd8f04b3ff7
|
|
@@ -39,11 +39,14 @@ module SvelteOnRails
|
|
|
39
39
|
associations.merge!(attr)
|
|
40
40
|
else
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
attr_s = attr.to_s
|
|
43
|
+
dot_index = attr_s.index('.')
|
|
44
|
+
_at = dot_index ? attr_s[0...dot_index].delete_suffix('&') : attr_s
|
|
45
|
+
if !model.method_defined?(_at) && !model.attribute_names.include?(_at)
|
|
46
|
+
raise "ERROR: Attribute or method «#{_at}» not found in model «#{_at}»"
|
|
44
47
|
end
|
|
45
48
|
@labels[key] ||= {}
|
|
46
|
-
@labels[key][
|
|
49
|
+
@labels[key][_at] ||= column_attributes(model, _at)
|
|
47
50
|
@labels[key]['self'] ||= model_attributes(model)
|
|
48
51
|
|
|
49
52
|
end
|
|
@@ -62,12 +62,11 @@ module SvelteOnRails
|
|
|
62
62
|
enums = record.class.try(:defined_enums) || {}
|
|
63
63
|
|
|
64
64
|
attributes.each do |attr|
|
|
65
|
-
validate_attribute!(record, attr)
|
|
66
65
|
|
|
67
66
|
key_s = attr.to_s
|
|
68
|
-
value = record
|
|
67
|
+
value = chained_send(record, key_s)
|
|
69
68
|
|
|
70
|
-
values[key_s] = enums.key?(key_s) ? record
|
|
69
|
+
values[key_s] = enums.key?(key_s) ? chained_send(record, key_s) : value
|
|
71
70
|
end
|
|
72
71
|
|
|
73
72
|
associations.each do |key, val|
|
|
@@ -119,12 +118,19 @@ module SvelteOnRails
|
|
|
119
118
|
obj.is_a?(ActiveRecord::Associations::CollectionProxy)) rescue false
|
|
120
119
|
end
|
|
121
120
|
|
|
122
|
-
def self.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
def self.chained_send(object, path)
|
|
122
|
+
calls = path.to_s.scan(/(&?\.)?([a-zA-Z_]\w*[!?=]?)/)
|
|
123
|
+
|
|
124
|
+
calls.reduce(object) do |current, (operator, method_name)|
|
|
125
|
+
return nil if operator == "&." && current.nil?
|
|
126
|
+
|
|
127
|
+
raise ArgumentError, "[SOR] Cannot call #{method_name} on nil" if current.nil?
|
|
128
|
+
|
|
129
|
+
unless current.respond_to?(method_name)
|
|
130
|
+
raise ArgumentError, "[SOR] No method #{method_name.inspect} on #{current.class}"
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
current.public_send(method_name)
|
|
128
134
|
end
|
|
129
135
|
end
|
|
130
136
|
end
|
data/lib/tasks/cache_tasks.rake
CHANGED
|
@@ -26,8 +26,6 @@ namespace :svelte_on_rails do
|
|
|
26
26
|
total_deleted = 0
|
|
27
27
|
batches = 0
|
|
28
28
|
|
|
29
|
-
puts "Scanning Redis for keys matching «#{pattern}» ..."
|
|
30
|
-
|
|
31
29
|
loop do
|
|
32
30
|
cursor, keys = redis.scan(cursor, match: pattern, count: 500)
|
|
33
31
|
if keys.any?
|
|
@@ -52,9 +50,11 @@ namespace :svelte_on_rails do
|
|
|
52
50
|
desc "Show all svelte-on-rails Redis keys with their memory footprint (scoped to redis_namespace). Env: LIMIT=n, SORT=size|key, PATTERN=extra-glob"
|
|
53
51
|
task show: :environment do
|
|
54
52
|
|
|
55
|
-
_entries = SvelteOnRails::Cache.redis_entries
|
|
53
|
+
_entries = SvelteOnRails::Cache.redis_entries(silent: true)
|
|
54
|
+
cnf = SvelteOnRails::Configuration.instance
|
|
56
55
|
|
|
57
56
|
if _entries.empty?
|
|
57
|
+
puts "No keys found for redis namespace «#{cnf.redis_namespace}»."
|
|
58
58
|
exit 0
|
|
59
59
|
end
|
|
60
60
|
|
|
@@ -84,11 +84,15 @@ namespace :svelte_on_rails do
|
|
|
84
84
|
desc "Show contents of cached keys"
|
|
85
85
|
task show_contents: :environment do
|
|
86
86
|
|
|
87
|
+
entries = SvelteOnRails::Cache.redis_entries(silent: true)
|
|
88
|
+
|
|
87
89
|
entries.each do |e|
|
|
90
|
+
puts
|
|
88
91
|
puts '='*120
|
|
89
92
|
puts "#{e[:key]} (#{human_bytes(e[:bytes])})"
|
|
90
93
|
puts '-'*120
|
|
91
94
|
puts SvelteOnRails::Configuration.instance.redis_instance.get(e[:key])
|
|
95
|
+
puts
|
|
92
96
|
end
|
|
93
97
|
|
|
94
98
|
end
|
|
@@ -96,6 +100,8 @@ namespace :svelte_on_rails do
|
|
|
96
100
|
desc "Show only the svelte part (wrapping div stripped away) of cached keys"
|
|
97
101
|
task show_svelte: :environment do
|
|
98
102
|
|
|
103
|
+
entries = SvelteOnRails::Cache.redis_entries(silent: true)
|
|
104
|
+
|
|
99
105
|
entries.each do |e|
|
|
100
106
|
|
|
101
107
|
ht = SvelteOnRails::Configuration.instance.redis_instance.get(e[:key])
|