hsss 0.1.18 → 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 +5 -5
  2. data/exe/hsss +3 -0
  3. data/lib/hsss/version.rb +1 -1
  4. data/lib/hsss.rb +25 -3
  5. metadata +6 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b4cfbeb48000c60ccc92946c71bbefe9732e44c8
4
- data.tar.gz: 7dbb7590b50b940a18a3d01c74d401db53879c52
2
+ SHA256:
3
+ metadata.gz: ffc48f97f746816651fcaf8eecfb1bb572adabafd97059e64260dcc13d88c66d
4
+ data.tar.gz: ff6c1ccad571b8e13f0ac51503ab200799ef4ea39286f83a51f00d5c414e5426
5
5
  SHA512:
6
- metadata.gz: 4a1d6e92e2b97508cb32879d0be317c011e5343e702a7680cb725b911cf6cb4f96feda30d4a531aa22eac272a7ff77b90dce66ce24f667e67d18f8267bacd1db
7
- data.tar.gz: d4424e547089c26757f55337e494ef90e244b2a72f33f1043a2c6defd2e4a4dbeb41a5b9b9cff74dc644b1f0d9b95d8e323daf657b452d28d42f0018de778dcf
6
+ metadata.gz: 43a0baa1f428595f27e48f93ee74ff8f6f0b2a60a719f51836af43f06eb9ec2ed33adde283e17dc602f8e1de44eb500d9a25c5af0282e5b04c080d530b7ddf2a
7
+ data.tar.gz: 7eaa26210dbeb3590cfd9dffbb976af7141c27e5b193640a06675c2807befaf34abf55b71c3e14f118aeaea5ef4a5fc8f0f35fedf21139bde35e4bf1768e8362
data/exe/hsss CHANGED
@@ -14,11 +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}
24
+ opts.on("--header-guard [LUA_SCRIPTS_H]", "header guard string"){|v|opt[:header_guard]=v}
22
25
  opts.on("--data-only", "just the data"){opt[:data_only]=true}
23
26
  opts.on("--prefix [#{Hsss::DEFAULT_PREFIX}]", "Prefix default names with this"){|v| opt[:prefix]=v}
24
27
  end
data/lib/hsss/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hsss
2
- VERSION = "0.1.18"
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,7 +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]
50
+ @header_guard = opt[:header_guard] || "LUA_SCRIPTS_H"
51
+ @header_guard = false if @header_guard.length == 0
47
52
  @include_hash = !!hashes_struct
48
53
 
49
54
  (Array === files ? files : [ files ]).each do |f|
@@ -84,6 +89,14 @@ module Hsss
84
89
  end
85
90
  end
86
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
+
87
100
  def check_script(path)
88
101
  ret = system "luac -p #{path}"
89
102
  @failed = true unless ret
@@ -159,6 +172,7 @@ module Hsss
159
172
  out << "//no scrpts\n"
160
173
  end
161
174
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
175
+ out << count_macro
162
176
  out << iter_macro
163
177
  end
164
178
 
@@ -227,10 +241,17 @@ module Hsss
227
241
  scripties = nil
228
242
  end
229
243
  if @header_only
244
+ if @header_guard
245
+ out << "#ifndef #{@header_guard}\n"
246
+ out << "#define #{@header_guard}\n"
247
+ end
230
248
  out << sprintf(@headf, @struct.join("\n"))
231
- out << "#{@static}#{struct_name} #{scripts_struct};\n"
232
- 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
233
251
  out << iter_macro
252
+ if @header_guard
253
+ out << "\n#endif //#{@header_guard}\n"
254
+ end
234
255
  elsif @data_only
235
256
  out << "#{@static}#{struct_name} #{scripts_struct} = {\n"
236
257
  out << "#{scrapts.join(",\n\n")}\n"
@@ -239,6 +260,7 @@ module Hsss
239
260
  else
240
261
  out << sprintf(@cout, (@struct || []).join("\n"), (scrapts || []).join(",\n\n"))
241
262
  out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
263
+ out << count_macro
242
264
  out << iter_macro
243
265
  end
244
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.18
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo P.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-28 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
@@ -78,7 +78,7 @@ licenses:
78
78
  - MIT
79
79
  metadata:
80
80
  allowed_push_host: https://rubygems.org
81
- post_install_message:
81
+ post_install_message:
82
82
  rdoc_options: []
83
83
  require_paths:
84
84
  - lib
@@ -93,9 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
95
  requirements: []
96
- rubyforge_project:
97
- rubygems_version: 2.6.11
98
- signing_key:
96
+ rubygems_version: 3.3.8
97
+ signing_key:
99
98
  specification_version: 4
100
99
  summary: Hash-Safe Script Splinterer
101
100
  test_files: []