guard-redis 0.1.0
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/LICENSE +20 -0
- data/README.md +32 -0
- data/lib/guard/redis.rb +63 -0
- data/lib/guard/redis/templates/Guardfile +2 -0
- data/lib/guard/redis/version.rb +5 -0
- metadata +115 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Zachery Moneypenny
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Guard::Redis
|
2
|
+
|
3
|
+
Redis guard manages your development [Redis](http://redis.io) server, and will automatically restart if necessary.
|
4
|
+
|
5
|
+
The code for this gem was taken from [this blog post by Avdi Grimm](http://avdi.org/devblog/2011/06/15/a-guardfile-for-redis/). It refers to [this Gist](https://gist.github.com/1026546), and I searched around for an existing repo quite a bit before packing it up here. __All credit goes to Avdi for the source__ and all fault goes to me for configuration or packaging issues.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
Make sure you have [Guard](https://github.com/guard/guard) installed before continuing.
|
10
|
+
|
11
|
+
Install the gem:
|
12
|
+
|
13
|
+
$ gem install guard-redis
|
14
|
+
|
15
|
+
Add it to your Gemfile. You should really only need it in development and test environments; this gem is not meant to manage production server instances of Redis.
|
16
|
+
|
17
|
+
gem 'guard-redis'
|
18
|
+
|
19
|
+
Add the guard definition to your Guardfile by running:
|
20
|
+
|
21
|
+
$ guard init redis
|
22
|
+
|
23
|
+
## Options
|
24
|
+
|
25
|
+
Guard::Redis doesn't watch any files; it's purpose is to ensure that redis-server is running while you're coding and testing. It does take several options related to configuration of the redis server.
|
26
|
+
|
27
|
+
### List of available options
|
28
|
+
~~~~ruby
|
29
|
+
:executable => "/path/to/redis/server/executable" # Set the custom path to the redis server executable
|
30
|
+
:port => 9999 # Set a custom port number the redis server is running on
|
31
|
+
:pidfile => "/var/pid/redis.pid" # Set a custom path the where the pidfile is written
|
32
|
+
~~~~
|
data/lib/guard/redis.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'guard'
|
2
|
+
require 'guard/guard'
|
3
|
+
|
4
|
+
module Guard
|
5
|
+
class Redis < Guard
|
6
|
+
def start
|
7
|
+
puts "Starting Redis on port #{port}"
|
8
|
+
IO.popen("#{executable} -", 'w+') do |server|
|
9
|
+
server.write(config)
|
10
|
+
server.close_write
|
11
|
+
end
|
12
|
+
puts "Redis is running with PID #{pid}"
|
13
|
+
$?.success?
|
14
|
+
end
|
15
|
+
|
16
|
+
def stop
|
17
|
+
if pid
|
18
|
+
puts "Sending TERM signal to Redis (#{pid})"
|
19
|
+
Process.kill("TERM", pid)
|
20
|
+
true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def reload
|
25
|
+
stop
|
26
|
+
start
|
27
|
+
end
|
28
|
+
|
29
|
+
def run_all
|
30
|
+
true
|
31
|
+
end
|
32
|
+
|
33
|
+
def run_on_change(paths)
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def pidfile_path
|
38
|
+
options.fetch(:pidfile) {
|
39
|
+
File.expand_path('tmp/redis.pid', File.dirname(__FILE__))
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
def config
|
44
|
+
<<"END"
|
45
|
+
daemonize yes
|
46
|
+
pidfile #{pidfile_path}
|
47
|
+
port #{port}
|
48
|
+
END
|
49
|
+
end
|
50
|
+
|
51
|
+
def pid
|
52
|
+
File.exist?(pidfile_path) && File.read(pidfile_path).to_i
|
53
|
+
end
|
54
|
+
|
55
|
+
def executable
|
56
|
+
options.fetch(:executable) { 'redis-server' }
|
57
|
+
end
|
58
|
+
|
59
|
+
def port
|
60
|
+
options.fetch(:port) { 6379 }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: guard-redis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Zachery Moneypenny
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-09-27 00:00:00 -05:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: guard
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.4.0
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: redis
|
29
|
+
prerelease: false
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.2.2
|
36
|
+
type: :runtime
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: bundler
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "1.0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: rspec
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "2.6"
|
58
|
+
type: :development
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: guard-rspec
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
71
|
+
description: Guard::Redis automatically starts and restarts your local redis server.
|
72
|
+
email:
|
73
|
+
- guard-redis@whazzing.com
|
74
|
+
executables: []
|
75
|
+
|
76
|
+
extensions: []
|
77
|
+
|
78
|
+
extra_rdoc_files: []
|
79
|
+
|
80
|
+
files:
|
81
|
+
- lib/guard/redis/templates/Guardfile
|
82
|
+
- lib/guard/redis/version.rb
|
83
|
+
- lib/guard/redis.rb
|
84
|
+
- LICENSE
|
85
|
+
- README.md
|
86
|
+
has_rdoc: true
|
87
|
+
homepage: http://rubygems.org/gems/guard-redis
|
88
|
+
licenses: []
|
89
|
+
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.3.6
|
107
|
+
requirements: []
|
108
|
+
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 1.6.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: Guard gem for Redis
|
114
|
+
test_files: []
|
115
|
+
|