juno 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.travis.yml +25 -0
- data/Gemfile +19 -0
- data/LICENSE +20 -0
- data/README.md +83 -0
- data/Rakefile +15 -0
- data/SPEC.md +95 -0
- data/juno.gemspec +22 -0
- data/lib/juno.rb +31 -0
- data/lib/juno/activerecord.rb +58 -0
- data/lib/juno/base.rb +113 -0
- data/lib/juno/couch.rb +43 -0
- data/lib/juno/datamapper.rb +63 -0
- data/lib/juno/dbm.rb +15 -0
- data/lib/juno/expires.rb +45 -0
- data/lib/juno/file.rb +62 -0
- data/lib/juno/gdbm.rb +15 -0
- data/lib/juno/hashfile.rb +12 -0
- data/lib/juno/localmemcache.rb +16 -0
- data/lib/juno/memcached.rb +7 -0
- data/lib/juno/memcached_dalli.rb +55 -0
- data/lib/juno/memcached_native.rb +56 -0
- data/lib/juno/memory.rb +7 -0
- data/lib/juno/mongodb.rb +43 -0
- data/lib/juno/proxy.rb +5 -0
- data/lib/juno/pstore.rb +49 -0
- data/lib/juno/redis.rb +34 -0
- data/lib/juno/riak.rb +45 -0
- data/lib/juno/sdbm.rb +15 -0
- data/lib/juno/sequel.rb +51 -0
- data/lib/juno/sqlite.rb +50 -0
- data/lib/juno/tokyocabinet.rb +36 -0
- data/lib/juno/version.rb +3 -0
- data/lib/juno/yaml.rb +9 -0
- data/test/helper.rb +182 -0
- data/test/test_active_record.rb +36 -0
- data/test/test_couch.rb +13 -0
- data/test/test_datamapper.rb +64 -0
- data/test/test_dbm.rb +13 -0
- data/test/test_expires.rb +10 -0
- data/test/test_file.rb +9 -0
- data/test/test_gdbm.rb +13 -0
- data/test/test_hashfile.rb +9 -0
- data/test/test_localmemcache.rb +13 -0
- data/test/test_memcached.rb +15 -0
- data/test/test_memcached_dalli.rb +15 -0
- data/test/test_memcached_native.rb +15 -0
- data/test/test_memory.rb +9 -0
- data/test/test_mongodb.rb +13 -0
- data/test/test_proxy.rb +9 -0
- data/test/test_pstore.rb +9 -0
- data/test/test_redis.rb +13 -0
- data/test/test_riak.rb +13 -0
- data/test/test_sdbm.rb +13 -0
- data/test/test_sequel.rb +13 -0
- data/test/test_sqlite.rb +13 -0
- data/test/test_tokyocabinet.rb +13 -0
- data/test/test_yaml.rb +9 -0
- data/unsupported/benchmarks.rb +234 -0
- data/unsupported/cassandra.rb +45 -0
- data/unsupported/fog.rb +60 -0
- data/unsupported/test_cassandra.rb +13 -0
- data/unsupported/test_rackspace.rb +15 -0
- data/unsupported/test_s3.rb +15 -0
- data/unsupported/test_tokyotyrant.rb +13 -0
- data/unsupported/tokyotyrant.rb +29 -0
- metadata +165 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
# Copyright: 2011 TMX Credit
|
2
|
+
# Author: Potapov Sergey (aka Blake)
|
3
|
+
|
4
|
+
require 'cassandra'
|
5
|
+
|
6
|
+
module Juno
|
7
|
+
class Cassandra < Base
|
8
|
+
def initialize(options = {})
|
9
|
+
options[:keyspace] ||= 'Juno'
|
10
|
+
options[:host] ||= '127.0.0.1'
|
11
|
+
options[:port] ||= 9160
|
12
|
+
@client = ::Cassandra.new(options[:keyspace], "#{options[:host]}:#{options[:port]}")
|
13
|
+
@column_family = options[:column_family] || :Juno
|
14
|
+
end
|
15
|
+
|
16
|
+
def key?(key, options = {})
|
17
|
+
key = key_for(key)
|
18
|
+
@client.exists?(@column_family, key)
|
19
|
+
end
|
20
|
+
|
21
|
+
def [](key)
|
22
|
+
key = key_for(key)
|
23
|
+
deserialize(@client.get(@column_family, key)['value'])
|
24
|
+
end
|
25
|
+
|
26
|
+
def delete(key, options = {})
|
27
|
+
key = key_for(key)
|
28
|
+
value = self[key]
|
29
|
+
@client.remove(@column_family, key)
|
30
|
+
value
|
31
|
+
end
|
32
|
+
|
33
|
+
def store(key, value, options = {})
|
34
|
+
key = key_for(key)
|
35
|
+
@client.insert(@column_family, key, {'value' => serialize(value)})
|
36
|
+
end
|
37
|
+
|
38
|
+
def clear(options = {})
|
39
|
+
@client.each_key(@column_family) do |key|
|
40
|
+
delete(key)
|
41
|
+
end
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/unsupported/fog.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'fog'
|
2
|
+
|
3
|
+
module Juno
|
4
|
+
class Fog < Base
|
5
|
+
def initialize(options = {})
|
6
|
+
bucket = options.delete(:namespace)
|
7
|
+
cloud = options.delete(:cloud).new(options)
|
8
|
+
@directory = cloud.directories.create(:key => bucket)
|
9
|
+
end
|
10
|
+
|
11
|
+
def key?(key, options = {})
|
12
|
+
!@directory.files.head(key_for(key)).nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](key)
|
16
|
+
if value = get(key)
|
17
|
+
deserialize(value.body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(key, options = {})
|
22
|
+
value = get(key)
|
23
|
+
if value
|
24
|
+
value.destroy
|
25
|
+
deserialize(value.body)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def store(key, value, options = {})
|
30
|
+
@directory.files.create(:key => key_for(key), :body => serialize(value))
|
31
|
+
end
|
32
|
+
|
33
|
+
def clear(options = {})
|
34
|
+
@directory.files.all.each do |file|
|
35
|
+
file.destroy
|
36
|
+
end
|
37
|
+
nil
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def get(key)
|
43
|
+
@directory.files.get(key_for(key))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class S3 < Fog
|
48
|
+
def initialize(options = {})
|
49
|
+
options[:cloud] = ::Fog::AWS::S3
|
50
|
+
super
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Rackspace < Fog
|
55
|
+
def initialize(options = {})
|
56
|
+
options[:cloud] = ::Fog::Rackspace::Files
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
describe Juno::Rackspace do
|
5
|
+
def new_store
|
6
|
+
Juno::Rackspace.new(:rackspace_username => ENV['RACKSPACE_USERNAME'] || 'mocked',
|
7
|
+
:rackspace_api_key => ENV['RACKSPACE_APIKEY'] || 'mocked',
|
8
|
+
:namespace => 'TESTING')
|
9
|
+
end
|
10
|
+
|
11
|
+
class_eval(&JunoSpecification)
|
12
|
+
end
|
13
|
+
rescue LoadError => ex
|
14
|
+
puts "Juno::Rackspace not tested: #{ex.message}"
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
describe Juno::S3 do
|
5
|
+
def new_store
|
6
|
+
Juno::S3.new(:aws_access_key_id => ENV['S3_KEY'] || 'mocked',
|
7
|
+
:aws_secret_access_key => ENV['S3_SECRET'] || 'mocked',
|
8
|
+
:namespace => 'TESTING')
|
9
|
+
end
|
10
|
+
|
11
|
+
class_eval(&JunoSpecification)
|
12
|
+
end
|
13
|
+
rescue LoadError => ex
|
14
|
+
puts "Juno::S3 not tested: #{ex.message}"
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
describe Juno::TokyoTyrant do
|
5
|
+
def new_store
|
6
|
+
Juno::TokyoTyrant.new(:host => '127.0.0.1', :port => 1978)
|
7
|
+
end
|
8
|
+
|
9
|
+
class_eval(&JunoSpecification)
|
10
|
+
end
|
11
|
+
rescue LoadError => ex
|
12
|
+
puts "Juno::TokyoTyrant not tested: #{ex.message}"
|
13
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'tokyotyrant'
|
2
|
+
|
3
|
+
# FIXME: TokyoTyrant is obsolete, it is replaced by KyotoTycoon
|
4
|
+
module Juno
|
5
|
+
class TokyoTyrant < Base
|
6
|
+
def initialize(options = {})
|
7
|
+
raise 'No option :host specified' unless options[:host]
|
8
|
+
raise 'No option :port specified' unless options[:port]
|
9
|
+
@store = ::TokyoTyrant::RDB.new
|
10
|
+
unless @store.open(options[:host], options[:port])
|
11
|
+
raise @hash.errmsg(@hash.ecode)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def key?(key, options = {})
|
16
|
+
!!self[key]
|
17
|
+
end
|
18
|
+
|
19
|
+
def store(key, value, options = {})
|
20
|
+
@store.put(key_for(key), serialize(value))
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(key, options = {})
|
24
|
+
value = self[key]
|
25
|
+
@hash.delete(key_for(key))
|
26
|
+
value
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: juno
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yehuda Katz
|
9
|
+
- Derek Kastner
|
10
|
+
- Daniel Mendler
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2012-11-19 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: rake
|
18
|
+
requirement: &19508020 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
type: :development
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: *19508020
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: &19507540 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: *19507540
|
38
|
+
description: A unified interface to key/value stores (moneta replacement)
|
39
|
+
email:
|
40
|
+
- wycats@gmail.com
|
41
|
+
- dkastner@gmail.com
|
42
|
+
- mail@daniel-mendler.de
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files:
|
46
|
+
- README.md
|
47
|
+
- SPEC.md
|
48
|
+
- LICENSE
|
49
|
+
files:
|
50
|
+
- .gitignore
|
51
|
+
- .travis.yml
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- SPEC.md
|
57
|
+
- juno.gemspec
|
58
|
+
- lib/juno.rb
|
59
|
+
- lib/juno/activerecord.rb
|
60
|
+
- lib/juno/base.rb
|
61
|
+
- lib/juno/couch.rb
|
62
|
+
- lib/juno/datamapper.rb
|
63
|
+
- lib/juno/dbm.rb
|
64
|
+
- lib/juno/expires.rb
|
65
|
+
- lib/juno/file.rb
|
66
|
+
- lib/juno/gdbm.rb
|
67
|
+
- lib/juno/hashfile.rb
|
68
|
+
- lib/juno/localmemcache.rb
|
69
|
+
- lib/juno/memcached.rb
|
70
|
+
- lib/juno/memcached_dalli.rb
|
71
|
+
- lib/juno/memcached_native.rb
|
72
|
+
- lib/juno/memory.rb
|
73
|
+
- lib/juno/mongodb.rb
|
74
|
+
- lib/juno/proxy.rb
|
75
|
+
- lib/juno/pstore.rb
|
76
|
+
- lib/juno/redis.rb
|
77
|
+
- lib/juno/riak.rb
|
78
|
+
- lib/juno/sdbm.rb
|
79
|
+
- lib/juno/sequel.rb
|
80
|
+
- lib/juno/sqlite.rb
|
81
|
+
- lib/juno/tokyocabinet.rb
|
82
|
+
- lib/juno/version.rb
|
83
|
+
- lib/juno/yaml.rb
|
84
|
+
- test/helper.rb
|
85
|
+
- test/test_active_record.rb
|
86
|
+
- test/test_couch.rb
|
87
|
+
- test/test_datamapper.rb
|
88
|
+
- test/test_dbm.rb
|
89
|
+
- test/test_expires.rb
|
90
|
+
- test/test_file.rb
|
91
|
+
- test/test_gdbm.rb
|
92
|
+
- test/test_hashfile.rb
|
93
|
+
- test/test_localmemcache.rb
|
94
|
+
- test/test_memcached.rb
|
95
|
+
- test/test_memcached_dalli.rb
|
96
|
+
- test/test_memcached_native.rb
|
97
|
+
- test/test_memory.rb
|
98
|
+
- test/test_mongodb.rb
|
99
|
+
- test/test_proxy.rb
|
100
|
+
- test/test_pstore.rb
|
101
|
+
- test/test_redis.rb
|
102
|
+
- test/test_riak.rb
|
103
|
+
- test/test_sdbm.rb
|
104
|
+
- test/test_sequel.rb
|
105
|
+
- test/test_sqlite.rb
|
106
|
+
- test/test_tokyocabinet.rb
|
107
|
+
- test/test_yaml.rb
|
108
|
+
- unsupported/benchmarks.rb
|
109
|
+
- unsupported/cassandra.rb
|
110
|
+
- unsupported/fog.rb
|
111
|
+
- unsupported/test_cassandra.rb
|
112
|
+
- unsupported/test_rackspace.rb
|
113
|
+
- unsupported/test_s3.rb
|
114
|
+
- unsupported/test_tokyotyrant.rb
|
115
|
+
- unsupported/tokyotyrant.rb
|
116
|
+
homepage: http://github.com/minad/juno
|
117
|
+
licenses: []
|
118
|
+
post_install_message:
|
119
|
+
rdoc_options: []
|
120
|
+
require_paths:
|
121
|
+
- lib
|
122
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 1.8.15
|
137
|
+
signing_key:
|
138
|
+
specification_version: 3
|
139
|
+
summary: A unified interface to key/value stores, including MongoDB, Redis, Tokyo,
|
140
|
+
and ActiveRecord
|
141
|
+
test_files:
|
142
|
+
- test/helper.rb
|
143
|
+
- test/test_active_record.rb
|
144
|
+
- test/test_couch.rb
|
145
|
+
- test/test_datamapper.rb
|
146
|
+
- test/test_dbm.rb
|
147
|
+
- test/test_expires.rb
|
148
|
+
- test/test_file.rb
|
149
|
+
- test/test_gdbm.rb
|
150
|
+
- test/test_hashfile.rb
|
151
|
+
- test/test_localmemcache.rb
|
152
|
+
- test/test_memcached.rb
|
153
|
+
- test/test_memcached_dalli.rb
|
154
|
+
- test/test_memcached_native.rb
|
155
|
+
- test/test_memory.rb
|
156
|
+
- test/test_mongodb.rb
|
157
|
+
- test/test_proxy.rb
|
158
|
+
- test/test_pstore.rb
|
159
|
+
- test/test_redis.rb
|
160
|
+
- test/test_riak.rb
|
161
|
+
- test/test_sdbm.rb
|
162
|
+
- test/test_sequel.rb
|
163
|
+
- test/test_sqlite.rb
|
164
|
+
- test/test_tokyocabinet.rb
|
165
|
+
- test/test_yaml.rb
|