hsss 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
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 +14 -1
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d82312d9d40fe7749258fe1e917963eca868efe1f21a5867b24531c988d9f423
4
- data.tar.gz: ef2849d3bd39335bd3e1b19a10b61ca1c613230570db7b7a7792d0154d39943d
3
+ metadata.gz: ffc48f97f746816651fcaf8eecfb1bb572adabafd97059e64260dcc13d88c66d
4
+ data.tar.gz: ff6c1ccad571b8e13f0ac51503ab200799ef4ea39286f83a51f00d5c414e5426
5
5
  SHA512:
6
- metadata.gz: fe53ce199038e44561d0f6dab8e00472618b879a94089d9333b369c4229047870e43139abbe9f53ba2ccd44333255e39370f6f4ea52d96de2e542644dc090475
7
- data.tar.gz: 82aa9124e4bc30bd1b42de06715a89ae6af7344afeaf9be5e96d559116875d76c69412434b2d62e68e7ca7a5fb4d41d170b684ed78bf76350282b1b26b319875
6
+ metadata.gz: 43a0baa1f428595f27e48f93ee74ff8f6f0b2a60a719f51836af43f06eb9ec2ed33adde283e17dc602f8e1de44eb500d9a25c5af0282e5b04c080d530b7ddf2a
7
+ data.tar.gz: 7eaa26210dbeb3590cfd9dffbb976af7141c27e5b193640a06675c2807befaf34abf55b71c3e14f118aeaea5ef4a5fc8f0f35fedf21139bde35e4bf1768e8362
data/exe/hsss CHANGED
@@ -14,6 +14,8 @@ 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}
17
19
  opts.on("--each-macro [#{Hsss::DEFAULT_ITER_MACRO_NAME}]", "Iterator macro"){|v| opt[:iter_macro_name]=v}
18
20
  opts.on("--no-each", "Omit the iterator macro"){opt[:skip_each]=true}
19
21
  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.20"
2
+ VERSION = "0.1.21"
3
3
  end
data/lib/hsss.rb CHANGED
@@ -8,12 +8,13 @@ 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"
12
13
  DEFAULT_PREFIX="redis_"
13
14
 
14
15
  class COutput
15
16
  EXT="lua"
16
- attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name, :iter_macro_name, :row_struct_name
17
+ attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name, :count_macro_name, :iter_macro_name, :row_struct_name
17
18
 
18
19
  def cased_prefix(prefix, name)
19
20
  if name
@@ -34,6 +35,7 @@ module Hsss
34
35
  names_struct: DEFAULT_NAMES_NAME,
35
36
  scripts_struct: DEFAULT_SCRIPTS_NAME,
36
37
  count_name: DEFAULT_COUNT_NAME,
38
+ count_macro_name: DEFAULT_COUNT_MACRO_NAME,
37
39
  iter_macro_name: DEFAULT_ITER_MACRO_NAME}
38
40
 
39
41
  names.each do |var, default|
@@ -43,6 +45,7 @@ module Hsss
43
45
  @header_only = opt[:header_only]
44
46
  @data_only = opt[:data_only]
45
47
  @include_count = !opt[:skip_count]
48
+ @include_count_macro = !opt[:skip_count_macro]
46
49
  @include_iter_macro = !opt[:skip_each]
47
50
  @header_guard = opt[:header_guard] || "LUA_SCRIPTS_H"
48
51
  @header_guard = false if @header_guard.length == 0
@@ -86,6 +89,14 @@ module Hsss
86
89
  end
87
90
  end
88
91
 
92
+ def count_macro
93
+ if @include_count_macro
94
+ macro = "#define #{count_macro_name} #{@scripts.count}\n"
95
+ else
96
+ ""
97
+ end
98
+ end
99
+
89
100
  def check_script(path)
90
101
  ret = system "luac -p #{path}"
91
102
  @failed = true unless ret
@@ -161,6 +172,7 @@ module Hsss
161
172
  out << "//no scrpts\n"
162
173
  end
163
174
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
175
+ out << count_macro
164
176
  out << iter_macro
165
177
  end
166
178
 
@@ -248,6 +260,7 @@ module Hsss
248
260
  else
249
261
  out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
250
262
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
263
+ out << count_macro
251
264
  out << iter_macro
252
265
  end
253
266
  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.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo P.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2022-04-18 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.1.3
96
+ rubygems_version: 3.3.8
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Hash-Safe Script Splinterer