hsss 0.1.20 → 0.1.23
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/exe/hsss +4 -0
- data/lib/hsss/version.rb +1 -1
- data/lib/hsss.rb +25 -2
- 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: cc0e8819378906c8db5c9effc4597d26e6137b9e7f8cc90d4d1205e31d9df882
|
4
|
+
data.tar.gz: 58cf88d785f92d50ce314674f586aa95c0f5767b20b22afb8c4eaf6942a35bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eea9225707ba4221fc8e0264284d601078184f434c6917b0528e447b4c7db9b29665e919469aa864eb7ba4ee7e2d4eb33014f194e88bf60d893a6711c9315597
|
7
|
+
data.tar.gz: d66dedb27e22754c3ce56ee8ee1d8ebaa3c3a04c33c0e7ce29617464871d69ab156a8b621b6b7e5c4af4a3289f7502ffb815376af339f2535df8be11b00f7a73
|
data/exe/hsss
CHANGED
@@ -14,6 +14,10 @@ arg=OptionParser.new do |opts|
|
|
14
14
|
opts.on("--no-names", "Omit script names variable (split format)"){opt[:names_struct]=false}
|
15
15
|
opts.on("--count [#{Hsss::DEFAULT_COUNT_NAME}]", "integer script count variable"){|v| opt[:count_name]=v}
|
16
16
|
opts.on("--no-count", "Omit script count variable"){opt[:skip_count]=true}
|
17
|
+
opts.on("--count-macro [#{Hsss::DEFAULT_COUNT_MACRO_NAME}]", "integer script count variable"){|v| opt[:count_macro_name]=v}
|
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}
|
17
21
|
opts.on("--each-macro [#{Hsss::DEFAULT_ITER_MACRO_NAME}]", "Iterator macro"){|v| opt[:iter_macro_name]=v}
|
18
22
|
opts.on("--no-each", "Omit the iterator macro"){opt[:skip_each]=true}
|
19
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
@@ -8,12 +8,14 @@ module Hsss
|
|
8
8
|
DEFAULT_NAMES_NAME="lua_script_names"
|
9
9
|
DEFAULT_SCRIPTS_NAME="lua_scripts"
|
10
10
|
DEFAULT_COUNT_NAME="lua_scripts_count"
|
11
|
+
DEFAULT_COUNT_MACRO_NAME="LUA_SCRIPTS_COUNT"
|
11
12
|
DEFAULT_ITER_MACRO_NAME="LUA_SCRIPTS_EACH"
|
13
|
+
DEFAULT_ALL_HASHES_STRING_NAME="LUA_SCRIPTS_ALL_HASHES"
|
12
14
|
DEFAULT_PREFIX="redis_"
|
13
15
|
|
14
16
|
class COutput
|
15
17
|
EXT="lua"
|
16
|
-
attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_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
|
17
19
|
|
18
20
|
def cased_prefix(prefix, name)
|
19
21
|
if name
|
@@ -34,7 +36,10 @@ module Hsss
|
|
34
36
|
names_struct: DEFAULT_NAMES_NAME,
|
35
37
|
scripts_struct: DEFAULT_SCRIPTS_NAME,
|
36
38
|
count_name: DEFAULT_COUNT_NAME,
|
37
|
-
|
39
|
+
count_macro_name: DEFAULT_COUNT_MACRO_NAME,
|
40
|
+
iter_macro_name: DEFAULT_ITER_MACRO_NAME,
|
41
|
+
all_hashes_string_name: DEFAULT_ALL_HASHES_STRING_NAME,
|
42
|
+
}
|
38
43
|
|
39
44
|
names.each do |var, default|
|
40
45
|
send "#{var}=", opt[var]!=false ? opt[var] || cased_prefix(opt[:prefix], default) : false
|
@@ -43,7 +48,9 @@ module Hsss
|
|
43
48
|
@header_only = opt[:header_only]
|
44
49
|
@data_only = opt[:data_only]
|
45
50
|
@include_count = !opt[:skip_count]
|
51
|
+
@include_count_macro = !opt[:skip_count_macro]
|
46
52
|
@include_iter_macro = !opt[:skip_each]
|
53
|
+
@include_all_hashes_macro = !opt[:skip_all_hashes_string]
|
47
54
|
@header_guard = opt[:header_guard] || "LUA_SCRIPTS_H"
|
48
55
|
@header_guard = false if @header_guard.length == 0
|
49
56
|
@include_hash = !!hashes_struct
|
@@ -86,6 +93,16 @@ module Hsss
|
|
86
93
|
end
|
87
94
|
end
|
88
95
|
|
96
|
+
def count_macro
|
97
|
+
return "" unless @include_count_macro
|
98
|
+
"#define #{count_macro_name} #{@scripts.count}\n"
|
99
|
+
end
|
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
|
+
|
89
106
|
def check_script(path)
|
90
107
|
ret = system "luac -p #{path}"
|
91
108
|
@failed = true unless ret
|
@@ -161,6 +178,8 @@ module Hsss
|
|
161
178
|
out << "//no scrpts\n"
|
162
179
|
end
|
163
180
|
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
181
|
+
out << all_hashes_string_macro
|
182
|
+
out << count_macro
|
164
183
|
out << iter_macro
|
165
184
|
end
|
166
185
|
|
@@ -236,6 +255,8 @@ module Hsss
|
|
236
255
|
out << sprintf(@headf, @struct.join("\n"))
|
237
256
|
out << "extern #{@static}#{struct_name} #{scripts_struct};\n"
|
238
257
|
out << "extern const int #{@count_name};\n" if @include_count
|
258
|
+
out << all_hashes_string_macro
|
259
|
+
out << count_macro
|
239
260
|
out << iter_macro
|
240
261
|
if @header_guard
|
241
262
|
out << "\n#endif //#{@header_guard}\n"
|
@@ -248,6 +269,8 @@ module Hsss
|
|
248
269
|
else
|
249
270
|
out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
|
250
271
|
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
272
|
+
out << all_hashes_string_macro
|
273
|
+
out << count_macro
|
251
274
|
out << iter_macro
|
252
275
|
end
|
253
276
|
out
|
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.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo P.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-19 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.
|
96
|
+
rubygems_version: 3.3.8
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Hash-Safe Script Splinterer
|