juno 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -4
- data/Gemfile +3 -1
- data/README.md +40 -8
- data/benchmarks/run.rb +17 -5
- data/lib/juno/adapters/activerecord.rb +23 -14
- data/lib/juno/adapters/cassandra.rb +11 -0
- data/lib/juno/adapters/couch.rb +9 -0
- data/lib/juno/adapters/datamapper.rb +10 -0
- data/lib/juno/adapters/dbm.rb +8 -0
- data/lib/juno/adapters/file.rb +2 -0
- data/lib/juno/adapters/fog.rb +9 -0
- data/lib/juno/adapters/gdbm.rb +8 -0
- data/lib/juno/adapters/localmemcache.rb +8 -0
- data/lib/juno/adapters/lruhash.rb +8 -0
- data/lib/juno/adapters/memcached_dalli.rb +9 -0
- data/lib/juno/adapters/memcached_native.rb +10 -0
- data/lib/juno/adapters/memory.rb +2 -0
- data/lib/juno/adapters/mongo.rb +11 -0
- data/lib/juno/adapters/null.rb +2 -0
- data/lib/juno/adapters/pstore.rb +9 -2
- data/lib/juno/adapters/redis.rb +5 -0
- data/lib/juno/adapters/riak.rb +9 -0
- data/lib/juno/adapters/sdbm.rb +8 -0
- data/lib/juno/adapters/sequel.rb +10 -0
- data/lib/juno/adapters/sqlite.rb +9 -0
- data/lib/juno/adapters/tokyocabinet.rb +16 -4
- data/lib/juno/adapters/yaml.rb +2 -0
- data/lib/juno/base.rb +1 -0
- data/lib/juno/builder.rb +2 -0
- data/lib/juno/cache.rb +2 -0
- data/lib/juno/expires.rb +1 -0
- data/lib/juno/lock.rb +37 -0
- data/lib/juno/proxy.rb +1 -0
- data/lib/juno/stack.rb +2 -0
- data/lib/juno/transformer.rb +16 -4
- data/lib/juno/version.rb +3 -1
- data/lib/juno.rb +33 -2
- data/spec/adapter_activerecord_spec.rb +20 -34
- data/spec/adapter_cassandra_spec.rb +9 -23
- data/spec/adapter_couch_spec.rb +9 -23
- data/spec/adapter_datamapper_spec.rb +36 -50
- data/spec/adapter_dbm_spec.rb +9 -23
- data/spec/adapter_file_spec.rb +9 -23
- data/spec/adapter_fog_spec.rb +12 -29
- data/spec/adapter_gdbm_spec.rb +9 -23
- data/spec/adapter_localmemcache_spec.rb +9 -23
- data/spec/adapter_lruhash_spec.rb +24 -38
- data/spec/adapter_memcached_dalli_spec.rb +10 -24
- data/spec/adapter_memcached_native_spec.rb +10 -24
- data/spec/adapter_memcached_spec.rb +10 -24
- data/spec/adapter_memory_spec.rb +24 -38
- data/spec/adapter_mongo_spec.rb +9 -23
- data/spec/adapter_pstore_spec.rb +12 -26
- data/spec/adapter_redis_spec.rb +10 -24
- data/spec/adapter_riak_spec.rb +9 -23
- data/spec/adapter_sdbm_spec.rb +9 -23
- data/spec/adapter_sequel_spec.rb +9 -23
- data/spec/adapter_sqlite_spec.rb +9 -23
- data/spec/adapter_tokyocabinet_bdb_spec.rb +13 -0
- data/spec/adapter_tokyocabinet_hdb_spec.rb +13 -0
- data/spec/adapter_yaml_spec.rb +12 -26
- data/spec/cache_file_memory_spec.rb +22 -43
- data/spec/cache_memory_null_spec.rb +13 -34
- data/spec/expires_file_spec.rb +56 -76
- data/spec/expires_memory_spec.rb +35 -54
- data/spec/generate.rb +147 -160
- data/spec/helper.rb +39 -0
- data/spec/junospecs.rb +612 -610
- data/spec/lock_spec.rb +31 -0
- data/spec/null_adapter_spec.rb +15 -29
- data/spec/proxy_expires_memory_spec.rb +37 -58
- data/spec/proxy_redis_spec.rb +13 -33
- data/spec/simple_activerecord_spec.rb +34 -48
- data/spec/simple_activerecord_with_expires_spec.rb +35 -49
- data/spec/simple_cassandra_spec.rb +35 -49
- data/spec/simple_couch_spec.rb +34 -48
- data/spec/simple_couch_with_expires_spec.rb +35 -49
- data/spec/simple_datamapper_spec.rb +34 -48
- data/spec/simple_datamapper_with_expires_spec.rb +35 -49
- data/spec/simple_datamapper_with_repository_spec.rb +34 -48
- data/spec/simple_dbm_spec.rb +34 -48
- data/spec/simple_dbm_with_expires_spec.rb +35 -49
- data/spec/simple_file_spec.rb +34 -48
- data/spec/simple_file_with_expires_spec.rb +35 -49
- data/spec/simple_fog_spec.rb +37 -54
- data/spec/simple_fog_with_expires_spec.rb +39 -57
- data/spec/simple_gdbm_spec.rb +34 -48
- data/spec/simple_gdbm_with_expires_spec.rb +35 -49
- data/spec/simple_hashfile_spec.rb +34 -48
- data/spec/simple_hashfile_with_expires_spec.rb +35 -49
- data/spec/simple_localmemcache_spec.rb +34 -48
- data/spec/simple_localmemcache_with_expires_spec.rb +35 -49
- data/spec/simple_lruhash_spec.rb +34 -48
- data/spec/simple_lruhash_with_expires_spec.rb +35 -49
- data/spec/simple_memcached_dalli_spec.rb +35 -49
- data/spec/simple_memcached_native_spec.rb +35 -49
- data/spec/simple_memcached_spec.rb +35 -49
- data/spec/simple_memory_spec.rb +34 -48
- data/spec/simple_memory_with_expires_spec.rb +35 -49
- data/spec/simple_mongo_spec.rb +34 -48
- data/spec/simple_mongo_with_expires_spec.rb +35 -49
- data/spec/simple_null_spec.rb +25 -39
- data/spec/simple_pstore_spec.rb +34 -48
- data/spec/simple_pstore_with_expires_spec.rb +35 -49
- data/spec/simple_redis_spec.rb +35 -49
- data/spec/simple_riak_spec.rb +34 -48
- data/spec/simple_riak_with_expires_spec.rb +35 -49
- data/spec/simple_sdbm_spec.rb +34 -48
- data/spec/simple_sdbm_with_expires_spec.rb +35 -49
- data/spec/simple_sequel_spec.rb +34 -48
- data/spec/simple_sequel_with_expires_spec.rb +35 -49
- data/spec/simple_sqlite_spec.rb +34 -48
- data/spec/simple_sqlite_with_expires_spec.rb +35 -49
- data/spec/simple_tokyocabinet_spec.rb +34 -48
- data/spec/simple_tokyocabinet_with_expires_spec.rb +35 -49
- data/spec/simple_yaml_spec.rb +34 -48
- data/spec/simple_yaml_with_expires_spec.rb +35 -49
- data/spec/stack_file_memory_spec.rb +15 -38
- data/spec/stack_memory_file_spec.rb +14 -37
- data/spec/transformer_bson_spec.rb +20 -39
- data/spec/transformer_compress_spec.rb +17 -36
- data/spec/transformer_json_spec.rb +20 -39
- data/spec/transformer_marshal_base64_spec.rb +36 -55
- data/spec/transformer_marshal_escape_spec.rb +36 -55
- data/spec/transformer_marshal_md5_spec.rb +36 -55
- data/spec/transformer_marshal_md5_spread_spec.rb +36 -55
- data/spec/transformer_msgpack_spec.rb +20 -39
- data/spec/transformer_ox_spec.rb +40 -0
- data/spec/transformer_yaml_spec.rb +35 -54
- metadata +11 -6
- data/spec/adapter_tokyocabinet_spec.rb +0 -27
- data/spec/simpl_memory_with_expires_spec.rb +0 -53
data/lib/juno/lock.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
3
|
+
module Juno
|
4
|
+
# Locks the underlying stores with a Mutex
|
5
|
+
# @api public
|
6
|
+
class Lock < Proxy
|
7
|
+
def initialize(adapter, options = {})
|
8
|
+
super
|
9
|
+
@lock = Mutex.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def key?(key, options = {})
|
13
|
+
@lock.synchronize { super }
|
14
|
+
end
|
15
|
+
|
16
|
+
def load(key, options = {})
|
17
|
+
@lock.synchronize { super }
|
18
|
+
end
|
19
|
+
|
20
|
+
def store(key, value, options = {})
|
21
|
+
@lock.synchronize { super }
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete(key, options = {})
|
25
|
+
@lock.synchronize { super }
|
26
|
+
end
|
27
|
+
|
28
|
+
def clear(options = {})
|
29
|
+
@lock.synchronize { super }
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def close
|
34
|
+
@lock.synchronize { super }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/juno/proxy.rb
CHANGED
data/lib/juno/stack.rb
CHANGED
data/lib/juno/transformer.rb
CHANGED
@@ -7,15 +7,18 @@ module Juno
|
|
7
7
|
# transformer :key => [:marshal, :escape], :value => [:marshal]
|
8
8
|
# adapter :File, :dir => 'data'
|
9
9
|
# end
|
10
|
+
#
|
11
|
+
# @api public
|
10
12
|
class Transformer < Proxy
|
11
13
|
VALUE_TRANSFORMER = {
|
12
14
|
:marshal => { :load => '::Marshal.load(VALUE)', :dump => '::Marshal.dump(VALUE)' },
|
15
|
+
:ox => { :load => '::Ox.parse_obj(VALUE)', :dump => '::Ox.dump(VALUE)', :require => 'ox' },
|
13
16
|
:base64 => { :load => "VALUE.unpack('m').first", :dump => "[VALUE].pack('m').strip" },
|
14
17
|
:json => { :load => '::MultiJson.load(VALUE).first', :dump => '::MultiJson.dump([VALUE])', :require => 'multi_json' },
|
15
|
-
:yaml => { :load => '::YAML.load(VALUE)', :dump => '::YAML.dump(VALUE)',
|
18
|
+
:yaml => { :load => '::YAML.load(VALUE)', :dump => '::YAML.dump(VALUE)', :require => 'yaml' },
|
16
19
|
#:tnet => { :load => '::TNetstring.parse(VALUE)', :dump => '::TNetstring.dump(VALUE)', :require => 'tnetstring' },
|
17
20
|
:msgpack => { :load => '::MessagePack.unpack(VALUE)', :dump => '::MessagePack.pack(VALUE)', :require => 'msgpack' },
|
18
|
-
:bson => { :load => '::BSON.deserialize(VALUE)["v"]', :dump => '::BSON.serialize({"v"=>VALUE})',
|
21
|
+
:bson => { :load => '::BSON.deserialize(VALUE)["v"]', :dump => '::BSON.serialize({"v"=>VALUE})', :require => 'bson' },
|
19
22
|
:compress => { :load => '::Zlib::Inflate.inflate(VALUE)', :dump => '::Zlib::Deflate.deflate(VALUE)', :require => 'zlib' },
|
20
23
|
}
|
21
24
|
|
@@ -23,11 +26,12 @@ module Juno
|
|
23
26
|
:base64 => { :transform => "[KEY].pack('m').strip" },
|
24
27
|
:spread => { :transform => '(TMP = KEY; ::File.join(TMP[0..1], TMP[2..-1]))' },
|
25
28
|
:escape => { :transform => "KEY.gsub(/[^a-zA-Z0-9_-]+/) { '%%' + $&.unpack('H2' * $&.bytesize).join('%%').upcase }" },
|
26
|
-
:md5 => { :transform => '::Digest::MD5.hexdigest(KEY)',
|
29
|
+
:md5 => { :transform => '::Digest::MD5.hexdigest(KEY)', :require => 'digest/md5' },
|
27
30
|
:json => { :transform => '(TMP = KEY; String === TMP ? TMP : ::MultiJson.dump(TMP))', :require => 'multi_json' },
|
28
31
|
:bson => { :transform => '(TMP = KEY; String === TMP ? TMP : ::BSON.serialize({"k"=>TMP}).to_s)', :require => 'bson' },
|
29
|
-
:yaml => { :transform => '(TMP = KEY; String === TMP ? TMP : ::YAML.dump(TMP))',
|
32
|
+
:yaml => { :transform => '(TMP = KEY; String === TMP ? TMP : ::YAML.dump(TMP))', :require => 'yaml' },
|
30
33
|
:marshal => { :transform => '(TMP = KEY; String === TMP ? TMP : ::Marshal.dump(TMP))' },
|
34
|
+
:ox => { :transform => '(TMP = KEY; String === TMP ? TMP : ::Ox.dump(TMP))' },
|
31
35
|
#:tnet => { :transform => '(TMP = KEY; String === TMP ? TMP : ::TNetstring.dump(TMP))', :require => 'tnetstring' },
|
32
36
|
:msgpack => { :transform => '(TMP = KEY; String === TMP ? TMP : ::MessagePack.pack(TMP))', :require => 'msgpack' },
|
33
37
|
}
|
@@ -98,6 +102,14 @@ module Juno
|
|
98
102
|
klass
|
99
103
|
end
|
100
104
|
|
105
|
+
# Constructor
|
106
|
+
#
|
107
|
+
# @param [Juno store] store The underlying store
|
108
|
+
# @param [Hash] options
|
109
|
+
#
|
110
|
+
# Options:
|
111
|
+
# * :key - List of key transformers in the order in which they should be applied
|
112
|
+
# * :value - List of value transformers in the order in which they should be applied
|
101
113
|
def new(store, options = {})
|
102
114
|
keys = [options[:key]].flatten.compact
|
103
115
|
values = [options[:value]].flatten.compact
|
data/lib/juno/version.rb
CHANGED
data/lib/juno.rb
CHANGED
@@ -3,6 +3,7 @@ module Juno
|
|
3
3
|
autoload :Builder, 'juno/builder'
|
4
4
|
autoload :Cache, 'juno/cache'
|
5
5
|
autoload :Expires, 'juno/expires'
|
6
|
+
autoload :Lock, 'juno/lock'
|
6
7
|
autoload :Proxy, 'juno/proxy'
|
7
8
|
autoload :Stack, 'juno/stack'
|
8
9
|
autoload :Transformer, 'juno/transformer'
|
@@ -34,15 +35,34 @@ module Juno
|
|
34
35
|
autoload :YAML, 'juno/adapters/yaml'
|
35
36
|
end
|
36
37
|
|
38
|
+
# Create new Juno store with default proxies
|
39
|
+
# which works in most cases if you don't want fine
|
40
|
+
# control over the proxy chain. It uses Marshal on the
|
41
|
+
# keys and values. Use Juno#build if you want to have fine control!
|
42
|
+
#
|
43
|
+
# @param [Symbol] name Name of adapter (See Juno::Adapters)
|
44
|
+
# @param [Hash] options
|
45
|
+
#
|
46
|
+
# Options:
|
47
|
+
# * :expires - Ensure that store supports expiration by inserting
|
48
|
+
# Juno::Expires if the underlying adapter doesn't support it natively
|
49
|
+
# * :threadsafe - Ensure that the store is thread safe by inserting Juno::Lock
|
50
|
+
# * All other options passed to the adapter
|
51
|
+
#
|
52
|
+
# Supported adapters:
|
53
|
+
# * :HashFile (Store which spreads the entries using a md5 hash, e.g. cache/42/391dd7535aebef91b823286ac67fcd)
|
54
|
+
# * :File (normal file store)
|
55
|
+
# * :Memcached (Memcached store)
|
56
|
+
# * ... (All other adapters from Juno::Adapters)
|
37
57
|
def self.new(name, options = {})
|
38
58
|
expires = options.delete(:expires)
|
59
|
+
threadsafe = options.delete(:threadsafe)
|
39
60
|
transformer = {:key => :marshal, :value => :marshal}
|
40
61
|
raise 'Name must be Symbol' unless Symbol === name
|
41
62
|
case name
|
42
63
|
when :Sequel, :ActiveRecord, :Couch
|
43
64
|
# Sequel accept only base64 keys and values
|
44
|
-
# FIXME:
|
45
|
-
# raises an error on 1.9
|
65
|
+
# FIXME: Couch should work only with :marshal but this raises an error on 1.9
|
46
66
|
transformer = {:key => [:marshal, :base64], :value => [:marshal, :base64]}
|
47
67
|
when :Memcached, :MemcachedDalli, :MemcachedNative
|
48
68
|
# Memcached accept only base64 keys, expires already supported
|
@@ -65,10 +85,21 @@ module Juno
|
|
65
85
|
build(options) do
|
66
86
|
use :Expires if expires
|
67
87
|
use :Transformer, transformer
|
88
|
+
use :Lock if threadsafe
|
68
89
|
adapter name
|
69
90
|
end
|
70
91
|
end
|
71
92
|
|
93
|
+
# Build your own store chain!
|
94
|
+
#
|
95
|
+
# @params [Hash] options Options passed to the proxies and adapter
|
96
|
+
#
|
97
|
+
# Example:
|
98
|
+
#
|
99
|
+
# Juno.build do
|
100
|
+
# use :Expires
|
101
|
+
# adapter :Memory
|
102
|
+
# end
|
72
103
|
def self.build(options = {}, &block)
|
73
104
|
Builder.new(options, &block).build
|
74
105
|
end
|
@@ -1,41 +1,27 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
before do
|
9
|
-
@store = Juno::Adapters::ActiveRecord.new(:connection => { :adapter => (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'), :database => File.join(make_tempdir, 'adapter_activerecord') })
|
10
|
-
@store.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@store.close.should == nil if @store
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
-
|
21
|
-
it 'updates an existing key/value' do
|
22
|
-
@store['foo/bar'] = '1'
|
23
|
-
@store['foo/bar'] = '2'
|
24
|
-
records = @store.table.find :all, :conditions => { :k => 'foo/bar' }
|
25
|
-
records.count.should == 1
|
26
|
-
end
|
4
|
+
describe_juno "adapter_activerecord" do
|
5
|
+
def new_store
|
6
|
+
Juno::Adapters::ActiveRecord.new(:connection => { :adapter => (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'), :database => File.join(make_tempdir, 'adapter_activerecord') })
|
7
|
+
end
|
27
8
|
|
28
|
-
|
29
|
-
|
9
|
+
include_context 'setup_store'
|
10
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
11
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
12
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
13
|
+
it 'updates an existing key/value' do
|
14
|
+
store['foo/bar'] = '1'
|
15
|
+
store['foo/bar'] = '2'
|
16
|
+
records = store.table.find :all, :conditions => { :k => 'foo/bar' }
|
17
|
+
records.count.should == 1
|
18
|
+
end
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
end
|
20
|
+
it 'uses an existing connection' do
|
21
|
+
ActiveRecord::Base.establish_connection :adapter => (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'), :database => File.join(make_tempdir, 'activerecord-existing')
|
34
22
|
|
23
|
+
store = Juno::Adapters::ActiveRecord.new
|
24
|
+
store.table.table_exists?.should == true
|
35
25
|
end
|
36
|
-
|
37
|
-
puts "Test adapter_activerecord not executed: #{ex.message}"
|
38
|
-
rescue Exception => ex
|
39
|
-
puts "Test adapter_activerecord not executed: #{ex.message}"
|
40
|
-
#puts "#{ex.backtrace.join("\n")}"
|
26
|
+
|
41
27
|
end
|
@@ -1,27 +1,13 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe "adapter_cassandra" do
|
8
|
-
before do
|
9
|
-
@store = Juno::Adapters::Cassandra.new
|
10
|
-
@store.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@store.close.should == nil if @store
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
-
|
4
|
+
describe_juno "adapter_cassandra" do
|
5
|
+
def new_store
|
6
|
+
Juno::Adapters::Cassandra.new
|
21
7
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
|
9
|
+
include_context 'setup_store'
|
10
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
11
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
12
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
27
13
|
end
|
data/spec/adapter_couch_spec.rb
CHANGED
@@ -1,27 +1,13 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe "adapter_couch" do
|
8
|
-
before do
|
9
|
-
@store = Juno::Adapters::Couch.new(:db => 'adapter_couch')
|
10
|
-
@store.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@store.close.should == nil if @store
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
-
|
4
|
+
describe_juno "adapter_couch" do
|
5
|
+
def new_store
|
6
|
+
Juno::Adapters::Couch.new(:db => 'adapter_couch')
|
21
7
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
|
9
|
+
include_context 'setup_store'
|
10
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
11
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
12
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
27
13
|
end
|
@@ -1,61 +1,47 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
4
|
+
describe_juno "adapter_datamapper" do
|
5
5
|
require 'dm-core'
|
6
6
|
DataMapper.setup(:default, :adapter => :in_memory)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
before do
|
11
|
-
@store = Juno::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/adapter_datamapper")
|
12
|
-
@store.clear
|
13
|
-
end
|
14
|
-
|
15
|
-
after do
|
16
|
-
@store.close.should == nil if @store
|
17
|
-
end
|
18
|
-
|
19
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
20
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
22
|
-
it_should_behave_like 'returndifferent_stringkey_objectvalue'
|
23
|
-
it_should_behave_like 'null_stringkey_objectvalue'
|
24
|
-
it_should_behave_like 'store_stringkey_objectvalue'
|
25
|
-
|
26
|
-
it 'does not cross contaminate when storing' do
|
27
|
-
first = Juno::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/datamapper-first")
|
28
|
-
first.clear
|
29
|
-
|
30
|
-
second = Juno::Adapters::DataMapper.new(:repository => :sample, :setup => "sqlite3://#{make_tempdir}/datamapper-second")
|
31
|
-
second.clear
|
32
|
-
|
33
|
-
first['key'] = 'value'
|
34
|
-
second['key'] = 'value2'
|
35
|
-
|
36
|
-
first['key'].should == 'value'
|
37
|
-
second['key'].should == 'value2'
|
38
|
-
end
|
7
|
+
def new_store
|
8
|
+
Juno::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/adapter_datamapper")
|
9
|
+
end
|
39
10
|
|
40
|
-
|
41
|
-
|
42
|
-
|
11
|
+
include_context 'setup_store'
|
12
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
13
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
14
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'returndifferent_stringkey_objectvalue'
|
16
|
+
it_should_behave_like 'null_stringkey_objectvalue'
|
17
|
+
it_should_behave_like 'store_stringkey_objectvalue'
|
18
|
+
it 'does not cross contaminate when storing' do
|
19
|
+
first = Juno::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/datamapper-first")
|
20
|
+
first.clear
|
21
|
+
|
22
|
+
second = Juno::Adapters::DataMapper.new(:repository => :sample, :setup => "sqlite3://#{make_tempdir}/datamapper-second")
|
23
|
+
second.clear
|
24
|
+
|
25
|
+
first['key'] = 'value'
|
26
|
+
second['key'] = 'value2'
|
27
|
+
|
28
|
+
first['key'].should == 'value'
|
29
|
+
second['key'].should == 'value2'
|
30
|
+
end
|
43
31
|
|
44
|
-
|
45
|
-
|
32
|
+
it 'does not cross contaminate when deleting' do
|
33
|
+
first = Juno::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/datamapper-first")
|
34
|
+
first.clear
|
46
35
|
|
47
|
-
|
48
|
-
|
36
|
+
second = Juno::Adapters::DataMapper.new(:repository => :sample, :setup => "sqlite3://#{make_tempdir}/datamapper-second")
|
37
|
+
second.clear
|
49
38
|
|
50
|
-
|
51
|
-
|
52
|
-
second['key'].should == 'value2'
|
53
|
-
end
|
39
|
+
first['key'] = 'value'
|
40
|
+
second['key'] = 'value2'
|
54
41
|
|
42
|
+
first.delete('key').should == 'value'
|
43
|
+
first.key?('key').should == false
|
44
|
+
second['key'].should == 'value2'
|
55
45
|
end
|
56
|
-
|
57
|
-
puts "Test adapter_datamapper not executed: #{ex.message}"
|
58
|
-
rescue Exception => ex
|
59
|
-
puts "Test adapter_datamapper not executed: #{ex.message}"
|
60
|
-
#puts "#{ex.backtrace.join("\n")}"
|
46
|
+
|
61
47
|
end
|
data/spec/adapter_dbm_spec.rb
CHANGED
@@ -1,27 +1,13 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe "adapter_dbm" do
|
8
|
-
before do
|
9
|
-
@store = Juno::Adapters::DBM.new(:file => File.join(make_tempdir, "adapter_dbm"))
|
10
|
-
@store.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@store.close.should == nil if @store
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
-
|
4
|
+
describe_juno "adapter_dbm" do
|
5
|
+
def new_store
|
6
|
+
Juno::Adapters::DBM.new(:file => File.join(make_tempdir, "adapter_dbm"))
|
21
7
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
|
9
|
+
include_context 'setup_store'
|
10
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
11
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
12
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
27
13
|
end
|
data/spec/adapter_file_spec.rb
CHANGED
@@ -1,27 +1,13 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe "adapter_file" do
|
8
|
-
before do
|
9
|
-
@store = Juno::Adapters::File.new(:dir => File.join(make_tempdir, "adapter_file"))
|
10
|
-
@store.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@store.close.should == nil if @store
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
-
|
4
|
+
describe_juno "adapter_file" do
|
5
|
+
def new_store
|
6
|
+
Juno::Adapters::File.new(:dir => File.join(make_tempdir, "adapter_file"))
|
21
7
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
|
9
|
+
include_context 'setup_store'
|
10
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
11
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
12
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
27
13
|
end
|
data/spec/adapter_fog_spec.rb
CHANGED
@@ -1,35 +1,18 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
4
|
+
describe_juno "adapter_fog" do
|
5
5
|
require 'fog'
|
6
6
|
Fog.mock!
|
7
|
-
|
8
|
-
:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
describe "adapter_fog" do
|
13
|
-
before do
|
14
|
-
@store = Juno::Adapters::Fog.new(:aws_access_key_id => 'fake_access_key_id',
|
15
|
-
:aws_secret_access_key => 'fake_secret_access_key',
|
16
|
-
:provider => 'AWS',
|
17
|
-
:dir => 'juno')
|
18
|
-
@store.clear
|
19
|
-
end
|
20
|
-
|
21
|
-
after do
|
22
|
-
@store.close.should == nil if @store
|
23
|
-
end
|
24
|
-
|
25
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
26
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
27
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
28
|
-
|
7
|
+
def new_store
|
8
|
+
Juno::Adapters::Fog.new(:aws_access_key_id => 'fake_access_key_id',
|
9
|
+
:aws_secret_access_key => 'fake_secret_access_key',
|
10
|
+
:provider => 'AWS',
|
11
|
+
:dir => 'juno')
|
29
12
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
13
|
+
|
14
|
+
include_context 'setup_store'
|
15
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
35
18
|
end
|
data/spec/adapter_gdbm_spec.rb
CHANGED
@@ -1,27 +1,13 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe "adapter_gdbm" do
|
8
|
-
before do
|
9
|
-
@store = Juno::Adapters::GDBM.new(:file => File.join(make_tempdir, "adapter_gdbm"))
|
10
|
-
@store.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@store.close.should == nil if @store
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
-
|
4
|
+
describe_juno "adapter_gdbm" do
|
5
|
+
def new_store
|
6
|
+
Juno::Adapters::GDBM.new(:file => File.join(make_tempdir, "adapter_gdbm"))
|
21
7
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
|
9
|
+
include_context 'setup_store'
|
10
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
11
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
12
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
27
13
|
end
|
@@ -1,27 +1,13 @@
|
|
1
|
-
# Generated
|
1
|
+
# Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
|
2
2
|
require 'helper'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe "adapter_localmemcache" do
|
8
|
-
before do
|
9
|
-
@store = Juno::Adapters::LocalMemCache.new(:file => File.join(make_tempdir, "adapter_localmemcache"))
|
10
|
-
@store.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
after do
|
14
|
-
@store.close.should == nil if @store
|
15
|
-
end
|
16
|
-
|
17
|
-
it_should_behave_like 'null_stringkey_stringvalue'
|
18
|
-
it_should_behave_like 'store_stringkey_stringvalue'
|
19
|
-
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
20
|
-
|
4
|
+
describe_juno "adapter_localmemcache" do
|
5
|
+
def new_store
|
6
|
+
Juno::Adapters::LocalMemCache.new(:file => File.join(make_tempdir, "adapter_localmemcache"))
|
21
7
|
end
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
|
9
|
+
include_context 'setup_store'
|
10
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
11
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
12
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
27
13
|
end
|