ribeye 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +2 -0
- data/Gemfile.lock +2 -0
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/ribeye.rb +66 -0
- data/lib/ribeye/bloom_filter.rb +24 -0
- data/ribeye.gemspec +6 -2
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDdkYTJlMDkwNjM1ZDEzZThjMDhkYmEwMmNhZDA5MGNkNWM4NmE3Yw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmIwODRiN2Y2MzNhMjg5ODZhYjI5YmRjNGYyMzFiZGIzNTM3OGJiMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzlkOWIyYjVmMGFjOTRkM2RjNjQyYTM5ODdkNTc0Y2ExODNhN2Y4N2E2MWI1
|
10
|
+
NzgwNzRlY2I1MjlhOWI3MGE0NDJjNzBhYTc4NDM5ZWJmNTc1NzQ3NjU4ZDk2
|
11
|
+
ZGVhNjYxMjMxZjFhM2I2NjBhYjNlZDlkMzBhYTE2NTYyNjc3Yjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTQzNGQ1MmFlZTk5ZDBiODhkYTA5MTI0YjViN2JiYzBlOGRjY2M5NDlkMWFk
|
14
|
+
NDYzMWU4NWI3ZDllNTJjMzNkNzQ2OTY0NTRhYzY3M2ViNTBmZDI1ZGQyZTFl
|
15
|
+
NzJhOWY5MTc1ODllY2E3NDg2NGEzNTgyZmRmMTU1Mjg3YWM0N2I=
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -17,6 +17,7 @@ GEM
|
|
17
17
|
hashie (2.0.5)
|
18
18
|
highline (1.6.20)
|
19
19
|
httpauth (0.2.0)
|
20
|
+
httpclient (2.3.4.1)
|
20
21
|
jeweler (1.8.8)
|
21
22
|
builder
|
22
23
|
bundler (~> 1.0)
|
@@ -58,5 +59,6 @@ PLATFORMS
|
|
58
59
|
|
59
60
|
DEPENDENCIES
|
60
61
|
bundler (~> 1.3.5)
|
62
|
+
httpclient (~> 2.3.4.1)
|
61
63
|
jeweler (~> 1.8.4)
|
62
64
|
rspec (~> 2.8.0)
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/lib/ribeye.rb
CHANGED
@@ -1 +1,67 @@
|
|
1
|
+
require 'httpclient'
|
2
|
+
require 'ribeye/bloom_filter'
|
1
3
|
|
4
|
+
class Ribeye
|
5
|
+
|
6
|
+
# Response codes
|
7
|
+
TRUE_VALUE = 't'
|
8
|
+
FALSE_VALUE = 'f'
|
9
|
+
SUCCESS = '0'
|
10
|
+
INVALID_PARAMETER_VALUE = '1'
|
11
|
+
INVALID_PARAMETERS = '2'
|
12
|
+
BLOOM_FILTER_EXISTS = '3'
|
13
|
+
BLOOM_FILTER_DOES_NOT_EXIST = '4'
|
14
|
+
|
15
|
+
# Response code exceptions
|
16
|
+
class InvalidParameterValue < StandardError; end
|
17
|
+
class InvalidParameters < StandardError; end
|
18
|
+
class NonExistentBF < StandardError; end
|
19
|
+
class BFExists < StandardError; end
|
20
|
+
|
21
|
+
attr_accessor :uri, :client
|
22
|
+
|
23
|
+
def initialize(uri = nil)
|
24
|
+
@uri = uri || 'http://localhost:8080'
|
25
|
+
@client = HTTPClient.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_errors(body)
|
29
|
+
case body
|
30
|
+
when INVALID_PARAMETER_VALUE
|
31
|
+
raise InvalidParameterValue
|
32
|
+
when INVALID_PARAMETERS
|
33
|
+
raise InvalidParameters
|
34
|
+
when BLOOM_FILTER_EXISTS
|
35
|
+
raise BFExists
|
36
|
+
when BLOOM_FILTER_DOES_NOT_EXIST
|
37
|
+
raise NonExistentBF
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def make_request(path, success_value, params)
|
42
|
+
response = client.get(URI.join(uri, path), params)
|
43
|
+
parse_errors(response.body)
|
44
|
+
response.body == success_value
|
45
|
+
end
|
46
|
+
|
47
|
+
def create(name, size)
|
48
|
+
make_request('/create', SUCCESS, name: name, size: size)
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete(name)
|
52
|
+
make_request('/delete', SUCCESS, name: name)
|
53
|
+
end
|
54
|
+
|
55
|
+
def exists(name)
|
56
|
+
make_request('/exists', TRUE_VALUE, name: name)
|
57
|
+
end
|
58
|
+
|
59
|
+
def insert(name, value)
|
60
|
+
make_request('/insert', SUCCESS, name: name, value: value)
|
61
|
+
end
|
62
|
+
|
63
|
+
def check(name, value)
|
64
|
+
make_request('/check', TRUE_VALUE, name: name, value: value)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Ribeye
|
2
|
+
|
3
|
+
class BloomFilter
|
4
|
+
|
5
|
+
attr_reader :name, :size
|
6
|
+
|
7
|
+
def initialize(name, size, opts = {})
|
8
|
+
@name = name
|
9
|
+
@size = size
|
10
|
+
@client = Ribeye.new(opts[:uri])
|
11
|
+
@client.create(name, size) unless @client.exists(name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def insert(value)
|
15
|
+
@client.insert(name, value)
|
16
|
+
end
|
17
|
+
|
18
|
+
def check(value)
|
19
|
+
@client.check(name, value)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/ribeye.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ribeye 0.
|
5
|
+
# stub: ribeye 0.1.0 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ribeye"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.1.0"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.authors = ["David Huie"]
|
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
30
|
"lib/ribeye.rb",
|
31
|
+
"lib/ribeye/bloom_filter.rb",
|
31
32
|
"ribeye.gemspec",
|
32
33
|
"spec/spec_helper.rb"
|
33
34
|
]
|
@@ -41,15 +42,18 @@ Gem::Specification.new do |s|
|
|
41
42
|
s.specification_version = 4
|
42
43
|
|
43
44
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
45
|
+
s.add_runtime_dependency(%q<httpclient>, ["~> 2.3.4.1"])
|
44
46
|
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
45
47
|
s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
|
46
48
|
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
47
49
|
else
|
50
|
+
s.add_dependency(%q<httpclient>, ["~> 2.3.4.1"])
|
48
51
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
49
52
|
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
50
53
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
51
54
|
end
|
52
55
|
else
|
56
|
+
s.add_dependency(%q<httpclient>, ["~> 2.3.4.1"])
|
53
57
|
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
58
|
s.add_dependency(%q<bundler>, ["~> 1.3.5"])
|
55
59
|
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ribeye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Huie
|
@@ -10,6 +10,20 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2013-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httpclient
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.3.4.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.3.4.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,6 +86,7 @@ files:
|
|
72
86
|
- Rakefile
|
73
87
|
- VERSION
|
74
88
|
- lib/ribeye.rb
|
89
|
+
- lib/ribeye/bloom_filter.rb
|
75
90
|
- ribeye.gemspec
|
76
91
|
- spec/spec_helper.rb
|
77
92
|
homepage: http://github.com/DavidHuie/ribeye
|