fuzzyhash 0.0.6 → 0.0.7
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 +7 -28
- data/VERSION.yml +1 -1
- data/lib/fuzzy_hash.rb +22 -5
- metadata +3 -3
data/Rakefile
CHANGED
|
@@ -9,38 +9,17 @@ begin
|
|
|
9
9
|
s.files = FileList["[A-Z]*", "{lib,spec}/**/*"]
|
|
10
10
|
s.rubyforge_project = 'fuzzyhash' # This line would be new
|
|
11
11
|
end
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
begin
|
|
18
|
-
require 'rake/contrib/sshpublisher'
|
|
19
|
-
namespace :rubyforge do
|
|
20
|
-
|
|
21
|
-
desc "Release gem and RDoc documentation to RubyForge"
|
|
22
|
-
task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
|
|
23
|
-
|
|
24
|
-
namespace :release do
|
|
25
|
-
desc "Publish RDoc to RubyForge."
|
|
26
|
-
task :docs => [:rdoc] do
|
|
27
|
-
config = YAML.load(
|
|
28
|
-
File.read(File.expand_path('~/.rubyforge/user-config.yml'))
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
host = "#{config['username']}@rubyforge.org"
|
|
32
|
-
remote_dir = "/var/www/gforge-projects/fuzzyhash/"
|
|
33
|
-
local_dir = 'rdoc'
|
|
34
|
-
|
|
35
|
-
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
|
36
|
-
end
|
|
37
|
-
end
|
|
12
|
+
|
|
13
|
+
Jeweler::GemcutterTasks.new
|
|
14
|
+
Jeweler::RubyforgeTasks.new do |rubyforge|
|
|
15
|
+
rubyforge.doc_task = "rdoc"
|
|
16
|
+
rubyforge.remote_doc_path = ''
|
|
38
17
|
end
|
|
18
|
+
|
|
39
19
|
rescue LoadError
|
|
40
|
-
puts "
|
|
20
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
|
41
21
|
end
|
|
42
22
|
|
|
43
|
-
|
|
44
23
|
require 'spec'
|
|
45
24
|
require 'spec/rake/spectask'
|
|
46
25
|
task :spec => 'spec:all'
|
data/VERSION.yml
CHANGED
data/lib/fuzzy_hash.rb
CHANGED
|
@@ -15,6 +15,12 @@ class FuzzyHash
|
|
|
15
15
|
@regexes_reverse.clear
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
def size
|
|
19
|
+
@hash.size + @regexes.size
|
|
20
|
+
end
|
|
21
|
+
alias_method :count, :size
|
|
22
|
+
|
|
23
|
+
|
|
18
24
|
def ==(o)
|
|
19
25
|
o.is_a?(FuzzyHash)
|
|
20
26
|
o.instance_variable_get(:@hash) == @hash &&
|
|
@@ -83,14 +89,25 @@ class FuzzyHash
|
|
|
83
89
|
|
|
84
90
|
private
|
|
85
91
|
def regex_test
|
|
86
|
-
@regex_test
|
|
92
|
+
unless @regex_test
|
|
93
|
+
@regex_test = Object.new
|
|
94
|
+
@regex_test.instance_variable_set(:'@regexes', @regexes)
|
|
95
|
+
method = "
|
|
96
|
+
def match(str)
|
|
97
|
+
case str
|
|
98
|
+
"
|
|
99
|
+
@regexes.each_with_index do |reg, index|
|
|
100
|
+
method << "when #{reg.first.inspect}: [@regexes[#{index}][1], str]\n"
|
|
101
|
+
end
|
|
102
|
+
method << "end\nend\n"
|
|
103
|
+
@regex_test.instance_eval method
|
|
104
|
+
end
|
|
105
|
+
@regex_test
|
|
87
106
|
end
|
|
88
107
|
|
|
89
108
|
def regex_lookup(key)
|
|
90
|
-
if !@regexes.empty? && key.is_a?(String) && (
|
|
91
|
-
|
|
92
|
-
break [@regexes[i].last, data_array.at(i+1)] if data_array.at(i+1)
|
|
93
|
-
end
|
|
109
|
+
if !@regexes.empty? && key.is_a?(String) && (value = regex_test.match(key))
|
|
110
|
+
value
|
|
94
111
|
end
|
|
95
112
|
end
|
|
96
113
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fuzzyhash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Hull
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-
|
|
12
|
+
date: 2009-09-25 00:00:00 -04:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|
|
@@ -53,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
53
53
|
requirements: []
|
|
54
54
|
|
|
55
55
|
rubyforge_project: fuzzyhash
|
|
56
|
-
rubygems_version: 1.3.
|
|
56
|
+
rubygems_version: 1.3.5
|
|
57
57
|
signing_key:
|
|
58
58
|
specification_version: 3
|
|
59
59
|
summary: A weird hash with special semantics for regex keys
|