hsss 0.1.19 → 0.1.22

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 +3 -1
  3. data/lib/hsss/version.rb +1 -1
  4. data/lib/hsss.rb +20 -5
  5. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96bbfca29172fb609c9de7699b81e89c02e0b7539e63a5632f963e2202940031
4
- data.tar.gz: 210afcafd9fd2829ae7cc1865150acd329a175d9b9afc1506dd81d3bd10c9778
3
+ metadata.gz: ab9670f9e9bc65678262837155e1d719ff1229aacf60ddbb252dfc60db21e1e0
4
+ data.tar.gz: e3fb68fb25dcca408cade5e93428171c43954ae677b8246244740de15f2d0f06
5
5
  SHA512:
6
- metadata.gz: 1bcda4beaed9ffdd7f9d2e254da451dade55bed7861e6691029d987e0df6e4d469e74091649dbdb3aab77dfb05885c965f03131d7e26174148ecb03ef23aeaf9
7
- data.tar.gz: 2530fcf8cfcf4b7a5bff064097f16da2de02fc0db0ea32ba7c7270424b3adfa42854c7d4e561acd137aa79ef4fa0961e702cc67b71f51dc857891ff52758ee78
6
+ metadata.gz: 29fdbf0eea60e178839c45f95bcb8430cd0d1b195d66c6bb204c1bc7f884cf5004b77db99896b21bab01b6e68d3b1ca0194237dc1b6696786000709ff9f0cbe3
7
+ data.tar.gz: f72929dd7afcbf6ded15f647d71b6eb13b2adc23c574ae665e41b3984895df72479a87ca0f8064d564bb5d1c611fdef97ab2eca9895dd803273e7cfd2fc58f1f
data/exe/hsss CHANGED
@@ -14,12 +14,14 @@ 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}
20
22
  opts.on("--no-static", "Don't make variables static (file-scoped)"){opt[:no_static]=true}
21
23
  opts.on("--header-only", "just the header"){opt[:header_only]=true}
22
- opts.on("--header-guard", "header guard string"){|v|opt[:header_guard]=v}
24
+ opts.on("--header-guard [LUA_SCRIPTS_H]", "header guard string"){|v|opt[:header_guard]=v}
23
25
  opts.on("--data-only", "just the data"){opt[:data_only]=true}
24
26
  opts.on("--prefix [#{Hsss::DEFAULT_PREFIX}]", "Prefix default names with this"){|v| opt[:prefix]=v}
25
27
  end
data/lib/hsss/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hsss
2
- VERSION = "0.1.19"
2
+ VERSION = "0.1.22"
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,8 +45,10 @@ 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
- @header_guard = opt[:header_guard]
50
+ @header_guard = opt[:header_guard] || "LUA_SCRIPTS_H"
51
+ @header_guard = false if @header_guard.length == 0
48
52
  @include_hash = !!hashes_struct
49
53
 
50
54
  (Array === files ? files : [ files ]).each do |f|
@@ -85,6 +89,14 @@ module Hsss
85
89
  end
86
90
  end
87
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
+
88
100
  def check_script(path)
89
101
  ret = system "luac -p #{path}"
90
102
  @failed = true unless ret
@@ -160,6 +172,7 @@ module Hsss
160
172
  out << "//no scrpts\n"
161
173
  end
162
174
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
175
+ out << count_macro
163
176
  out << iter_macro
164
177
  end
165
178
 
@@ -233,11 +246,12 @@ module Hsss
233
246
  out << "#define #{@header_guard}\n"
234
247
  end
235
248
  out << sprintf(@headf, @struct.join("\n"))
236
- out << "#{@static}#{struct_name} #{scripts_struct};\n"
237
- out << "const int #{@count_name};\n" if @include_count
249
+ out << "extern #{@static}#{struct_name} #{scripts_struct};\n"
250
+ out << "extern const int #{@count_name};\n" if @include_count
251
+ out << count_macro
238
252
  out << iter_macro
239
253
  if @header_guard
240
- out << "#endif //#{@header_guard}\n"
254
+ out << "\n#endif //#{@header_guard}\n"
241
255
  end
242
256
  elsif @data_only
243
257
  out << "#{@static}#{struct_name} #{scripts_struct} = {\n"
@@ -247,6 +261,7 @@ module Hsss
247
261
  else
248
262
  out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
249
263
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
264
+ out << count_macro
250
265
  out << iter_macro
251
266
  end
252
267
  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.19
4
+ version: 0.1.22
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