hsss 0.1.1 → 0.1.2
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.
- checksums.yaml +4 -4
- data/exe/hsss +2 -0
- data/lib/hsss/version.rb +1 -1
- data/lib/hsss.rb +9 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a272e42a10b7a98238cae56b00cf7902ccd319
|
4
|
+
data.tar.gz: 1848f5e3f163ac181bff90e93d2e26e2225cd308
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa8a75586ff0d0dcc1f2adac6e25653feb3a5d676d85b622240130e71da95075cb8fb90b0b6ba64791cf7f9ea6089d6da56c0a18df5dd09216b9cc9abdb578c7
|
7
|
+
data.tar.gz: 9c36341b6e51df94c6214420a59690eac694b9ec5d1f22cf20457dce781bca2f7b5bddb382e3138f55d621fa93bae98e723ff8085465273db845e4678fdc16a3
|
data/exe/hsss
CHANGED
@@ -8,6 +8,8 @@ arg=OptionParser.new do |opts|
|
|
8
8
|
opts.on("--scripts [#{Hsss::DEFAULT_SCRIPTS_NAME}]", "Scripts variable"){|v| opt[:scripts_struct]=v}
|
9
9
|
opts.on("--hashes [#{Hsss::DEFAULT_HASHES_NAME}]", "Hashes variable"){|v| opt[:hashes_struct]=v}
|
10
10
|
opts.on("--names [#{Hsss::DEFAULT_NAMES_NAME}]", "Script names variable"){|v| opt[:names_struct]=v}
|
11
|
+
opts.on("--count [#{Hsss::DEFAULT_COUNT_NAME}]", "integer script count variable"){|v| opt[:count_name]=v}
|
12
|
+
opts.on("--no-count", "Omit script count variable"){opt[:skip_count]=true}
|
11
13
|
opts.on("--no-parse", "Skip using luac to check script syntax"){opt[:no_luac]=true}
|
12
14
|
opts.on("--prefix PREFIX", "Prefix default names with this"){|v| opt[:prefix]=v}
|
13
15
|
end
|
data/lib/hsss/version.rb
CHANGED
data/lib/hsss.rb
CHANGED
@@ -6,18 +6,20 @@ module Hsss
|
|
6
6
|
DEFAULT_HASHES_NAME="redis_lua_hashes"
|
7
7
|
DEFAULT_NAMES_NAME="redis_lua_script_names"
|
8
8
|
DEFAULT_SCRIPTS_NAME="redis_lua_scripts"
|
9
|
+
DEFAULT_COUNT_NAME="redis_lua_scripts_count"
|
9
10
|
|
10
11
|
class Hsss
|
11
12
|
EXT="lua"
|
12
13
|
|
13
|
-
attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct
|
14
|
+
attr_accessor :struct_name, :hashes_struct, :names_struct, :scripts_struct, :count_name
|
14
15
|
def initialize(files, opt={})
|
15
16
|
@scripts={}
|
16
17
|
|
17
18
|
{ struct_name: DEFAULT_STRUCT_NAME,
|
18
19
|
hashes_struct: DEFAULT_HASHES_NAME,
|
19
20
|
names_struct: DEFAULT_NAMES_NAME,
|
20
|
-
scripts_struct: DEFAULT_SCRIPTS_NAME
|
21
|
+
scripts_struct: DEFAULT_SCRIPTS_NAME,
|
22
|
+
count_name: DEFAULT_COUNT_NAME}.each do |var, default|
|
21
23
|
send "#{var}=", opt[var] || default
|
22
24
|
end
|
23
25
|
|
@@ -26,6 +28,7 @@ module Hsss
|
|
26
28
|
send "#{var}=", "#{opt[:prefix]}#{send var}"
|
27
29
|
end
|
28
30
|
end
|
31
|
+
@include_count = !opt[:skip_count]
|
29
32
|
|
30
33
|
(Array === files ? files : [ files ]).each do |f|
|
31
34
|
begin
|
@@ -50,8 +53,6 @@ module Hsss
|
|
50
53
|
%s
|
51
54
|
};
|
52
55
|
|
53
|
-
#define REDIS_LUA_HASH_LENGTH %i
|
54
|
-
|
55
56
|
static #{struct_name} #{names_struct} = {
|
56
57
|
%s
|
57
58
|
};
|
@@ -59,6 +60,7 @@ module Hsss
|
|
59
60
|
static #{struct_name} #{scripts_struct} = {
|
60
61
|
%s
|
61
62
|
};
|
63
|
+
|
62
64
|
EOS
|
63
65
|
|
64
66
|
@struct=[]
|
@@ -105,10 +107,12 @@ module Hsss
|
|
105
107
|
|
106
108
|
def to_s
|
107
109
|
if @scripts.count > 0
|
108
|
-
out=sprintf @cout, @struct.join("\n"), @hashed_table.join(",\n"),
|
110
|
+
out=sprintf @cout, @struct.join("\n"), @hashed_table.join(",\n"), @name_table.join("\n"), @script_table.join(",\n\n")
|
109
111
|
else
|
110
112
|
out="//nothing here\n"
|
111
113
|
end
|
114
|
+
|
115
|
+
out<< "const int #{@count_name}=#{@scripts.count};\n" if @include_count
|
112
116
|
out
|
113
117
|
end
|
114
118
|
|