wolverine 0.0.1
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/wolverine.rb +46 -0
- data/lib/wolverine/version.rb +3 -0
- data/wolverine.gemspec +22 -0
- metadata +64 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/wolverine.rb
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "wolverine/version"
|
|
2
|
+
require 'redis'
|
|
3
|
+
|
|
4
|
+
module Wolverine
|
|
5
|
+
def self.script_path
|
|
6
|
+
Rails.root + 'app/redis'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.call(file, *args)
|
|
10
|
+
file << ".lua" unless file =~ /\.lua$/
|
|
11
|
+
LuaFile.new(script_path + file).call(redis, *args)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.redis
|
|
15
|
+
$redis ||= Redis.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class LuaFile
|
|
19
|
+
attr_reader :content, :digest
|
|
20
|
+
def initialize file
|
|
21
|
+
@content = load_lua file
|
|
22
|
+
@digest = Digest::SHA1.hexdigest @content
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def call redis, *args
|
|
26
|
+
run_evalsha redis, *args
|
|
27
|
+
rescue => e
|
|
28
|
+
e.message =~ /NOSCRIPT/ ? run_eval(redis, *args) : raise
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def run_evalsha redis, *args
|
|
34
|
+
redis.evalsha digest, args.size, *args
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def run_eval redis, *args
|
|
38
|
+
redis.eval content, args.size, *args
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def load_lua file
|
|
42
|
+
File.read file
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
data/wolverine.gemspec
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "wolverine/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "wolverine"
|
|
7
|
+
s.version = Wolverine::VERSION
|
|
8
|
+
s.authors = ["Burke Libbey"]
|
|
9
|
+
s.email = ["burke@burkelibbey.org"]
|
|
10
|
+
s.homepage = ""
|
|
11
|
+
s.summary = %q{Wolverine provides a simple way to run server-side redis scripts from a rails app}
|
|
12
|
+
s.description = %q{Wolverine provides a simple way to run server-side redis scripts from a rails app}
|
|
13
|
+
|
|
14
|
+
s.rubyforge_project = "wolverine"
|
|
15
|
+
|
|
16
|
+
s.files = `git ls-files`.split("\n")
|
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
19
|
+
s.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
s.add_runtime_dependency 'redis'
|
|
22
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: wolverine
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Burke Libbey
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-03-01 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: redis
|
|
16
|
+
requirement: &70192619258840 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *70192619258840
|
|
25
|
+
description: Wolverine provides a simple way to run server-side redis scripts from
|
|
26
|
+
a rails app
|
|
27
|
+
email:
|
|
28
|
+
- burke@burkelibbey.org
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- .gitignore
|
|
34
|
+
- Gemfile
|
|
35
|
+
- Rakefile
|
|
36
|
+
- lib/wolverine.rb
|
|
37
|
+
- lib/wolverine/version.rb
|
|
38
|
+
- wolverine.gemspec
|
|
39
|
+
homepage: ''
|
|
40
|
+
licenses: []
|
|
41
|
+
post_install_message:
|
|
42
|
+
rdoc_options: []
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
none: false
|
|
47
|
+
requirements:
|
|
48
|
+
- - ! '>='
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '0'
|
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
|
+
none: false
|
|
53
|
+
requirements:
|
|
54
|
+
- - ! '>='
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
requirements: []
|
|
58
|
+
rubyforge_project: wolverine
|
|
59
|
+
rubygems_version: 1.8.11
|
|
60
|
+
signing_key:
|
|
61
|
+
specification_version: 3
|
|
62
|
+
summary: Wolverine provides a simple way to run server-side redis scripts from a rails
|
|
63
|
+
app
|
|
64
|
+
test_files: []
|