hsss 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b7995c7ac8902ac28e088b5198e9d8d99b2d18e
4
- data.tar.gz: fc97fa7f070d4d7719aeb4fe165614533b778244
3
+ metadata.gz: c214ad328e8c64a680d183de71a3d70ecfc4033e
4
+ data.tar.gz: 8f94f9e93cceb204226fdfbe975d2d12473d5814
5
5
  SHA512:
6
- metadata.gz: 37ea09a827591c0cb921a04a1ea7633de8df7997df1910b70593dc60f0f416819a39e02566e6dbc1adddcea34a0a558d487c1f45f82afe6215e4336b00e05e6b
7
- data.tar.gz: 96e3d1e0011ede646153d37361a0b64edab1c2e6806b91628cadcb976ba8ddbfd8df62371535b1db4ed3c6e1fefee692073e608853838acb15d6d7eb3212c2d9
6
+ metadata.gz: 58c666e386a44a976090f939b9c88006909f3ab3cb2fb6f31a47294bf4193298b2e5af67195fbe2cc83f9cb4bad98c8b30f8f8627fcec05d2bb9bbfd196efdec
7
+ data.tar.gz: 36eb952a2a3ad64a5481895a715cecad71d10a1c0a9f534008bd1b5640ff6ce434334a29d1f0658464adbbdb2649ab3ace0b3c863e8858037c81dc56b46be992
data/exe/hsss CHANGED
@@ -10,6 +10,8 @@ arg=OptionParser.new do |opts|
10
10
  opts.on("--names [#{Hsss::DEFAULT_NAMES_NAME}]", "Script names variable"){|v| opt[:names_struct]=v}
11
11
  opts.on("--count [#{Hsss::DEFAULT_COUNT_NAME}]", "integer script count variable"){|v| opt[:count_name]=v}
12
12
  opts.on("--no-count", "Omit script count variable"){opt[:skip_count]=true}
13
+ opts.on("--each-macro [#{Hsss::DEFAULT_ITER_MACRO_NAME}]", "Iterator macro"){|v| opt[:iter_macro_name]=v}
14
+ opts.on("--no-each", "Omit the iterator macro"){opt[:skip_each]=true}
13
15
  opts.on("--no-parse", "Skip using luac to check script syntax"){opt[:no_luac]=true}
14
16
  opts.on("--prefix PREFIX", "Prefix default names with this"){|v| opt[:prefix]=v}
15
17
  end
@@ -18,6 +20,7 @@ Hash-Safe Script Splinterer, a Lua Script and hash embedder into C source.
18
20
  Good for putting Redis Lua scripts in your C headers.
19
21
  Usage: hsss [options] files
20
22
  EOS
23
+ arg.version=Hsss::VERSION
21
24
 
22
25
  rest = arg.parse!
23
26
 
data/hsss.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Leo P."]
10
10
  spec.email = ["junk@slact.net"]
11
11
 
12
- spec.summary = %q{Hash-Safe Script Splinter}
13
- spec.description = %q{Transforms Lua files into structs of C-strings and associated headers. Great for embedding Redis Lua scripts.}
12
+ spec.summary = %q{Hash-Safe Script Splinterer}
13
+ spec.description = %q{Hash-Safe Script Splinterer: Transforms Lua files into structs of C-strings and associated headers. Great for embedding Redis Lua scripts.}
14
14
  spec.homepage = "https://github.com/slact/hsss"
15
15
  spec.license = "MIT"
16
16
 
data/lib/hsss/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hsss
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
data/lib/hsss.rb CHANGED
@@ -7,11 +7,12 @@ module Hsss
7
7
  DEFAULT_NAMES_NAME="redis_lua_script_names"
8
8
  DEFAULT_SCRIPTS_NAME="redis_lua_scripts"
9
9
  DEFAULT_COUNT_NAME="redis_lua_scripts_count"
10
+ DEFAULT_ITER_MACRO_NAME="REDIS_LUA_SCRIPTS_EACH"
10
11
 
11
12
  class Hsss
12
13
  EXT="lua"
13
14
 
14
- attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name
15
+ attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name, :iter_macro_name
15
16
  def initialize(files, opt={})
16
17
  @scripts={}
17
18
 
@@ -19,7 +20,8 @@ module Hsss
19
20
  hashes_struct: DEFAULT_HASHES_NAME,
20
21
  names_struct: DEFAULT_NAMES_NAME,
21
22
  scripts_struct: DEFAULT_SCRIPTS_NAME,
22
- count_name: DEFAULT_COUNT_NAME}.each do |var, default|
23
+ count_name: DEFAULT_COUNT_NAME,
24
+ iter_macro_name: DEFAULT_ITER_MACRO_NAME}.each do |var, default|
23
25
  send "#{var}=", opt[var] || default
24
26
  end
25
27
 
@@ -29,6 +31,7 @@ module Hsss
29
31
  end
30
32
  end
31
33
  @include_count = !opt[:skip_count]
34
+ @include_iter_macro = !opt[:skip_each]
32
35
 
33
36
  (Array === files ? files : [ files ]).each do |f|
34
37
  begin
@@ -114,7 +117,15 @@ module Hsss
114
117
  out="//nothing here\n"
115
118
  end
116
119
 
117
- out<< "const int #{@count_name}=#{@scripts.count};\n" if @include_count
120
+ out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
121
+
122
+ if @include_iter_macro
123
+ macro = []
124
+ macro << "#define #{iter_macro_name}(script_src, script_name, script_hash) \\"
125
+ macro << "for((script_src)=(char **)&#{scripts_struct}, (script_hash)=(char **)&#{hashes_struct}, (script_name)=(char **)&#{names_struct}; (script_src) < (char **)(&#{scripts_struct} + 1); (script_src)++, (script_hash)++, (script_name)++) "
126
+ out << macro.join("\n")
127
+ end
128
+
118
129
  out
119
130
  end
120
131
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hsss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo P.
@@ -66,8 +66,8 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Transforms Lua files into structs of C-strings and associated headers.
70
- Great for embedding Redis Lua scripts.
69
+ description: 'Hash-Safe Script Splinterer: Transforms Lua files into structs of C-strings
70
+ and associated headers. Great for embedding Redis Lua scripts.'
71
71
  email:
72
72
  - junk@slact.net
73
73
  executables:
@@ -111,5 +111,5 @@ rubyforge_project:
111
111
  rubygems_version: 2.5.1
112
112
  signing_key:
113
113
  specification_version: 4
114
- summary: Hash-Safe Script Splinter
114
+ summary: Hash-Safe Script Splinterer
115
115
  test_files: []