hsss 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -3
- data/exe/hsss +5 -2
- data/lib/hsss.rb +13 -15
- data/lib/hsss/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30090ea6931a2c431bd7c0df476eb4b761d84b8a
|
4
|
+
data.tar.gz: 6e666a9c89b623aa5ecbc6ea1219357a03013e8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 818b34ffb2ff332eaa50b75da63108f51b92f98c8579c48064e58a482182eb0ef0fa891d3488842c20743fb09e0905aca5b25ea3d8e0ea224308a79495cfb3ca
|
7
|
+
data.tar.gz: 44db3e7e91073b2af12e94c6e56d8f2375690e9c6acc75c1f63e930445d3b610dd0ae38e190ff7cfeaf26b257c6802702be496ba02537cf5d5530575f48bd677
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Hash-Safe Script Splinterer, a Lua Script and hash embedder into C source.
|
|
4
4
|
Good for putting Redis Lua scripts in your C headers.
|
5
5
|
```
|
6
6
|
Usage: hsss [options] files
|
7
|
-
--format [whole
|
7
|
+
--format [split|whole] Output as separate or a single struct
|
8
8
|
--struct [redis_lua_scripts_t]
|
9
9
|
C struct name
|
10
10
|
--row-struct [redis_lua_script_t]
|
@@ -12,8 +12,10 @@ Usage: hsss [options] files
|
|
12
12
|
--scripts [redis_lua_scripts]
|
13
13
|
Scripts variable (split or whole format)
|
14
14
|
--hashes [redis_lua_hashes] Hashes variable (split format)
|
15
|
+
--no-hashes Omit hashes variable (split format)
|
15
16
|
--names [redis_lua_script_names]
|
16
17
|
Script names variable (split format)
|
18
|
+
--no-names Omit script names variable (split format)
|
17
19
|
--count [redis_lua_scripts_count]
|
18
20
|
integer script count variable
|
19
21
|
--no-count Omit script count variable
|
@@ -21,6 +23,7 @@ Usage: hsss [options] files
|
|
21
23
|
Iterator macro
|
22
24
|
--no-each Omit the iterator macro
|
23
25
|
--no-parse Skip using luac to check script syntax
|
26
|
+
--no-static Don't make variables static (file-scoped)
|
24
27
|
--prefix PREFIX Prefix default names with this
|
25
28
|
```
|
26
29
|
|
@@ -43,7 +46,7 @@ redis.call('del', KEYS[1])
|
|
43
46
|
```
|
44
47
|
|
45
48
|
|
46
|
-
running `hsss example/*.lua` ("whole" format produces
|
49
|
+
running `hsss example/*.lua` ("whole" format) produces
|
47
50
|
```c
|
48
51
|
// don't edit this please, it was auto-generated by hsss
|
49
52
|
// https://github.com/slact/hsss
|
@@ -78,7 +81,7 @@ const int redis_lua_scripts_count=2;
|
|
78
81
|
for((script)=(redis_lua_script_t *)&redis_lua_scripts; (script) < (redis_lua_script_t *)(&redis_lua_scripts + 1); (script)++)
|
79
82
|
```
|
80
83
|
|
81
|
-
running `hsss --format split example/*.lua`
|
84
|
+
running `hsss --format split example/*.lua` produces
|
82
85
|
```c
|
83
86
|
// don't edit this please, it was auto-generated by hsss
|
84
87
|
// https://github.com/slact/hsss
|
data/exe/hsss
CHANGED
@@ -9,12 +9,15 @@ arg=OptionParser.new do |opts|
|
|
9
9
|
opts.on("--row-struct [#{Hsss::DEFAULT_ROW_STRUCT_NAME}]", "Hash+name+script struct for 'whole' format."){|v| opt[:row_struct_name]= v}
|
10
10
|
opts.on("--scripts [#{Hsss::DEFAULT_SCRIPTS_NAME}]", "Scripts variable (split or whole format)"){|v| opt[:scripts_struct]=v}
|
11
11
|
opts.on("--hashes [#{Hsss::DEFAULT_HASHES_NAME}]", "Hashes variable (split format)"){|v| opt[:hashes_struct]=v}
|
12
|
+
opts.on("--no-hashes", "Omit hashes variable (split format)"){opt[:hashes_struct]=false}
|
12
13
|
opts.on("--names [#{Hsss::DEFAULT_NAMES_NAME}]", "Script names variable (split format)"){|v| opt[:names_struct]=v}
|
14
|
+
opts.on("--no-names", "Omit script names variable (split format)"){opt[:names_struct]=false}
|
13
15
|
opts.on("--count [#{Hsss::DEFAULT_COUNT_NAME}]", "integer script count variable"){|v| opt[:count_name]=v}
|
14
16
|
opts.on("--no-count", "Omit script count variable"){opt[:skip_count]=true}
|
15
17
|
opts.on("--each-macro [#{Hsss::DEFAULT_ITER_MACRO_NAME}]", "Iterator macro"){|v| opt[:iter_macro_name]=v}
|
16
18
|
opts.on("--no-each", "Omit the iterator macro"){opt[:skip_each]=true}
|
17
19
|
opts.on("--no-parse", "Skip using luac to check script syntax"){opt[:no_luac]=true}
|
20
|
+
opts.on("--no-static", "Don't make variables static (file-scoped)"){opt[:no_static]=true}
|
18
21
|
opts.on("--prefix PREFIX", "Prefix default names with this"){|v| opt[:prefix]=v}
|
19
22
|
end
|
20
23
|
arg.banner=<<EOS
|
@@ -27,9 +30,9 @@ arg.version=Hsss::VERSION
|
|
27
30
|
rest = arg.parse!
|
28
31
|
|
29
32
|
case opt[:format]
|
30
|
-
when
|
33
|
+
when "split"
|
31
34
|
hsss = Hsss::CSplit.new(rest, opt)
|
32
|
-
when "whole"
|
35
|
+
when "whole", nil
|
33
36
|
hsss = Hsss::CWhole.new(rest, opt)
|
34
37
|
else
|
35
38
|
STDERR.puts "Invalid format #{opt[:format]}."
|
data/lib/hsss.rb
CHANGED
@@ -23,12 +23,12 @@ module Hsss
|
|
23
23
|
scripts_struct: DEFAULT_SCRIPTS_NAME,
|
24
24
|
count_name: DEFAULT_COUNT_NAME,
|
25
25
|
iter_macro_name: DEFAULT_ITER_MACRO_NAME}.each do |var, default|
|
26
|
-
send "#{var}=", opt[var] || default
|
26
|
+
send "#{var}=", opt[var]!=false ? opt[var] || default : false
|
27
27
|
end
|
28
28
|
|
29
29
|
if opt[:prefix]
|
30
30
|
[:struct_name, :hashes_struct, :names_struct, :scripts_struct].each do |var|
|
31
|
-
send "#{var}=", "#{opt[:prefix]}#{send var}"
|
31
|
+
send "#{var}=", "#{opt[:prefix]}#{send var}" if send(var)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
@include_count = !opt[:skip_count]
|
@@ -98,7 +98,7 @@ module Hsss
|
|
98
98
|
|
99
99
|
def initialize(files, opt={})
|
100
100
|
super
|
101
|
-
@
|
101
|
+
@head= <<-EOS.gsub(/^ {8}/, '')
|
102
102
|
// don't edit this please, it was auto-generated by hsss
|
103
103
|
// https://github.com/slact/hsss
|
104
104
|
|
@@ -106,15 +106,9 @@ module Hsss
|
|
106
106
|
%s
|
107
107
|
} #{struct_name};
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
}
|
112
|
-
|
113
|
-
static #{struct_name} #{names_struct} = {
|
114
|
-
%s
|
115
|
-
};
|
116
|
-
|
117
|
-
static #{struct_name} #{scripts_struct} = {
|
109
|
+
EOS
|
110
|
+
@struct_fmt= <<-EOS.gsub(/^ {8}/, '')
|
111
|
+
#{opt[:no_static] ? "" : "static "}#{struct_name} %s = {
|
118
112
|
%s
|
119
113
|
};
|
120
114
|
|
@@ -130,10 +124,14 @@ module Hsss
|
|
130
124
|
end
|
131
125
|
|
132
126
|
def to_s
|
127
|
+
out = ""
|
128
|
+
out << sprintf(@head, @struct.join("\n"))
|
133
129
|
if @scripts.count > 0
|
134
|
-
out
|
130
|
+
out << sprintf(@struct_fmt, hashes_struct, @hashed_table.map{|v|" \"#{v}\""}.join(",\n")) if hashes_struct
|
131
|
+
out << sprintf(@struct_fmt, names_struct, @name_table.map{|v|" \"#{v}\","}.join("\n")) if names_struct
|
132
|
+
out << sprintf(@struct_fmt, scripts_struct, @script_table.join(",\n\n")) if scripts_struct
|
135
133
|
else
|
136
|
-
out
|
134
|
+
out << "//no scrpts\n"
|
137
135
|
end
|
138
136
|
|
139
137
|
out << "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
@@ -172,7 +170,7 @@ module Hsss
|
|
172
170
|
%s
|
173
171
|
} #{struct_name};
|
174
172
|
|
175
|
-
static #{struct_name} #{scripts_struct} = {
|
173
|
+
#{opt[:no_static] ? "" : "static "}#{struct_name} #{scripts_struct} = {
|
176
174
|
%s
|
177
175
|
};
|
178
176
|
|
data/lib/hsss/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo P.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|