redic 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b87eca346ba119f79fe0fe1d10d2fddb6496aa8
4
- data.tar.gz: 0fbf48927126da0626d0e5c7a5b088d2e30e50d1
3
+ metadata.gz: 355a240594d8061dd7923241cc74287a20fa95e9
4
+ data.tar.gz: 48970d72e3f18979402c1e48e0abbec18bca841f
5
5
  SHA512:
6
- metadata.gz: a50d44772e1fb5ae12967fc1bead5b23e01d7c466ab448e7770576e7ac588f2d5eb42f9708d2baa19322bf9e76d0986f79dcb61ef529124a35ca4c0606b37565
7
- data.tar.gz: d0a00c6821040e8f67441e624b3da6672691d46fbd6abbf1f13f25b7a0510bc09fc9cdc5122482970bc0f60b726c3981701209477b51bcc47f4466c79d62cd55
6
+ metadata.gz: 83f2a759265a3ec0fc8ed6695a648412219e9b6d929e11f5927050baa9d14b97ca1ad2746d16281e8787aa24bb82e931cb0862fff4b9b269fa954c1cc9596927
7
+ data.tar.gz: 99a04bb3a6952b079ae6b0eee9ab52e9f17346fffa3052d8fc237dfe26dd239d34d26b2ecf37112910ac47b91609e78b84815b4ef0427168de2545ef441bbf2d
@@ -0,0 +1,19 @@
1
+ This code tries to solve a particular problem with a very simple
2
+ implementation. We try to keep the code to a minimum while making
3
+ it as clear as possible. The design is very likely finished, and
4
+ if some feature is missing it is possible that it was left out on
5
+ purpose. That said, new usage patterns may arise, and when that
6
+ happens we are ready to adapt if necessary.
7
+
8
+ A good first step for contributing is to meet us on IRC and discuss
9
+ ideas. We spend a lot of time on #lesscode at freenode, always ready
10
+ to talk about code and simplicity. If connecting to IRC is not an
11
+ option, you can create an issue explaining the proposed change and
12
+ a use case. We pay a lot of attention to use cases, because our
13
+ goal is to keep the code base simple. Usually the result of a
14
+ conversation is the creation of a different tool.
15
+
16
+ Please don't start the conversation with a pull request. The code
17
+ should come at last, and even though it may help to convey an idea,
18
+ more often than not it draws the attention to a particular
19
+ implementation.
@@ -36,6 +36,16 @@ class Redic
36
36
  end
37
37
  end
38
38
 
39
+ def call!(*args)
40
+ reply = call(*args)
41
+
42
+ if RuntimeError === reply
43
+ raise reply
44
+ end
45
+
46
+ return reply
47
+ end
48
+
39
49
  def queue(*args)
40
50
  buffer << args
41
51
  end
@@ -3,6 +3,9 @@ require "uri"
3
3
 
4
4
  class Redic
5
5
  class Client
6
+ EMPTY = "".freeze
7
+ SLASH = "/".freeze
8
+
6
9
  attr :timeout
7
10
 
8
11
  def initialize(url, timeout)
@@ -68,9 +71,14 @@ class Redic
68
71
  raise err, "Can't connect to: %s" % @uri
69
72
  end
70
73
 
71
- if @uri.scheme == "redis"
72
- @uri.password && assert_ok(call("AUTH", @uri.password))
73
- @uri.path != "" && assert_ok(call("SELECT", @uri.path[1..-1]))
74
+ if @uri.scheme != "unix"
75
+ if @uri.password
76
+ assert_ok(call("AUTH", @uri.password))
77
+ end
78
+
79
+ if @uri.path != EMPTY && @uri.path != SLASH
80
+ assert_ok(call("SELECT", @uri.path[1..-1]))
81
+ end
74
82
  end
75
83
  end
76
84
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "redic"
5
- s.version = "1.4.1"
5
+ s.version = "1.5.0"
6
6
  s.summary = "Lightweight Redis Client"
7
7
  s.description = "Lightweight Redis Client"
8
8
  s.authors = ["Michel Martens", "Cyril David"]
@@ -7,11 +7,12 @@ prepare do
7
7
  c = Redic.new(REDIS_URL)
8
8
 
9
9
  begin
10
- c.call("FLUSHDB")
10
+ c.call!("FLUSHDB").inspect
11
11
  rescue
12
- c.call("AUTH", "foo")
13
- c.call("FLUSHDB")
14
- c.call("CONFIG", "SET", "requirepass", "")
12
+ c.call!("AUTH", "foo")
13
+ c.call!("SELECT", "0")
14
+ c.call!("FLUSHDB")
15
+ c.call!("CONFIG", "SET", "requirepass", "")
15
16
  end
16
17
  end
17
18
 
@@ -2,7 +2,7 @@ require "cutest"
2
2
  require_relative "../lib/redic"
3
3
 
4
4
  setup do
5
- Redic.new("unix:///tmp/redis.sock")
5
+ Redic.new("unix:///tmp/redis.6379.sock")
6
6
  end
7
7
 
8
8
  test "normal commands" do |c|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Martens
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-12 00:00:00.000000000 Z
12
+ date: 2015-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hiredis
@@ -36,6 +36,7 @@ files:
36
36
  - .gems
37
37
  - .gitignore
38
38
  - CHANGELOG
39
+ - CONTRIBUTING
39
40
  - LICENSE
40
41
  - README.md
41
42
  - lib/redic.rb