stockade 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 14344fa7658d3173f6f14e2300725ce2def9ff69
4
+ data.tar.gz: 2e5142b58d7a48dd811ad9bd2e5cfb228fea590d
5
+ SHA512:
6
+ metadata.gz: 8aa73b99f960c8fb42f2fba50a5406a0521ed5d78b77d9f02959a8aefcbdb0839e94d656cc6da98bd610b5fdd38812bc148555761db3f07735bc3a58917f8aa0
7
+ data.tar.gz: 0b622524d25184ae5313147ad83aa63d6e9e164b5b2b2f5c37f6131ccbc9a0d669cd473c877ced48afe5283d354de3f99220f22e38a19a3f2cbbb59636f988d5
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ stockade (0.1.0)
5
+ bloomfilter-rb
6
+ memoist
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ bloomfilter-rb (2.1.1)
12
+ redis
13
+ byebug (10.0.2)
14
+ coderay (1.1.2)
15
+ diff-lcs (1.3)
16
+ memoist (0.16.0)
17
+ method_source (0.9.0)
18
+ pry (0.11.3)
19
+ coderay (~> 1.1.0)
20
+ method_source (~> 0.9.0)
21
+ pry-byebug (3.6.0)
22
+ byebug (~> 10.0)
23
+ pry (~> 0.10)
24
+ rake (10.5.0)
25
+ redis (4.0.1)
26
+ rspec (3.7.0)
27
+ rspec-core (~> 3.7.0)
28
+ rspec-expectations (~> 3.7.0)
29
+ rspec-mocks (~> 3.7.0)
30
+ rspec-core (3.7.1)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-expectations (3.7.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.7.0)
35
+ rspec-mocks (3.7.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.7.0)
38
+ rspec-support (3.7.1)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler (~> 1.16)
45
+ pry-byebug
46
+ rake (~> 10.0)
47
+ rspec (~> 3.0)
48
+ stockade!
49
+
50
+ BUNDLED WITH
51
+ 1.16.3
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Stan Mazhara
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/load ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Make bloomfilter and dump it for future use
4
+ #
5
+ require 'bundler/setup'
6
+
7
+ require 'csv'
8
+ require 'bloomfilter-rb'
9
+
10
+ def load(type)
11
+ bf = BloomFilter::Native.new(
12
+ :size => 10_000_000,
13
+ :hashes => 2,
14
+ :seed => 1,
15
+ :bucket => 3,
16
+ :raise => false
17
+ )
18
+
19
+ Dir.glob("data/#{type}/*.csv").each do |file|
20
+ CSV.foreach(file) do |line|
21
+ name = line.first
22
+ next if name == 'name'
23
+
24
+ name.strip!
25
+ name.downcase!
26
+ bf.insert(name) unless bf.include?(name)
27
+ end
28
+ end
29
+
30
+ dump = Marshal.dump(bf)
31
+
32
+ File.write("data/#{type}.dump", dump)
33
+
34
+ df = Marshal.load(File.read("data/#{type}.dump"))
35
+ end
36
+
37
+ load('surnames')
38
+ load('firstnames')