simple-redis-server 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 ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple-redis-server.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jared Grippe
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # Simple::Redis::Server
2
+
3
+ starts a redis server
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'simple-redis-server'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install simple-redis-server
18
+
19
+ ## Usage
20
+
21
+ require 'redis/server'
22
+ s = Redis::Server.new
23
+ s.start
24
+ s.connect.set(:foo,:bar)
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,12 @@
1
+ class Redis::Server::Config < Hash
2
+
3
+ def initialize hash
4
+ hash.each{|k,v| self[k] = v}
5
+ end
6
+
7
+ def to_s
8
+ map{|p| p.join(' ')}.join("\n")
9
+ end
10
+ alias_method :inspect, :to_s
11
+
12
+ end
@@ -0,0 +1,5 @@
1
+ class Redis
2
+ class Server
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,64 @@
1
+ require "redis/server/version"
2
+ require 'redis'
3
+ require 'childprocess'
4
+ require 'tempfile'
5
+ require 'tmpdir'
6
+ require 'redis/server/config'
7
+
8
+ class Redis::Server
9
+
10
+ attr_reader :config, :process
11
+
12
+ def initialize config={}
13
+ @config = Redis::Server::Config.new(config)
14
+ @config[:'slave-serve-stale-data'] ||= "no"
15
+ @config[:'daemonize'] ||= "no"
16
+ @config[:'bind'] ||= "127.0.0.1"
17
+ @config[:'port'] ||= "#{find_available_port}"
18
+ @config[:'logfile'] ||= Tempfile.new('redis-slave-logfile').path
19
+ @config[:'save'] ||= "900 1"
20
+ @config[:'rdbcompression'] ||= "yes"
21
+ @config[:'dbfilename'] ||= "dump.rdb"
22
+ @config[:'dir'] ||= Dir.tmpdir
23
+ @config[:'appendonly'] ||= "no"
24
+ @config[:'appendfsync'] ||= "no"
25
+ @config[:'appendfsync'] ||= "everysec"
26
+ @config[:'no-appendfsync-on-rewrite'] ||= "yes"
27
+ end
28
+
29
+ def start
30
+ return if started?
31
+ @process = ChildProcess.new('redis-server -')
32
+ process.duplex = true
33
+ process.start
34
+ at_exit{ process.send(:send_kill) }
35
+ process.io.stdin.puts config.to_s
36
+ process.io.stdin.close
37
+ @started = process.alive?
38
+ end
39
+
40
+ def stop
41
+ return unless started?
42
+ process.stop
43
+ end
44
+
45
+ def connect options={}
46
+ options[:host] ||= config[:bind]
47
+ options[:port] ||= config[:port]
48
+
49
+ Redis.new(options)
50
+ end
51
+
52
+ def started?
53
+ process && process.alive?
54
+ end
55
+
56
+ # copied from capybara-1.1.2
57
+ def find_available_port
58
+ server = TCPServer.new('127.0.0.1', 0)
59
+ server.addr[1]
60
+ ensure
61
+ server.close if server
62
+ end
63
+
64
+ end
@@ -0,0 +1 @@
1
+ require 'redis/server'
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/redis/server/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jared Grippe"]
6
+ gem.email = ["jared@deadlyicon.com"]
7
+ gem.description = %q{starts a redis server}
8
+ gem.summary = %q{starts a redis server}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "simple-redis-server"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Redis::Server::VERSION
17
+
18
+ gem.add_runtime_dependency "redis"
19
+ gem.add_runtime_dependency "childprocess"
20
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple-redis-server
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jared Grippe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: redis
16
+ requirement: &2165825840 !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: *2165825840
25
+ - !ruby/object:Gem::Dependency
26
+ name: childprocess
27
+ requirement: &2165343420 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2165343420
36
+ description: starts a redis server
37
+ email:
38
+ - jared@deadlyicon.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - .gitignore
44
+ - Gemfile
45
+ - LICENSE
46
+ - README.md
47
+ - Rakefile
48
+ - lib/redis/server.rb
49
+ - lib/redis/server/config.rb
50
+ - lib/redis/server/version.rb
51
+ - lib/simple-redis-server.rb
52
+ - simple-redis-server.gemspec
53
+ homepage: ''
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 1.8.10
74
+ signing_key:
75
+ specification_version: 3
76
+ summary: starts a redis server
77
+ test_files: []
78
+ has_rdoc: