juno 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/.travis.yml +2 -4
  2. data/Gemfile +3 -1
  3. data/README.md +40 -8
  4. data/benchmarks/run.rb +17 -5
  5. data/lib/juno/adapters/activerecord.rb +23 -14
  6. data/lib/juno/adapters/cassandra.rb +11 -0
  7. data/lib/juno/adapters/couch.rb +9 -0
  8. data/lib/juno/adapters/datamapper.rb +10 -0
  9. data/lib/juno/adapters/dbm.rb +8 -0
  10. data/lib/juno/adapters/file.rb +2 -0
  11. data/lib/juno/adapters/fog.rb +9 -0
  12. data/lib/juno/adapters/gdbm.rb +8 -0
  13. data/lib/juno/adapters/localmemcache.rb +8 -0
  14. data/lib/juno/adapters/lruhash.rb +8 -0
  15. data/lib/juno/adapters/memcached_dalli.rb +9 -0
  16. data/lib/juno/adapters/memcached_native.rb +10 -0
  17. data/lib/juno/adapters/memory.rb +2 -0
  18. data/lib/juno/adapters/mongo.rb +11 -0
  19. data/lib/juno/adapters/null.rb +2 -0
  20. data/lib/juno/adapters/pstore.rb +9 -2
  21. data/lib/juno/adapters/redis.rb +5 -0
  22. data/lib/juno/adapters/riak.rb +9 -0
  23. data/lib/juno/adapters/sdbm.rb +8 -0
  24. data/lib/juno/adapters/sequel.rb +10 -0
  25. data/lib/juno/adapters/sqlite.rb +9 -0
  26. data/lib/juno/adapters/tokyocabinet.rb +16 -4
  27. data/lib/juno/adapters/yaml.rb +2 -0
  28. data/lib/juno/base.rb +1 -0
  29. data/lib/juno/builder.rb +2 -0
  30. data/lib/juno/cache.rb +2 -0
  31. data/lib/juno/expires.rb +1 -0
  32. data/lib/juno/lock.rb +37 -0
  33. data/lib/juno/proxy.rb +1 -0
  34. data/lib/juno/stack.rb +2 -0
  35. data/lib/juno/transformer.rb +16 -4
  36. data/lib/juno/version.rb +3 -1
  37. data/lib/juno.rb +33 -2
  38. data/spec/adapter_activerecord_spec.rb +20 -34
  39. data/spec/adapter_cassandra_spec.rb +9 -23
  40. data/spec/adapter_couch_spec.rb +9 -23
  41. data/spec/adapter_datamapper_spec.rb +36 -50
  42. data/spec/adapter_dbm_spec.rb +9 -23
  43. data/spec/adapter_file_spec.rb +9 -23
  44. data/spec/adapter_fog_spec.rb +12 -29
  45. data/spec/adapter_gdbm_spec.rb +9 -23
  46. data/spec/adapter_localmemcache_spec.rb +9 -23
  47. data/spec/adapter_lruhash_spec.rb +24 -38
  48. data/spec/adapter_memcached_dalli_spec.rb +10 -24
  49. data/spec/adapter_memcached_native_spec.rb +10 -24
  50. data/spec/adapter_memcached_spec.rb +10 -24
  51. data/spec/adapter_memory_spec.rb +24 -38
  52. data/spec/adapter_mongo_spec.rb +9 -23
  53. data/spec/adapter_pstore_spec.rb +12 -26
  54. data/spec/adapter_redis_spec.rb +10 -24
  55. data/spec/adapter_riak_spec.rb +9 -23
  56. data/spec/adapter_sdbm_spec.rb +9 -23
  57. data/spec/adapter_sequel_spec.rb +9 -23
  58. data/spec/adapter_sqlite_spec.rb +9 -23
  59. data/spec/adapter_tokyocabinet_bdb_spec.rb +13 -0
  60. data/spec/adapter_tokyocabinet_hdb_spec.rb +13 -0
  61. data/spec/adapter_yaml_spec.rb +12 -26
  62. data/spec/cache_file_memory_spec.rb +22 -43
  63. data/spec/cache_memory_null_spec.rb +13 -34
  64. data/spec/expires_file_spec.rb +56 -76
  65. data/spec/expires_memory_spec.rb +35 -54
  66. data/spec/generate.rb +147 -160
  67. data/spec/helper.rb +39 -0
  68. data/spec/junospecs.rb +612 -610
  69. data/spec/lock_spec.rb +31 -0
  70. data/spec/null_adapter_spec.rb +15 -29
  71. data/spec/proxy_expires_memory_spec.rb +37 -58
  72. data/spec/proxy_redis_spec.rb +13 -33
  73. data/spec/simple_activerecord_spec.rb +34 -48
  74. data/spec/simple_activerecord_with_expires_spec.rb +35 -49
  75. data/spec/simple_cassandra_spec.rb +35 -49
  76. data/spec/simple_couch_spec.rb +34 -48
  77. data/spec/simple_couch_with_expires_spec.rb +35 -49
  78. data/spec/simple_datamapper_spec.rb +34 -48
  79. data/spec/simple_datamapper_with_expires_spec.rb +35 -49
  80. data/spec/simple_datamapper_with_repository_spec.rb +34 -48
  81. data/spec/simple_dbm_spec.rb +34 -48
  82. data/spec/simple_dbm_with_expires_spec.rb +35 -49
  83. data/spec/simple_file_spec.rb +34 -48
  84. data/spec/simple_file_with_expires_spec.rb +35 -49
  85. data/spec/simple_fog_spec.rb +37 -54
  86. data/spec/simple_fog_with_expires_spec.rb +39 -57
  87. data/spec/simple_gdbm_spec.rb +34 -48
  88. data/spec/simple_gdbm_with_expires_spec.rb +35 -49
  89. data/spec/simple_hashfile_spec.rb +34 -48
  90. data/spec/simple_hashfile_with_expires_spec.rb +35 -49
  91. data/spec/simple_localmemcache_spec.rb +34 -48
  92. data/spec/simple_localmemcache_with_expires_spec.rb +35 -49
  93. data/spec/simple_lruhash_spec.rb +34 -48
  94. data/spec/simple_lruhash_with_expires_spec.rb +35 -49
  95. data/spec/simple_memcached_dalli_spec.rb +35 -49
  96. data/spec/simple_memcached_native_spec.rb +35 -49
  97. data/spec/simple_memcached_spec.rb +35 -49
  98. data/spec/simple_memory_spec.rb +34 -48
  99. data/spec/simple_memory_with_expires_spec.rb +35 -49
  100. data/spec/simple_mongo_spec.rb +34 -48
  101. data/spec/simple_mongo_with_expires_spec.rb +35 -49
  102. data/spec/simple_null_spec.rb +25 -39
  103. data/spec/simple_pstore_spec.rb +34 -48
  104. data/spec/simple_pstore_with_expires_spec.rb +35 -49
  105. data/spec/simple_redis_spec.rb +35 -49
  106. data/spec/simple_riak_spec.rb +34 -48
  107. data/spec/simple_riak_with_expires_spec.rb +35 -49
  108. data/spec/simple_sdbm_spec.rb +34 -48
  109. data/spec/simple_sdbm_with_expires_spec.rb +35 -49
  110. data/spec/simple_sequel_spec.rb +34 -48
  111. data/spec/simple_sequel_with_expires_spec.rb +35 -49
  112. data/spec/simple_sqlite_spec.rb +34 -48
  113. data/spec/simple_sqlite_with_expires_spec.rb +35 -49
  114. data/spec/simple_tokyocabinet_spec.rb +34 -48
  115. data/spec/simple_tokyocabinet_with_expires_spec.rb +35 -49
  116. data/spec/simple_yaml_spec.rb +34 -48
  117. data/spec/simple_yaml_with_expires_spec.rb +35 -49
  118. data/spec/stack_file_memory_spec.rb +15 -38
  119. data/spec/stack_memory_file_spec.rb +14 -37
  120. data/spec/transformer_bson_spec.rb +20 -39
  121. data/spec/transformer_compress_spec.rb +17 -36
  122. data/spec/transformer_json_spec.rb +20 -39
  123. data/spec/transformer_marshal_base64_spec.rb +36 -55
  124. data/spec/transformer_marshal_escape_spec.rb +36 -55
  125. data/spec/transformer_marshal_md5_spec.rb +36 -55
  126. data/spec/transformer_marshal_md5_spread_spec.rb +36 -55
  127. data/spec/transformer_msgpack_spec.rb +20 -39
  128. data/spec/transformer_ox_spec.rb +40 -0
  129. data/spec/transformer_yaml_spec.rb +35 -54
  130. metadata +11 -6
  131. data/spec/adapter_tokyocabinet_spec.rb +0 -27
  132. 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
@@ -1,5 +1,6 @@
1
1
  module Juno
2
2
  # Proxy base class
3
+ # @api public
3
4
  class Proxy < Base
4
5
  attr_reader :adapter
5
6
 
data/lib/juno/stack.rb CHANGED
@@ -11,6 +11,8 @@ module Juno
11
11
  # add { adapter :File, :dir => 'replicate' }
12
12
  # end
13
13
  # end
14
+ #
15
+ # @api public
14
16
  class Stack < Base
15
17
  class DSL
16
18
  attr_reader :stack
@@ -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)', :require => 'yaml' },
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})', :require => 'bson' },
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)', :require => 'digest/md5' },
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))', :require => 'yaml' },
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
@@ -1,3 +1,5 @@
1
1
  module Juno
2
- VERSION = '0.2.3'
2
+ # Juno version number
3
+ # @api public
4
+ VERSION = '0.2.4'
3
5
  end
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: ActiveRecord and Couch should work only with :marshal but this
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 file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
5
- Juno::Adapters::ActiveRecord.new(:connection => { :adapter => (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'), :database => File.join(make_tempdir, 'adapter_activerecord') }).close
6
-
7
- describe "adapter_activerecord" do
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
- it 'uses an existing connection' do
29
- ActiveRecord::Base.establish_connection :adapter => (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'), :database => File.join(make_tempdir, 'activerecord-existing')
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
- store = Juno::Adapters::ActiveRecord.new
32
- store.table.table_exists?.should == true
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
- rescue LoadError => ex
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 file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
5
- Juno::Adapters::Cassandra.new.close
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
- rescue LoadError => ex
23
- puts "Test adapter_cassandra not executed: #{ex.message}"
24
- rescue Exception => ex
25
- puts "Test adapter_cassandra not executed: #{ex.message}"
26
- #puts "#{ex.backtrace.join("\n")}"
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 file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
5
- Juno::Adapters::Couch.new(:db => 'adapter_couch').close
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
- rescue LoadError => ex
23
- puts "Test adapter_couch not executed: #{ex.message}"
24
- rescue Exception => ex
25
- puts "Test adapter_couch not executed: #{ex.message}"
26
- #puts "#{ex.backtrace.join("\n")}"
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 file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
4
+ describe_juno "adapter_datamapper" do
5
5
  require 'dm-core'
6
6
  DataMapper.setup(:default, :adapter => :in_memory)
7
- Juno::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/adapter_datamapper").close
8
-
9
- describe "adapter_datamapper" do
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
- it 'does not cross contaminate when deleting' do
41
- first = Juno::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/datamapper-first")
42
- first.clear
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
- second = Juno::Adapters::DataMapper.new(:repository => :sample, :setup => "sqlite3://#{make_tempdir}/datamapper-second")
45
- second.clear
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
- first['key'] = 'value'
48
- second['key'] = 'value2'
36
+ second = Juno::Adapters::DataMapper.new(:repository => :sample, :setup => "sqlite3://#{make_tempdir}/datamapper-second")
37
+ second.clear
49
38
 
50
- first.delete('key').should == 'value'
51
- first.key?('key').should == false
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
- rescue LoadError => ex
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
@@ -1,27 +1,13 @@
1
- # Generated file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
5
- Juno::Adapters::DBM.new(:file => File.join(make_tempdir, "adapter_dbm")).close
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
- rescue LoadError => ex
23
- puts "Test adapter_dbm not executed: #{ex.message}"
24
- rescue Exception => ex
25
- puts "Test adapter_dbm not executed: #{ex.message}"
26
- #puts "#{ex.backtrace.join("\n")}"
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 file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
5
- Juno::Adapters::File.new(:dir => File.join(make_tempdir, "adapter_file")).close
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
- rescue LoadError => ex
23
- puts "Test adapter_file not executed: #{ex.message}"
24
- rescue Exception => ex
25
- puts "Test adapter_file not executed: #{ex.message}"
26
- #puts "#{ex.backtrace.join("\n")}"
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,35 +1,18 @@
1
- # Generated file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
4
+ describe_juno "adapter_fog" do
5
5
  require 'fog'
6
6
  Fog.mock!
7
- Juno::Adapters::Fog.new(:aws_access_key_id => 'fake_access_key_id',
8
- :aws_secret_access_key => 'fake_secret_access_key',
9
- :provider => 'AWS',
10
- :dir => 'juno').close
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
- rescue LoadError => ex
31
- puts "Test adapter_fog not executed: #{ex.message}"
32
- rescue Exception => ex
33
- puts "Test adapter_fog not executed: #{ex.message}"
34
- #puts "#{ex.backtrace.join("\n")}"
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
@@ -1,27 +1,13 @@
1
- # Generated file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
5
- Juno::Adapters::GDBM.new(:file => File.join(make_tempdir, "adapter_gdbm")).close
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
- rescue LoadError => ex
23
- puts "Test adapter_gdbm not executed: #{ex.message}"
24
- rescue Exception => ex
25
- puts "Test adapter_gdbm not executed: #{ex.message}"
26
- #puts "#{ex.backtrace.join("\n")}"
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 file
1
+ # Generated by generate.rb at 2012-12-02 18:03:24 +0100, heads/master-0-g9a90bb4
2
2
  require 'helper'
3
3
 
4
- begin
5
- Juno::Adapters::LocalMemCache.new(:file => File.join(make_tempdir, "adapter_localmemcache")).close
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
- rescue LoadError => ex
23
- puts "Test adapter_localmemcache not executed: #{ex.message}"
24
- rescue Exception => ex
25
- puts "Test adapter_localmemcache not executed: #{ex.message}"
26
- #puts "#{ex.backtrace.join("\n")}"
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