hsss 0.1.22 → 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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/exe/hsss +2 -0
  3. data/lib/hsss/version.rb +1 -1
  4. data/lib/hsss.rb +16 -7
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab9670f9e9bc65678262837155e1d719ff1229aacf60ddbb252dfc60db21e1e0
4
- data.tar.gz: e3fb68fb25dcca408cade5e93428171c43954ae677b8246244740de15f2d0f06
3
+ metadata.gz: cc0e8819378906c8db5c9effc4597d26e6137b9e7f8cc90d4d1205e31d9df882
4
+ data.tar.gz: 58cf88d785f92d50ce314674f586aa95c0f5767b20b22afb8c4eaf6942a35bf6
5
5
  SHA512:
6
- metadata.gz: 29fdbf0eea60e178839c45f95bcb8430cd0d1b195d66c6bb204c1bc7f884cf5004b77db99896b21bab01b6e68d3b1ca0194237dc1b6696786000709ff9f0cbe3
7
- data.tar.gz: f72929dd7afcbf6ded15f647d71b6eb13b2adc23c574ae665e41b3984895df72479a87ca0f8064d564bb5d1c611fdef97ab2eca9895dd803273e7cfd2fc58f1f
6
+ metadata.gz: eea9225707ba4221fc8e0264284d601078184f434c6917b0528e447b4c7db9b29665e919469aa864eb7ba4ee7e2d4eb33014f194e88bf60d893a6711c9315597
7
+ data.tar.gz: d66dedb27e22754c3ce56ee8ee1d8ebaa3c3a04c33c0e7ce29617464871d69ab156a8b621b6b7e5c4af4a3289f7502ffb815376af339f2535df8be11b00f7a73
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
@@ -1,3 +1,3 @@
1
1
  module Hsss
2
- VERSION = "0.1.22"
2
+ VERSION = "0.1.23"
3
3
  end
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,13 +94,15 @@ module Hsss
90
94
  end
91
95
 
92
96
  def count_macro
93
- if @include_count_macro
94
- macro = "#define #{count_macro_name} #{@scripts.count}\n"
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)
101
107
  ret = system "luac -p #{path}"
102
108
  @failed = true unless ret
@@ -172,6 +178,7 @@ module Hsss
172
178
  out << "//no scrpts\n"
173
179
  end
174
180
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
181
+ out << all_hashes_string_macro
175
182
  out << count_macro
176
183
  out << iter_macro
177
184
  end
@@ -248,6 +255,7 @@ module Hsss
248
255
  out << sprintf(@headf, @struct.join("\n"))
249
256
  out << "extern #{@static}#{struct_name} #{scripts_struct};\n"
250
257
  out << "extern const int #{@count_name};\n" if @include_count
258
+ out << all_hashes_string_macro
251
259
  out << count_macro
252
260
  out << iter_macro
253
261
  if @header_guard
@@ -261,6 +269,7 @@ module Hsss
261
269
  else
262
270
  out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
263
271
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
272
+ out << all_hashes_string_macro
264
273
  out << count_macro
265
274
  out << iter_macro
266
275
  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.22
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: 2022-04-18 00:00:00.000000000 Z
11
+ date: 2022-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler