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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/exe/hsss +2 -0
  3. data/lib/hsss/version.rb +1 -1
  4. data/lib/hsss.rb +9 -5
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3be3af3e7c4718d68489fc13e9237d645ce63453
4
- data.tar.gz: ca2a4a2841d6ebfbe36825cc85c8a14db8d4ffed
3
+ metadata.gz: e8a272e42a10b7a98238cae56b00cf7902ccd319
4
+ data.tar.gz: 1848f5e3f163ac181bff90e93d2e26e2225cd308
5
5
  SHA512:
6
- metadata.gz: 2cb43611d0d02bfad67c04a0a2f50f840a04dd630e07bd0dbba32f720cb9bdaf99c7c3e022aea63b294063a94dd28d3037df7d1b1a2e65da9c8b39bc3ae0a0e0
7
- data.tar.gz: 8663b83515003c2f28dd8803e6f767cf10b4ef37ef7bf07d9f5490ab66ffe7c07df5f7958ade88caf440f7c1f515d0c9ccb60142cb16b9ddd365d554b75511c1
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
@@ -1,3 +1,3 @@
1
1
  module Hsss
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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 }.each do |var, default|
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"), Digest::SHA1.hexdigest("foo").length, @name_table.join("\n"), @script_table.join(",\n\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
 
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo P.