uri-redis 0.2.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/CHANGES.txt +5 -0
- data/LICENSE.txt +19 -0
- data/README.rdoc +35 -0
- data/Rakefile +74 -0
- data/lib/uri/redis.rb +59 -0
- data/tryouts/essential_tryouts.rb +11 -0
- data/uri-redis.gemspec +29 -0
- metadata +67 -0
data/CHANGES.txt
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Solutious Inc, Delano Mandelbaum
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
= URI-Redis v0.2
|
2
|
+
|
3
|
+
redis://host:port/dbindex
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
require 'uri/redis'
|
8
|
+
|
9
|
+
conf = URI.parse 'redis://localhost:8999/2'
|
10
|
+
conf.host # => localhost
|
11
|
+
conf.port # => 8999
|
12
|
+
conf.db # => 2
|
13
|
+
|
14
|
+
|
15
|
+
== Installation
|
16
|
+
|
17
|
+
Get it in one of the following ways:
|
18
|
+
|
19
|
+
* <tt>gem install uri-redis</tt>
|
20
|
+
* <tt>git clone git://github.com/delano/uri-redis.git</tt>
|
21
|
+
|
22
|
+
|
23
|
+
== More Information
|
24
|
+
|
25
|
+
* Codes[http://github.com/delano/uri-redis]
|
26
|
+
* RDocs[http://delano.github.com/uri-redis]
|
27
|
+
|
28
|
+
|
29
|
+
== Credits
|
30
|
+
|
31
|
+
* Delano Mandelbaum (http://solutious.com)
|
32
|
+
|
33
|
+
== License
|
34
|
+
|
35
|
+
See LICENSE.txt
|
data/Rakefile
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'hanna/rdoctask'
|
8
|
+
rescue LoadError
|
9
|
+
require 'rake/rdoctask'
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
task :default => :test
|
14
|
+
|
15
|
+
|
16
|
+
# PACKAGE =============================================================
|
17
|
+
|
18
|
+
name = "uri-redis"
|
19
|
+
load "#{name}.gemspec"
|
20
|
+
|
21
|
+
version = @spec.version
|
22
|
+
|
23
|
+
Rake::GemPackageTask.new(@spec) do |p|
|
24
|
+
p.need_tar = true if RUBY_PLATFORM !~ /mswin/
|
25
|
+
end
|
26
|
+
|
27
|
+
task :release => [ "publish:gem", :clean, "publish:rdoc" ] do
|
28
|
+
$: << File.join(File.dirname(__FILE__), 'lib')
|
29
|
+
require "rudy"
|
30
|
+
abort if Drydock.debug?
|
31
|
+
end
|
32
|
+
|
33
|
+
task :install => [ :rdoc, :package ] do
|
34
|
+
sh %{sudo gem install pkg/#{name}-#{version}.gem}
|
35
|
+
end
|
36
|
+
|
37
|
+
task :uninstall => [ :clean ] do
|
38
|
+
sh %{sudo gem uninstall #{name}}
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# Rubyforge Release / Publish Tasks ==================================
|
43
|
+
|
44
|
+
#about 'Publish website to rubyforge'
|
45
|
+
task 'publish:rdoc' => 'doc/index.html' do
|
46
|
+
sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
|
47
|
+
end
|
48
|
+
|
49
|
+
#about 'Public release to rubyforge'
|
50
|
+
task 'publish:gem' => [:package] do |t|
|
51
|
+
sh <<-end
|
52
|
+
rubyforge add_release -o Any -a CHANGES.txt -f -n README.rdoc #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
|
53
|
+
rubyforge add_file -o Any -a CHANGES.txt -f -n README.rdoc #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
Rake::RDocTask.new do |t|
|
59
|
+
t.rdoc_dir = 'doc'
|
60
|
+
t.title = @spec.summary
|
61
|
+
t.options << '--line-numbers' << '-A cattr_accessor=object'
|
62
|
+
t.options << '--charset' << 'utf-8'
|
63
|
+
t.rdoc_files.include('LICENSE.txt')
|
64
|
+
t.rdoc_files.include('README.rdoc')
|
65
|
+
t.rdoc_files.include('CHANGES.txt')
|
66
|
+
#t.rdoc_files.include('Rudyfile') # why is the formatting f'd?
|
67
|
+
t.rdoc_files.include('bin/*')
|
68
|
+
t.rdoc_files.include('lib/**/*.rb')
|
69
|
+
end
|
70
|
+
|
71
|
+
CLEAN.include [ 'pkg', '*.gem', '.config', 'doc', 'coverage*' ]
|
72
|
+
|
73
|
+
|
74
|
+
|
data/lib/uri/redis.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'redis'
|
3
|
+
|
4
|
+
module URI
|
5
|
+
class Redis < URI::Generic
|
6
|
+
DEFAULT_PORT = 6379
|
7
|
+
DEFAULT_DB = 0
|
8
|
+
|
9
|
+
def self.build(args)
|
10
|
+
tmp = Util::make_components_hash(self, args)
|
11
|
+
return super(tmp)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(*arg)
|
15
|
+
super(*arg)
|
16
|
+
end
|
17
|
+
|
18
|
+
def request_uri
|
19
|
+
r = path_query
|
20
|
+
end
|
21
|
+
|
22
|
+
def db
|
23
|
+
val = path.tr('/', '')
|
24
|
+
val.empty? ? DEFAULT_DB : val.to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def db=(val)
|
28
|
+
self.path = "/#{val}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def conf
|
32
|
+
tmp = {
|
33
|
+
:host => host,
|
34
|
+
:port => port,
|
35
|
+
:db => db
|
36
|
+
}
|
37
|
+
tmp[:password] = password if password
|
38
|
+
tmp
|
39
|
+
end
|
40
|
+
|
41
|
+
def serverid
|
42
|
+
'redis://%s:%s/%s' % [host, port, db]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
@@schemes['REDIS'] = Redis
|
48
|
+
end
|
49
|
+
|
50
|
+
class Redis
|
51
|
+
class Client
|
52
|
+
def uri
|
53
|
+
URI.parse 'redis://%s:%s/%s' % [@host, @port, @db]
|
54
|
+
end
|
55
|
+
def self.uri(conf={})
|
56
|
+
URI.parse 'redis://%s:%s/%s' % [conf[:host], conf[:port], conf[:db]]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/uri-redis.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
@spec = Gem::Specification.new do |s|
|
2
|
+
s.name = "uri-redis"
|
3
|
+
s.rubyforge_project = 'uri-redis'
|
4
|
+
s.version = "0.2.0"
|
5
|
+
s.summary = "URI-Redis: support for parsing redis://host:port/dbindex"
|
6
|
+
s.description = s.summary
|
7
|
+
s.author = "Delano Mandelbaum"
|
8
|
+
s.email = "delano@solutious.com"
|
9
|
+
s.homepage = "http://github.com/delano/uri-redis"
|
10
|
+
|
11
|
+
s.extra_rdoc_files = %w[README.rdoc LICENSE.txt CHANGES.txt]
|
12
|
+
s.has_rdoc = true
|
13
|
+
s.rdoc_options = ["--line-numbers", "--title", s.summary, "--main", "README.rdoc"]
|
14
|
+
s.require_paths = %w[lib]
|
15
|
+
|
16
|
+
# = MANIFEST =
|
17
|
+
# git ls-files
|
18
|
+
s.files = %w(
|
19
|
+
CHANGES.txt
|
20
|
+
LICENSE.txt
|
21
|
+
README.rdoc
|
22
|
+
Rakefile
|
23
|
+
lib/uri/redis.rb
|
24
|
+
tryouts/essential_tryouts.rb
|
25
|
+
uri-redis.gemspec
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uri-redis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Delano Mandelbaum
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-05-30 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: "URI-Redis: support for parsing redis://host:port/dbindex"
|
17
|
+
email: delano@solutious.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- LICENSE.txt
|
25
|
+
- CHANGES.txt
|
26
|
+
files:
|
27
|
+
- CHANGES.txt
|
28
|
+
- LICENSE.txt
|
29
|
+
- README.rdoc
|
30
|
+
- Rakefile
|
31
|
+
- lib/uri/redis.rb
|
32
|
+
- tryouts/essential_tryouts.rb
|
33
|
+
- uri-redis.gemspec
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: http://github.com/delano/uri-redis
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options:
|
40
|
+
- --line-numbers
|
41
|
+
- --title
|
42
|
+
- "URI-Redis: support for parsing redis://host:port/dbindex"
|
43
|
+
- --main
|
44
|
+
- README.rdoc
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project: uri-redis
|
62
|
+
rubygems_version: 1.3.5
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: "URI-Redis: support for parsing redis://host:port/dbindex"
|
66
|
+
test_files: []
|
67
|
+
|