juno 0.2.2 → 0.2.3

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.
@@ -4,8 +4,7 @@ module Juno
4
4
  module Adapters
5
5
  class LRUHash < Memory
6
6
  def initialize(options = {})
7
- raise 'No option :max_size specified' unless options[:max_size]
8
- @memory = Hashery::LRUHash.new(options[:max_size])
7
+ @memory = Hashery::LRUHash.new(options[:max_size] || 1024)
9
8
  end
10
9
  end
11
10
  end
@@ -9,13 +9,14 @@ module Juno
9
9
  # end
10
10
  class Transformer < Proxy
11
11
  VALUE_TRANSFORMER = {
12
- :marshal => { :load => '::Marshal.load(VALUE)', :dump => '::Marshal.dump(VALUE)' },
13
- :base64 => { :load => "VALUE.unpack('m').first", :dump => "[VALUE].pack('m').strip" },
14
- :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' },
12
+ :marshal => { :load => '::Marshal.load(VALUE)', :dump => '::Marshal.dump(VALUE)' },
13
+ :base64 => { :load => "VALUE.unpack('m').first", :dump => "[VALUE].pack('m').strip" },
14
+ :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' },
16
16
  #:tnet => { :load => '::TNetstring.parse(VALUE)', :dump => '::TNetstring.dump(VALUE)', :require => 'tnetstring' },
17
- :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' },
17
+ :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' },
19
+ :compress => { :load => '::Zlib::Inflate.inflate(VALUE)', :dump => '::Zlib::Deflate.deflate(VALUE)', :require => 'zlib' },
19
20
  }
20
21
 
21
22
  KEY_TRANSFORMER = {
@@ -27,7 +28,7 @@ module Juno
27
28
  :bson => { :transform => '(TMP = KEY; String === TMP ? TMP : ::BSON.serialize({"k"=>TMP}).to_s)', :require => 'bson' },
28
29
  :yaml => { :transform => '(TMP = KEY; String === TMP ? TMP : ::YAML.dump(TMP))', :require => 'yaml' },
29
30
  :marshal => { :transform => '(TMP = KEY; String === TMP ? TMP : ::Marshal.dump(TMP))' },
30
- #:tnet => { :transform => '(TMP = KEY; String === TMP ? TMP : ::TNetstring.dump(TMP))', :require => 'tnetstring' },
31
+ #:tnet => { :transform => '(TMP = KEY; String === TMP ? TMP : ::TNetstring.dump(TMP))', :require => 'tnetstring' },
31
32
  :msgpack => { :transform => '(TMP = KEY; String === TMP ? TMP : ::MessagePack.pack(TMP))', :require => 'msgpack' },
32
33
  }
33
34
 
@@ -1,3 +1,3 @@
1
1
  module Juno
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
@@ -2,11 +2,11 @@
2
2
  require 'helper'
3
3
 
4
4
  begin
5
- Juno::Adapters::LRUHash.new(:max_size => 10).close
5
+ Juno::Adapters::LRUHash.new.close
6
6
 
7
7
  describe "adapter_lruhash" do
8
8
  before do
9
- @store = Juno::Adapters::LRUHash.new(:max_size => 10)
9
+ @store = Juno::Adapters::LRUHash.new
10
10
  @store.clear
11
11
  end
12
12
 
@@ -13,11 +13,10 @@ TESTS = {
13
13
  },
14
14
  'simple_lruhash' => {
15
15
  :store => :LRUHash,
16
- :options => ':max_size => 10',
17
16
  },
18
17
  'simple_lruhash_with_expires' => {
19
18
  :store => :LRUHash,
20
- :options => ':expires => true, :max_size => 10',
19
+ :options => ':expires => true',
21
20
  :specs => EXPIRES_SPECS,
22
21
  },
23
22
  'simple_file' => {
@@ -333,6 +332,15 @@ Juno.build do
333
332
  end},
334
333
  :specs => [:null_stringkey_stringvalue, :store_stringkey_stringvalue]
335
334
  },
335
+ 'transformer_compress' => {
336
+ :build => %{
337
+ Juno.build do
338
+ use :Transformer, :value => :compress
339
+ adapter :Memory
340
+ end},
341
+ :value => %w(String),
342
+ :specs => [:null, :store, :returndifferent]
343
+ },
336
344
  'transformer_json' => {
337
345
  :build => %{
338
346
  Juno.build do
@@ -520,7 +528,7 @@ end
520
528
  :specs => [:null, :store]
521
529
  },
522
530
  'adapter_lruhash' => {
523
- :build => 'Juno::Adapters::LRUHash.new(:max_size => 10)',
531
+ :build => 'Juno::Adapters::LRUHash.new',
524
532
  :specs => [:null, :store]
525
533
  },
526
534
  'adapter_mongo' => {
@@ -2,11 +2,11 @@
2
2
  require 'helper'
3
3
 
4
4
  begin
5
- Juno.new(:LRUHash, :max_size => 10).close
5
+ Juno.new(:LRUHash).close
6
6
 
7
7
  describe "simple_lruhash" do
8
8
  before do
9
- @store = Juno.new(:LRUHash, :max_size => 10)
9
+ @store = Juno.new(:LRUHash)
10
10
  @store.clear
11
11
  end
12
12
 
@@ -2,11 +2,11 @@
2
2
  require 'helper'
3
3
 
4
4
  begin
5
- Juno.new(:LRUHash, :expires => true, :max_size => 10).close
5
+ Juno.new(:LRUHash, :expires => true).close
6
6
 
7
7
  describe "simple_lruhash_with_expires" do
8
8
  before do
9
- @store = Juno.new(:LRUHash, :expires => true, :max_size => 10)
9
+ @store = Juno.new(:LRUHash, :expires => true)
10
10
  @store.clear
11
11
  end
12
12
 
@@ -0,0 +1,41 @@
1
+ # Generated file
2
+ require 'helper'
3
+
4
+ begin
5
+
6
+ Juno.build do
7
+ use :Transformer, :value => :compress
8
+ adapter :Memory
9
+ end.close
10
+
11
+ describe "transformer_compress" do
12
+ before do
13
+ @store =
14
+ Juno.build do
15
+ use :Transformer, :value => :compress
16
+ adapter :Memory
17
+ end
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_objectkey_stringvalue'
26
+ it_should_behave_like 'null_stringkey_stringvalue'
27
+ it_should_behave_like 'null_hashkey_stringvalue'
28
+ it_should_behave_like 'store_objectkey_stringvalue'
29
+ it_should_behave_like 'store_stringkey_stringvalue'
30
+ it_should_behave_like 'store_hashkey_stringvalue'
31
+ it_should_behave_like 'returndifferent_objectkey_stringvalue'
32
+ it_should_behave_like 'returndifferent_stringkey_stringvalue'
33
+ it_should_behave_like 'returndifferent_hashkey_stringvalue'
34
+
35
+ end
36
+ rescue LoadError => ex
37
+ puts "Test transformer_compress not executed: #{ex.message}"
38
+ rescue Exception => ex
39
+ puts "Test transformer_compress not executed: #{ex.message}"
40
+ #puts "#{ex.backtrace.join("\n")}"
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juno
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-11-26 00:00:00.000000000 Z
14
+ date: 2012-11-28 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: A unified interface to key/value stores (moneta replacement)
17
17
  email:
@@ -149,6 +149,7 @@ files:
149
149
  - spec/stack_file_memory_spec.rb
150
150
  - spec/stack_memory_file_spec.rb
151
151
  - spec/transformer_bson_spec.rb
152
+ - spec/transformer_compress_spec.rb
152
153
  - spec/transformer_json_spec.rb
153
154
  - spec/transformer_marshal_base64_spec.rb
154
155
  - spec/transformer_marshal_escape_spec.rb
@@ -264,6 +265,7 @@ test_files:
264
265
  - spec/stack_file_memory_spec.rb
265
266
  - spec/stack_memory_file_spec.rb
266
267
  - spec/transformer_bson_spec.rb
268
+ - spec/transformer_compress_spec.rb
267
269
  - spec/transformer_json_spec.rb
268
270
  - spec/transformer_marshal_base64_spec.rb
269
271
  - spec/transformer_marshal_escape_spec.rb