Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bundlerize + rspec2 cleanup

  • Loading branch information...
commit 7d3532c0aef9fc80733c147ada982cfec8f5c306 1 parent 9b87dca
@igrigorik authored
View
0  .rspec
No changes.
View
3  Gemfile
@@ -0,0 +1,3 @@
+source "http://rubygems.org"
+
+gemspec
View
29 Gemfile.lock
@@ -0,0 +1,29 @@
+PATH
+ remote: .
+ specs:
+ bloomfilter (1.3.1)
+ redis
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ diff-lcs (1.1.2)
+ rake (0.8.7)
+ redis (2.0.5)
+ rspec (2.3.0)
+ rspec-core (~> 2.3.0)
+ rspec-expectations (~> 2.3.0)
+ rspec-mocks (~> 2.3.0)
+ rspec-core (2.3.1)
+ rspec-expectations (2.3.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.3.0)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ bloomfilter!
+ rake
+ redis
+ rspec
View
59 README.md
@@ -0,0 +1,59 @@
+# BloomFilter
+
+Counting Bloom Filter implemented in Ruby.
+
+Bloom filter is a space-efficient probabilistic data structure that is used to test whether an element is a member of a set. False positives are possible, but false negatives are not. For more detail, check the [wikipedia article](http://en.wikipedia.org/wiki/Bloom_filter). Instead of using k different hash functions, this implementation seeds the CRC32 hash with k different initial values (0, 1, ..., k-1). This may or may not give you a good distribution, it all depends on the data.
+
+Performance of the Bloom filter depends on a number of variables:
+
+- size of the bit array
+- size of the counter bucket
+- number of hash functions
+
+## Resources
+
+- Determining parameters: [Scalable Datasets: Bloom Filters in Ruby](http://www.igvita.com/2008/12/27/scalable-datasets-bloom-filters-in-ruby/)
+- Applications & reasons behind bloom filter: [Flow analysis: Time based bloom filter](http://www.igvita.com/2010/01/06/flow-analysis-time-based-bloom-filters/)
+
+## Example
+
+ require 'bloomfilter'
+
+ bf = BloomFilter.new(:size => 100, :hashes => 2, :seed => 1, :bucket => 3, :raise => false)
+ bf.insert("test")
+ bf.include?("test")
+ => true
+ bf.include?("test2")
+ => false
+ bf.delete("test")
+ bf.include?("test")
+ => false
+
+ # Hash with a bloom filter!
+ bf["test2"] = "bar"
+ bf["test2"]
+ => "bar"
+ bf["test3"]
+ => nil
+
+ bf.stats
+ Number of filter bits (m): 10
+ Number of filter elements (n): 2
+ Number of filter hashes (k) : 2
+ Predicted false positive rate = 10.87%
+
+## Redis-backed counting Bloom Filter with TTL's
+
+ bf = BloomFilter.new(:type => :redis, :ttl => 2, :server => {:host => 'localhost'})
+
+ bf.insert('test')
+ bf.include?('test')
+ => true
+
+ sleep(2)
+ bf.include?('test')
+ => false
+
+## Credits
+
+Tatsuya Mori <valdzone@gmail.com> (Original C implementation: http://vald.x0.com/sb/)
View
66 README.rdoc
@@ -1,66 +0,0 @@
-= BloomFilter
-
-Counting Bloom Filter implemented in Ruby.
-
-Bloom filter is a space-efficient probabilistic data structure that is used to
-test whether an element is a member of a set. False positives are possible, but
-false negatives are not. For more detail: http://en.wikipedia.org/wiki/Bloom_filter
-
-Performance of the Bloom filter depends on a number of variables:
-- size of the bit array
-- size of the counter bucket
-- number of hash functions
-
-To figure out the values for these parameters, refer to:
-- http://www.igvita.com/2008/12/27/scalable-datasets-bloom-filters-in-ruby/
-
-To learn about applications and reasons for the time based bloom filters, refer to:
-- http://www.igvita.com/2010/01/06/flow-analysis-time-based-bloom-filters/
-
-== Implementation
-
-Instead of using k different hash functions, this implementation seeds the CRC32 hash
-with k different initial values (0, 1, ..., k-1). This may or may not give you a good
-distribution, it all depends on the data.
-
-== Example
-
- require 'bloomfilter'
-
- bf = BloomFilter.new(:size => 100, :hashes => 2, :seed => 1, :bucket => 3, :raise => false)
- bf.insert("test")
- bf.include?("test")
- => true
- bf.include?("test2")
- => false
- bf.delete("test")
- bf.include?("test")
- => false
-
- # Hash with a bloom filter!
- bf["test2"] = "bar"
- bf["test2"]
- => "bar"
- bf["test3"]
- => nil
-
- bf.stats
- Number of filter bits (m): 10
- Number of filter elements (n): 2
- Number of filter hashes (k) : 2
- Predicted false positive rate = 10.87%
-
-== Redis-backed counting Bloom Filter with TTL's
-
- bf = BloomFilter.new(:type => :redis, :ttl => 2, :server => {:host => 'localhost'})
-
- bf.insert('test')
- bf.include?('test')
- => true
-
- sleep(2)
- bf.include?('test')
- => false
-
-== Credits
-Tatsuya Mori <valdzone@gmail.com> (Original C implementation: http://vald.x0.com/sb/)
View
28 Rakefile
@@ -2,30 +2,8 @@ require 'rake'
require 'rspec'
require 'rspec/core/rake_task'
require 'rake/extensiontask'
+require 'bundler'
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "bloomfilter"
- gemspec.summary = "Counting Bloom Filter implemented in Ruby"
- gemspec.description = gemspec.summary
- gemspec.email = "ilya@igvita.com"
- gemspec.homepage = "http://github.com/igrigorik/bloomfilter"
- gemspec.authors = ["Ilya Grigorik", "Tatsuya Mori"]
- gemspec.extensions = ["ext/cbloomfilter/extconf.rb"]
- gemspec.rubyforge_project = "bloomfilter"
- gemspec.files = FileList[`git ls-files`.split]
- gemspec.add_dependency 'redis'
- gemspec.add_development_dependency 'rake'
- gemspec.add_development_dependency 'rspec'
- gemspec.add_development_dependency 'rake-compiler'
- end
-
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
-end
-
+Bundler::GemHelper.install_tasks
RSpec::Core::RakeTask.new(:spec)
-
-Rake::ExtensionTask.new('cbloomfilter')
+Rake::ExtensionTask.new('cbloomfilter')
View
1  VERSION
@@ -1 +0,0 @@
-1.3.1
View
90 bloomfilter.gemspec
@@ -1,76 +1,26 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "bloomfilter"
Gem::Specification.new do |s|
- s.name = %q{bloomfilter}
- s.version = "1.3.1"
+ s.name = "bloomfilter"
+ s.version = BloomFilter::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Ilya Grigorik", "Tatsuya Mori"]
+ s.email = ["ilya@igvita.com"]
+ s.homepage = "http://github.com/igrigorik/bloomfilter"
+ s.summary = "Counting Bloom Filter implemented in Ruby"
+ s.description = s.summary
+ s.rubyforge_project = "bloomfilter"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Ilya Grigorik", "Tatsuya Mori"]
- s.date = %q{2010-11-23}
- s.description = %q{Counting Bloom Filter implemented in Ruby}
- s.email = %q{ilya@igvita.com}
- s.extensions = ["ext/cbloomfilter/extconf.rb"]
- s.extra_rdoc_files = [
- "README.rdoc"
- ]
- s.files = [
- ".gitignore",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "bloomfilter.gemspec",
- "examples/bf.rb",
- "examples/redis-backed.rb",
- "examples/simple.rb",
- "ext/cbloomfilter/cbloomfilter.c",
- "ext/cbloomfilter/crc32.c",
- "ext/cbloomfilter/crc32.h",
- "ext/cbloomfilter/extconf.rb",
- "lib/bloomfilter.rb",
- "lib/redisbloom.rb",
- "spec/c_spec.rb",
- "spec/helper.rb",
- "spec/redis_spec.rb",
- "spec/spec.opts"
- ]
- s.homepage = %q{http://github.com/igrigorik/bloomfilter}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{bloomfilter}
- s.rubygems_version = %q{1.3.7}
- s.summary = %q{Counting Bloom Filter implemented in Ruby}
- s.test_files = [
- "spec/c_spec.rb",
- "spec/helper.rb",
- "spec/redis_spec.rb",
- "examples/bf.rb",
- "examples/redis-backed.rb",
- "examples/simple.rb"
- ]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
+ s.add_dependency "redis"
+ s.add_development_dependency "rspec"
+ s.add_development_dependency "rake"
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<redis>, [">= 0"])
- s.add_development_dependency(%q<rake>, [">= 0"])
- s.add_development_dependency(%q<rspec>, [">= 0"])
- s.add_development_dependency(%q<rake-compiler>, [">= 0"])
- else
- s.add_dependency(%q<redis>, [">= 0"])
- s.add_dependency(%q<rake>, [">= 0"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<rake-compiler>, [">= 0"])
- end
- else
- s.add_dependency(%q<redis>, [">= 0"])
- s.add_dependency(%q<rake>, [">= 0"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<rake-compiler>, [">= 0"])
- end
-end
+ s.extensions = ["ext/cbloomfilter/extconf.rb"]
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+end
View
1  lib/bloomfilter.rb
@@ -2,6 +2,7 @@
require 'cbloomfilter'
class BloomFilter
+ VERSION = "1.3.1"
attr_reader :bf
View
2  lib/redisbloom.rb
@@ -22,7 +22,7 @@ def insert(key, ttl=nil)
def delete(key)
indexes_for(key).each do |idx|
if @db.decr(idx).to_i <= 0
- @db.del(idx)
+ @db.del(idx)
end
end
end
View
4 spec/helper.rb
@@ -1,3 +1 @@
-require 'rspec'
-$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
-require 'bloomfilter'
+require 'bundler/setup'
View
7 spec/spec.opts
@@ -1,7 +0,0 @@
---colour
---format
-specdoc
---loadby
-mtime
---reverse
---backtrace
Please sign in to comment.
Something went wrong with that request. Please try again.