lunar 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/LICENSE +1 -1
- data/README.markdown +116 -0
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/lib/lunar.rb +112 -24
- data/lib/lunar/connection.rb +51 -0
- data/lib/lunar/fuzzy_matches.rb +24 -0
- data/lib/lunar/fuzzy_word.rb +2 -2
- data/lib/lunar/index.rb +200 -94
- data/lib/lunar/keyword_matches.rb +32 -0
- data/lib/lunar/lunar_nest.rb +19 -0
- data/lib/lunar/range_matches.rb +28 -0
- data/lib/lunar/result_set.rb +85 -28
- data/lib/lunar/scoring.rb +4 -2
- data/lib/lunar/stopwords.rb +15 -0
- data/lib/lunar/words.rb +6 -3
- data/lunar.gemspec +31 -60
- data/test/helper.rb +4 -5
- data/test/test_fuzzy_indexing.rb +105 -0
- data/test/test_index.rb +150 -0
- data/test/test_lunar.rb +178 -1
- data/test/test_lunar_fuzzy_word.rb +4 -4
- data/test/test_lunar_nest.rb +46 -0
- data/test/{test_lunar_scoring.rb → test_scoring.rb} +5 -5
- metadata +72 -68
- data/.document +0 -5
- data/DATA +0 -41
- data/README.md +0 -80
- data/examples/ohm.rb +0 -40
- data/lib/lunar/search.rb +0 -68
- data/lib/lunar/sets.rb +0 -86
- data/test/test_lunar_fuzzy.rb +0 -118
- data/test/test_lunar_index.rb +0 -191
- data/test/test_lunar_search.rb +0 -261
- data/test/test_sets.rb +0 -48
- data/vendor/nest/nest.rb +0 -7
- data/vendor/redis/.gitignore +0 -9
- data/vendor/redis/LICENSE +0 -20
- data/vendor/redis/README.markdown +0 -120
- data/vendor/redis/Rakefile +0 -75
- data/vendor/redis/benchmarking/logging.rb +0 -62
- data/vendor/redis/benchmarking/pipeline.rb +0 -44
- data/vendor/redis/benchmarking/speed.rb +0 -21
- data/vendor/redis/benchmarking/suite.rb +0 -24
- data/vendor/redis/benchmarking/worker.rb +0 -71
- data/vendor/redis/bin/distredis +0 -33
- data/vendor/redis/examples/basic.rb +0 -15
- data/vendor/redis/examples/dist_redis.rb +0 -43
- data/vendor/redis/examples/incr-decr.rb +0 -17
- data/vendor/redis/examples/list.rb +0 -26
- data/vendor/redis/examples/pubsub.rb +0 -25
- data/vendor/redis/examples/sets.rb +0 -36
- data/vendor/redis/lib/edis.rb +0 -3
- data/vendor/redis/lib/redis.rb +0 -496
- data/vendor/redis/lib/redis/client.rb +0 -265
- data/vendor/redis/lib/redis/dist_redis.rb +0 -118
- data/vendor/redis/lib/redis/distributed.rb +0 -460
- data/vendor/redis/lib/redis/hash_ring.rb +0 -131
- data/vendor/redis/lib/redis/pipeline.rb +0 -13
- data/vendor/redis/lib/redis/raketasks.rb +0 -1
- data/vendor/redis/lib/redis/subscribe.rb +0 -79
- data/vendor/redis/profile.rb +0 -22
- data/vendor/redis/tasks/redis.tasks.rb +0 -140
- data/vendor/redis/test/db/.gitignore +0 -1
- data/vendor/redis/test/distributed_test.rb +0 -1131
- data/vendor/redis/test/redis_test.rb +0 -1134
- data/vendor/redis/test/test.conf +0 -8
- data/vendor/redis/test/test_helper.rb +0 -113
data/vendor/redis/test/test.conf
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
-
|
3
|
-
$VERBOSE = true
|
4
|
-
|
5
|
-
require "test/unit"
|
6
|
-
require "logger"
|
7
|
-
require "stringio"
|
8
|
-
require "redis"
|
9
|
-
require "stringio"
|
10
|
-
|
11
|
-
begin
|
12
|
-
require "ruby-debug"
|
13
|
-
rescue LoadError
|
14
|
-
end
|
15
|
-
|
16
|
-
def capture_stderr
|
17
|
-
stderr = $stderr
|
18
|
-
$stderr = StringIO.new
|
19
|
-
|
20
|
-
yield
|
21
|
-
|
22
|
-
$stderr = stderr
|
23
|
-
end
|
24
|
-
|
25
|
-
def ensure_redis_running(r)
|
26
|
-
begin
|
27
|
-
@r.ping
|
28
|
-
rescue Errno::ECONNREFUSED
|
29
|
-
puts <<-EOS
|
30
|
-
|
31
|
-
Cannot connect to Redis.
|
32
|
-
|
33
|
-
Make sure Redis is running on localhost, port 6379.
|
34
|
-
This testing suite connects to the database 15.
|
35
|
-
|
36
|
-
To start the server:
|
37
|
-
rake start
|
38
|
-
|
39
|
-
To stop the server:
|
40
|
-
rake stop
|
41
|
-
|
42
|
-
EOS
|
43
|
-
exit 1
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Test::Unit loads a default test if the suite is empty, whose purpose is to
|
48
|
-
# fail. Since having empty contexts is a common practice, we decided to
|
49
|
-
# overwrite TestSuite#empty? in order to allow them. Having a failure when no
|
50
|
-
# tests have been defined seems counter-intuitive.
|
51
|
-
class Test::Unit::TestSuite
|
52
|
-
def empty?
|
53
|
-
false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
# Contest adds +teardown+, +test+ and +context+ as class methods, and the
|
58
|
-
# instance methods +setup+ and +teardown+ now iterate on the corresponding
|
59
|
-
# blocks. Note that all setup and teardown blocks must be defined with the
|
60
|
-
# block syntax. Adding setup or teardown instance methods defeats the purpose
|
61
|
-
# of this library.
|
62
|
-
class Test::Unit::TestCase
|
63
|
-
def self.setup(&block)
|
64
|
-
define_method :setup do
|
65
|
-
super(&block)
|
66
|
-
instance_eval(&block)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.teardown(&block)
|
71
|
-
define_method :teardown do
|
72
|
-
instance_eval(&block)
|
73
|
-
super(&block)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.context(*name, &block)
|
78
|
-
subclass = Class.new(self)
|
79
|
-
remove_tests(subclass)
|
80
|
-
subclass.class_eval(&block) if block_given?
|
81
|
-
const_set(context_name(name.join(" ")), subclass)
|
82
|
-
end
|
83
|
-
|
84
|
-
def self.test(name, &block)
|
85
|
-
block ||= lambda { print "P" }
|
86
|
-
define_method(test_name(name), &block)
|
87
|
-
end
|
88
|
-
|
89
|
-
class << self
|
90
|
-
alias_method :should, :test
|
91
|
-
alias_method :describe, :context
|
92
|
-
end
|
93
|
-
|
94
|
-
private
|
95
|
-
|
96
|
-
def self.context_name(name)
|
97
|
-
"Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}".to_sym
|
98
|
-
end
|
99
|
-
|
100
|
-
def self.test_name(name)
|
101
|
-
"test_#{sanitize_name(name).gsub(/\s+/,'_')}".to_sym
|
102
|
-
end
|
103
|
-
|
104
|
-
def self.sanitize_name(name)
|
105
|
-
name.gsub(/\W+/, ' ').strip
|
106
|
-
end
|
107
|
-
|
108
|
-
def self.remove_tests(subclass)
|
109
|
-
subclass.public_instance_methods.grep(/^test_/).each do |meth|
|
110
|
-
subclass.send(:undef_method, meth.to_sym)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|