aclatraz 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ == Version 0.1.2
2
+
3
+ * Added possibility to passing connection objects in Aclatraz#init
4
+ * Tested Aclatraz#init with Redis hash options given
5
+ * Minor bugfixes
6
+
1
7
  == Version 0.1.1
2
8
 
3
9
  * Riak store [Thanks seven1m]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/aclatraz.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{aclatraz}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kriss 'nu7hatch' Kowalik"]
12
- s.date = %q{2010-09-17}
12
+ s.date = %q{2010-09-19}
13
13
  s.description = %q{ Extremaly fast and flexible access control mechanism inspired by *nix ACLs,
14
14
  powered by fast key value stores like Redis or TokyoCabinet.
15
15
  }
@@ -1,5 +1,6 @@
1
1
  begin
2
2
  require 'redis'
3
+ require 'redis/distributed'
3
4
  rescue LoadError
4
5
  raise "You must install the redis gem to use the Redis store"
5
6
  end
@@ -21,7 +22,11 @@ module Aclatraz
21
22
  MEMBER_ROLES = "member.%s.roles"
22
23
 
23
24
  def initialize(*args) # :nodoc:
24
- @backend = ::Redis.new(*args)
25
+ case args.first when ::Redis, ::Redis::Distributed
26
+ @backend = args.first
27
+ else
28
+ @backend = ::Redis.new(*args)
29
+ end
25
30
  end
26
31
 
27
32
  def set(role, member, object=nil)
@@ -18,7 +18,11 @@ module Aclatraz
18
18
  include Aclatraz::Helpers
19
19
 
20
20
  def initialize(bucket_name, *args) # :nodoc:
21
- @backend = ::Riak::Client.new(*args).bucket(bucket_name)
21
+ case args.first when ::Riak::Client
22
+ @backend = args.first.bucket(bucket_name)
23
+ else
24
+ @backend = ::Riak::Client.new(*args).bucket(bucket_name)
25
+ end
22
26
  end
23
27
 
24
28
  def set(role, member, object=nil)
@@ -55,19 +55,34 @@ describe "Aclatraz" do
55
55
  let(:owner) { StubOwner.new }
56
56
  let(:target) { StubTarget.new }
57
57
 
58
- describe "Redis store" do
59
- before(:all) { @redis = Thread.new { `redis-server` } }
60
- after(:all) { @redis.exit! }
58
+ describe "for Redis store" do
61
59
  subject { Aclatraz.init(:redis, "redis://localhost:6379/0") }
62
60
 
63
61
  class_eval &STORE_SPECS
62
+
63
+ it "should respect persistent connection given on initalize" do
64
+ Aclatraz.instance_variable_set("@store", nil)
65
+ Aclatraz.init(:redis, Redis.new("redis://localhost:6379/0"))
66
+ Aclatraz.store.instance_variable_get('@backend').should be_kind_of(Redis)
67
+ Aclatraz.store.instance_variable_get('@backend').ping.should be_true
68
+ end
69
+
70
+ it "shouls respect redis hash options given in init" do
71
+ Aclatraz.instance_variable_set("@store", nil)
72
+ Aclatraz.init(:redis, :url => "redis://localhost:6379/0")
73
+ Aclatraz.store.instance_variable_get('@backend').ping.should be_true
74
+ end
64
75
  end
65
76
 
66
- describe "Riak store" do
67
- before(:all) { @riak = Thread.new { `riak start` } }
68
- after(:all) { @riak.exit! }
77
+ describe "for Riak store" do
69
78
  subject { Aclatraz.init(:riak, "roles") }
70
79
 
71
80
  class_eval &STORE_SPECS
81
+
82
+ it "should respect persistent connection given on initalize" do
83
+ Aclatraz.instance_variable_set("@store", nil)
84
+ Aclatraz.init(:riak, "roles", ::Riak::Client.new)
85
+ Aclatraz.store.instance_variable_get('@backend').should be_kind_of(Riak::Bucket)
86
+ end
72
87
  end
73
88
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aclatraz
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kriss 'nu7hatch' Kowalik
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-17 00:00:00 +02:00
18
+ date: 2010-09-19 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency