hsss 0.1.22 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/hsss +2 -0
- data/lib/hsss/version.rb +1 -1
- data/lib/hsss.rb +22 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b326a1ea17b5af3b409257a920bf4b34b3574fad92aa5bebd1b1e9936e10442
|
4
|
+
data.tar.gz: d4a828beb961c683c4c8b5b3c4edb08b080f76b99e7a385f7f30217ab6fe06a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aaa3566110eed57a52c527a9f81d464e4c79f44159449eb027b28c9c758a6f4a4a55ae0d4fe7fdb2fe5095a1502a48f12bce32dc955254bb3cbd6bfd1a39c75
|
7
|
+
data.tar.gz: 8b8da08b03629fbfd86cc4b5f7166d7fa17df28669f6b170826419ff13810e5a940b2083bed8bb6869fca4027d8862f36244e35ecdc59ea6c79d867fcfb14099
|
data/exe/hsss
CHANGED
@@ -16,6 +16,8 @@ arg=OptionParser.new do |opts|
|
|
16
16
|
opts.on("--no-count", "Omit script count variable"){opt[:skip_count]=true}
|
17
17
|
opts.on("--count-macro [#{Hsss::DEFAULT_COUNT_MACRO_NAME}]", "integer script count variable"){|v| opt[:count_macro_name]=v}
|
18
18
|
opts.on("--no-count-macro", "Omit script count variable"){opt[:skip_count_macro]=true}
|
19
|
+
opts.on("--all-hashes-string [#{Hsss::DEFAULT_ALL_HASHES_STRING_NAME}]", "all hashes string macro name"){|v| opt[:all_hashes_string_name]=v}
|
20
|
+
opts.on("--no-all-hashes-string", "Omit the string with all the script hashes"){opt[:skip_all_hashes_string]=true}
|
19
21
|
opts.on("--each-macro [#{Hsss::DEFAULT_ITER_MACRO_NAME}]", "Iterator macro"){|v| opt[:iter_macro_name]=v}
|
20
22
|
opts.on("--no-each", "Omit the iterator macro"){opt[:skip_each]=true}
|
21
23
|
opts.on("--no-parse", "Skip using luac to check script syntax"){opt[:no_luac]=true}
|
data/lib/hsss/version.rb
CHANGED
data/lib/hsss.rb
CHANGED
@@ -10,11 +10,12 @@ module Hsss
|
|
10
10
|
DEFAULT_COUNT_NAME="lua_scripts_count"
|
11
11
|
DEFAULT_COUNT_MACRO_NAME="LUA_SCRIPTS_COUNT"
|
12
12
|
DEFAULT_ITER_MACRO_NAME="LUA_SCRIPTS_EACH"
|
13
|
+
DEFAULT_ALL_HASHES_STRING_NAME="LUA_SCRIPTS_ALL_HASHES"
|
13
14
|
DEFAULT_PREFIX="redis_"
|
14
15
|
|
15
16
|
class COutput
|
16
17
|
EXT="lua"
|
17
|
-
attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name, :count_macro_name, :iter_macro_name, :row_struct_name
|
18
|
+
attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name, :count_macro_name, :all_hashes_string_name, :iter_macro_name, :row_struct_name
|
18
19
|
|
19
20
|
def cased_prefix(prefix, name)
|
20
21
|
if name
|
@@ -36,7 +37,9 @@ module Hsss
|
|
36
37
|
scripts_struct: DEFAULT_SCRIPTS_NAME,
|
37
38
|
count_name: DEFAULT_COUNT_NAME,
|
38
39
|
count_macro_name: DEFAULT_COUNT_MACRO_NAME,
|
39
|
-
iter_macro_name: DEFAULT_ITER_MACRO_NAME
|
40
|
+
iter_macro_name: DEFAULT_ITER_MACRO_NAME,
|
41
|
+
all_hashes_string_name: DEFAULT_ALL_HASHES_STRING_NAME,
|
42
|
+
}
|
40
43
|
|
41
44
|
names.each do |var, default|
|
42
45
|
send "#{var}=", opt[var]!=false ? opt[var] || cased_prefix(opt[:prefix], default) : false
|
@@ -47,6 +50,7 @@ module Hsss
|
|
47
50
|
@include_count = !opt[:skip_count]
|
48
51
|
@include_count_macro = !opt[:skip_count_macro]
|
49
52
|
@include_iter_macro = !opt[:skip_each]
|
53
|
+
@include_all_hashes_macro = !opt[:skip_all_hashes_string]
|
50
54
|
@header_guard = opt[:header_guard] || "LUA_SCRIPTS_H"
|
51
55
|
@header_guard = false if @header_guard.length == 0
|
52
56
|
@include_hash = !!hashes_struct
|
@@ -90,14 +94,22 @@ module Hsss
|
|
90
94
|
end
|
91
95
|
|
92
96
|
def count_macro
|
93
|
-
|
94
|
-
|
95
|
-
else
|
96
|
-
""
|
97
|
-
end
|
97
|
+
return "" unless @include_count_macro
|
98
|
+
"#define #{count_macro_name} #{@scripts.count}\n"
|
98
99
|
end
|
99
100
|
|
101
|
+
def all_hashes_string_macro
|
102
|
+
return "" unless @include_all_hashes_macro
|
103
|
+
"#define #{all_hashes_string_name} \"#{@hashed_table.join " "}\"\n"
|
104
|
+
end
|
105
|
+
|
100
106
|
def check_script(path)
|
107
|
+
luac_exists_ret = system "command -v luac &>/dev/null"
|
108
|
+
unless luac_exists_ret
|
109
|
+
@failed = true
|
110
|
+
STDERR.puts "luac is missing, cannot check script #{path}"
|
111
|
+
return false
|
112
|
+
end
|
101
113
|
ret = system "luac -p #{path}"
|
102
114
|
@failed = true unless ret
|
103
115
|
ret
|
@@ -172,6 +184,7 @@ module Hsss
|
|
172
184
|
out << "//no scrpts\n"
|
173
185
|
end
|
174
186
|
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
187
|
+
out << all_hashes_string_macro
|
175
188
|
out << count_macro
|
176
189
|
out << iter_macro
|
177
190
|
end
|
@@ -248,6 +261,7 @@ module Hsss
|
|
248
261
|
out << sprintf(@headf, @struct.join("\n"))
|
249
262
|
out << "extern #{@static}#{struct_name} #{scripts_struct};\n"
|
250
263
|
out << "extern const int #{@count_name};\n" if @include_count
|
264
|
+
out << all_hashes_string_macro
|
251
265
|
out << count_macro
|
252
266
|
out << iter_macro
|
253
267
|
if @header_guard
|
@@ -261,6 +275,7 @@ module Hsss
|
|
261
275
|
else
|
262
276
|
out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
|
263
277
|
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
278
|
+
out << all_hashes_string_macro
|
264
279
|
out << count_macro
|
265
280
|
out << iter_macro
|
266
281
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hsss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo P.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.3.
|
96
|
+
rubygems_version: 3.3.25
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Hash-Safe Script Splinterer
|