honkster-bin 0.6.3.3 → 0.6.3.4

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.
data/Rakefile CHANGED
@@ -9,10 +9,6 @@ namespace :spec do
9
9
  t.verbose = true
10
10
  end
11
11
 
12
- task :as2 do
13
- sh 'ACTIVE_SUPPORT_VERSION="<= 2.3.8" rake spec:all'
14
- end
15
-
16
12
  task :as3 do
17
13
  sh 'ACTIVE_SUPPORT_VERSION=">= 3.0.0.beta3" rake spec:all'
18
14
  end
@@ -20,7 +16,6 @@ end
20
16
 
21
17
  desc 'Runs all specs against Active Support 2 and 3'
22
18
  task :spec do
23
- Rake::Task['spec:as2'].invoke
24
19
  Rake::Task['spec:as3'].invoke
25
20
  end
26
21
 
data/lib/bin/store.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
  module Bin
3
- class Store < Compatibility
3
+ class Store < ActiveSupport::Cache::Store
4
4
  attr_reader :collection, :options
5
5
 
6
6
  def initialize(collection, options={})
@@ -11,23 +11,21 @@ module Bin
11
11
  @expires_in ||= options[:expires_in] || 1.year
12
12
  end
13
13
 
14
- def write(key, value, options={})
14
+ def write_entry(key, entry, options={})
15
15
  key = key.to_s
16
- super do
17
- expires = Time.now.utc + ((options && options[:expires_in]) || expires_in)
18
- raw = !!options[:raw]
19
- value = raw ? value : BSON::Binary.new(Marshal.dump(value))
20
- doc = {:_id => key, :value => value, :expires_at => expires, :raw => raw}
21
- collection.save(doc)
22
- end
16
+ value = entry.value
17
+ expires = Time.now.utc + ((options && options[:expires_in]) || expires_in)
18
+ raw = !!options[:raw]
19
+ value = raw ? value : BSON::Binary.new(Marshal.dump(value))
20
+ doc = {:_id => key, :value => value, :expires_at => expires, :raw => raw}
21
+ collection.save(doc)
23
22
  end
24
23
  alias_method :write_entry, :write
25
24
 
26
- def read(key, options=nil)
27
- super do
28
- if doc = collection.find_one(:_id => key.to_s, :expires_at => {'$gt' => Time.now.utc})
29
- doc['raw'] ? doc['value'] : Marshal.load(doc['value'].to_s)
30
- end
25
+ def read_entry(key, options=nil)
26
+ if doc = collection.find_one(:_id => key.to_s, :expires_at => {'$gt' => Time.now.utc})
27
+ value = doc['raw'] ? doc['value'] : Marshal.load(doc['value'].to_s)
28
+ value.is_a?(ActiveSupport::Cache::Entry) ? value : ActiveSupport::Cache::Entry.new(value, options)
31
29
  end
32
30
  end
33
31
  alias_method :read_entry, :read
@@ -39,9 +37,11 @@ module Bin
39
37
  end
40
38
 
41
39
  def delete_matched(matcher, options=nil)
42
- super do
43
- collection.remove(:_id => matcher)
44
- end
40
+ collection.remove(:_id => matcher)
41
+ end
42
+
43
+ def delete_entry(key, options)
44
+ collection.remove(:_id => key.to_s)
45
45
  end
46
46
 
47
47
  def exist?(key, options=nil)
@@ -51,15 +51,11 @@ module Bin
51
51
  end
52
52
 
53
53
  def increment(key, amount=1)
54
- super do
55
- counter_key_upsert(key, amount)
56
- end
54
+ counter_key_upsert(key, amount)
57
55
  end
58
56
 
59
57
  def decrement(key, amount=1)
60
- super do
61
- counter_key_upsert(key, -amount.abs)
62
- end
58
+ counter_key_upsert(key, -amount.abs)
63
59
  end
64
60
 
65
61
  def clear
data/lib/bin/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: UTF-8
2
2
  module Bin
3
- Version = '0.6.3.3'
3
+ Version = '0.6.3.4'
4
4
  end
data/lib/bin.rb CHANGED
@@ -4,7 +4,6 @@ require 'active_support/version'
4
4
  require 'mongo'
5
5
 
6
6
  module Bin
7
- autoload :Compatibility, 'bin/compatibility'
8
7
  autoload :Store, 'bin/store'
9
8
  autoload :Version, 'bin/version'
10
9
  end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require File.expand_path("#{File.dirname(__FILE__)}/../helper")
2
2
 
3
3
  describe Bin::Store do
4
4
  before(:each) do
data/spec/bin_spec.rb CHANGED
@@ -5,10 +5,6 @@ describe Bin do
5
5
  lambda { Bin::Store }.should_not raise_error(NameError)
6
6
  end
7
7
 
8
- it "autoloads Compatibility" do
9
- lambda { Bin::Compatibility }.should_not raise_error(NameError)
10
- end
11
-
12
8
  it "autoloads Version" do
13
9
  lambda { Bin::Version }.should_not raise_error(NameError)
14
10
  end
data/spec/helper.rb CHANGED
@@ -1,4 +1,6 @@
1
- gem 'activesupport', ENV['ACTIVE_SUPPORT_VERSION']
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler.setup
2
4
 
3
5
  $:.unshift(File.expand_path('../../lib', __FILE__))
4
6
 
@@ -6,6 +8,6 @@ require 'bin'
6
8
  require 'spec'
7
9
 
8
10
  connection = Mongo::Connection.new
9
- DB = connection.db('bin-store-test')
11
+ DB = connection.db('test')
10
12
 
11
13
  puts "\n--- Active Support Version: #{ActiveSupport::VERSION::STRING} ---\n"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: honkster-bin
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.3.3
5
+ version: 0.6.3.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - John Nunemaker
@@ -21,31 +21,75 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 1.1.1
24
+ version: 1.0.1
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: bson_ext
29
29
  prerelease: false
30
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: "2.3"
35
+ version: 1.0.1
36
36
  type: :runtime
37
37
  version_requirements: *id002
38
38
  - !ruby/object:Gem::Dependency
39
- name: rspec
39
+ name: activesupport
40
40
  prerelease: false
41
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "3.0"
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: i18n
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 0.6.0
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rspec
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
42
64
  none: false
43
65
  requirements:
44
66
  - - ~>
45
67
  - !ruby/object:Gem::Version
46
68
  version: 1.3.0
47
69
  type: :development
48
- version_requirements: *id003
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: ruby-debug19
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.11.6
80
+ type: :development
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: diff-lcs
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 1.1.2
91
+ type: :development
92
+ version_requirements: *id007
49
93
  description:
50
94
  email:
51
95
  - nunemaker@gmail.com
@@ -59,7 +103,6 @@ files:
59
103
  - lib/bin.rb
60
104
  - lib/bin/version.rb
61
105
  - lib/bin/store.rb
62
- - lib/bin/compatibility.rb
63
106
  - spec/bin/store_spec.rb
64
107
  - spec/helper.rb
65
108
  - spec/bin_spec.rb
@@ -1,41 +0,0 @@
1
- # encoding: UTF-8
2
- module Bin
3
- class Compatibility < ActiveSupport::Cache::Store
4
- def increment(key, amount=1)
5
- yield
6
- end
7
-
8
- def decrement(key, amount=1)
9
- yield
10
- end
11
- end
12
-
13
- if ActiveSupport::VERSION::STRING < '3'
14
- class Compatibility
15
- def write(key, value, options=nil, &block)
16
- super(key, value, options)
17
- yield
18
- end
19
-
20
- def read(key, options=nil, &block)
21
- super
22
- yield
23
- end
24
-
25
- def delete(key, options=nil, &block)
26
- super
27
- yield
28
- end
29
-
30
- def delete_matched(matcher, options=nil, &block)
31
- super
32
- yield
33
- end
34
-
35
- def exist?(key, options=nil, &block)
36
- super
37
- yield
38
- end
39
- end
40
- end
41
- end