dsander-redis 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/../../tasks/redis.tasks"
@@ -0,0 +1,16 @@
1
+ class Redis
2
+ class Subscription
3
+ def subscribe(&block)
4
+ if block_given? then @subscribe = block else @subscribe end
5
+ end
6
+
7
+ def unsubscribe(&block)
8
+ if block_given? then @unsubscribe = block else @unsubscribe end
9
+ end
10
+
11
+ def message(&block)
12
+ if block_given? then @message = block else @message end
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,140 @@
1
+ # Inspired by rabbitmq.rake the Redbox project at http://github.com/rick/redbox/tree/master
2
+ require 'rake'
3
+ require 'fileutils'
4
+ require 'open-uri'
5
+
6
+ class RedisRunner
7
+
8
+ def self.redisdir
9
+ "/tmp/redis/"
10
+ end
11
+
12
+ def self.redisconfdir
13
+ '/etc/redis.conf'
14
+ end
15
+
16
+ def self.dtach_socket
17
+ '/tmp/redis.dtach'
18
+ end
19
+
20
+ # Just check for existance of dtach socket
21
+ def self.running?
22
+ File.exists? dtach_socket
23
+ end
24
+
25
+ def self.start
26
+ puts 'Detach with Ctrl+\ Re-attach with rake redis:attach'
27
+ sleep 3
28
+ exec "dtach -A #{dtach_socket} redis-server #{redisconfdir}"
29
+ end
30
+
31
+ def self.start_detached
32
+ system "dtach -n #{dtach_socket} redis-server #{redisconfdir}"
33
+ end
34
+
35
+ def self.attach
36
+ exec "dtach -a #{dtach_socket}"
37
+ end
38
+
39
+ def self.stop
40
+ system 'echo "SHUTDOWN" | nc localhost 6379'
41
+ end
42
+
43
+ end
44
+
45
+ namespace :redis do
46
+
47
+ desc 'About redis'
48
+ task :about do
49
+ puts "\nSee http://code.google.com/p/redis/ for information about redis.\n\n"
50
+ end
51
+
52
+ desc 'Start redis'
53
+ task :start do
54
+ RedisRunner.start
55
+ end
56
+
57
+ desc 'Stop redis'
58
+ task :stop do
59
+ RedisRunner.stop
60
+ end
61
+
62
+ desc 'Restart redis'
63
+ task :restart do
64
+ RedisRunner.stop
65
+ RedisRunner.start
66
+ end
67
+
68
+ desc 'Attach to redis dtach socket'
69
+ task :attach do
70
+ RedisRunner.attach
71
+ end
72
+
73
+ desc 'Install the lastest verison of Redis from Github (requires git, duh)'
74
+ task :install => [:about, :download, :make] do
75
+ %w(redis-benchmark redis-cli redis-server).each do |bin|
76
+ sh "sudo cp /tmp/redis/#{bin} /usr/bin/"
77
+ end
78
+
79
+ puts "Installed redis-benchmark, redis-cli and redis-server to /usr/bin/"
80
+
81
+ unless File.exists?('/etc/redis.conf')
82
+ sh 'sudo cp /tmp/redis/redis.conf /etc/'
83
+ puts "Installed redis.conf to /etc/ \n You should look at this file!"
84
+ end
85
+ end
86
+
87
+ task :make do
88
+ sh "cd #{RedisRunner.redisdir} && make clean"
89
+ sh "cd #{RedisRunner.redisdir} && make"
90
+ end
91
+
92
+ desc "Download package"
93
+ task :download do
94
+ sh 'rm -rf /tmp/redis/' if File.exists?("#{RedisRunner.redisdir}/.svn")
95
+ sh 'git clone git://github.com/antirez/redis.git /tmp/redis' unless File.exists?(RedisRunner.redisdir)
96
+
97
+ if File.exists?("#{RedisRunner.redisdir}/.git")
98
+ arguments = ENV['COMMIT'].nil? ? "pull" : "reset --hard #{ENV['COMMIT']}"
99
+ sh "cd #{RedisRunner.redisdir} && git #{arguments}"
100
+ end
101
+ end
102
+
103
+ desc "Open an IRb session"
104
+ task :console do
105
+ RedisRunner.start_detached
106
+ system "irb -I lib -I extra -r redis.rb"
107
+ RedisRunner.stop
108
+ end
109
+ end
110
+
111
+ namespace :dtach do
112
+
113
+ desc 'About dtach'
114
+ task :about do
115
+ puts "\nSee http://dtach.sourceforge.net/ for information about dtach.\n\n"
116
+ end
117
+
118
+ desc 'Install dtach 0.8 from source'
119
+ task :install => [:about] do
120
+
121
+ Dir.chdir('/tmp/')
122
+ unless File.exists?('/tmp/dtach-0.8.tar.gz')
123
+ require 'net/http'
124
+
125
+ url = 'http://downloads.sourceforge.net/project/dtach/dtach/0.8/dtach-0.8.tar.gz'
126
+ open('/tmp/dtach-0.8.tar.gz', 'wb') do |file| file.write(open(url).read) end
127
+ end
128
+
129
+ unless File.directory?('/tmp/dtach-0.8')
130
+ system('tar xzf dtach-0.8.tar.gz')
131
+ end
132
+
133
+ Dir.chdir('/tmp/dtach-0.8/')
134
+ sh 'cd /tmp/dtach-0.8/ && ./configure && make'
135
+ sh 'sudo cp /tmp/dtach-0.8/dtach /usr/bin/'
136
+
137
+ puts 'Dtach successfully installed to /usr/bin.'
138
+ end
139
+ end
140
+
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dsander-redis
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 6
9
+ version: 1.0.6
10
+ platform: ruby
11
+ authors:
12
+ - Ezra Zygmuntowicz
13
+ - Taylor Weibley
14
+ - Matthew Clark
15
+ - Brian McKinney
16
+ - Salvatore Sanfilippo
17
+ - Luca Guidi
18
+ - Dominik Sander
19
+ autorequire: dsander-redis
20
+ bindir: bin
21
+ cert_chain: []
22
+
23
+ date: 2010-04-22 00:00:00 +00:00
24
+ default_executable:
25
+ dependencies: []
26
+
27
+ description: Ruby client library for Redis, the key value storage server
28
+ email: ez@engineyard.com
29
+ executables: []
30
+
31
+ extensions: []
32
+
33
+ extra_rdoc_files:
34
+ - LICENSE
35
+ files:
36
+ - LICENSE
37
+ - README.markdown
38
+ - Rakefile
39
+ - lib/redis.rb
40
+ - lib/edis.rb
41
+ - lib/redis/raketasks.rb
42
+ - lib/redis/client.rb
43
+ - lib/redis/hash_ring.rb
44
+ - lib/redis/event_machine.rb
45
+ - lib/redis/dist_redis.rb
46
+ - lib/redis/subscribe.rb
47
+ - lib/redis/pipeline.rb
48
+ - tasks/redis.tasks.rb
49
+ has_rdoc: true
50
+ homepage: http://github.com/dsander/redis-rb
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project:
75
+ rubygems_version: 1.3.6
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Ruby client library for Redis, the key value storage server
79
+ test_files: []
80
+