lunar 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/.gitignore +2 -1
  2. data/LICENSE +1 -1
  3. data/README.markdown +116 -0
  4. data/Rakefile +6 -5
  5. data/VERSION +1 -1
  6. data/lib/lunar.rb +112 -24
  7. data/lib/lunar/connection.rb +51 -0
  8. data/lib/lunar/fuzzy_matches.rb +24 -0
  9. data/lib/lunar/fuzzy_word.rb +2 -2
  10. data/lib/lunar/index.rb +200 -94
  11. data/lib/lunar/keyword_matches.rb +32 -0
  12. data/lib/lunar/lunar_nest.rb +19 -0
  13. data/lib/lunar/range_matches.rb +28 -0
  14. data/lib/lunar/result_set.rb +85 -28
  15. data/lib/lunar/scoring.rb +4 -2
  16. data/lib/lunar/stopwords.rb +15 -0
  17. data/lib/lunar/words.rb +6 -3
  18. data/lunar.gemspec +31 -60
  19. data/test/helper.rb +4 -5
  20. data/test/test_fuzzy_indexing.rb +105 -0
  21. data/test/test_index.rb +150 -0
  22. data/test/test_lunar.rb +178 -1
  23. data/test/test_lunar_fuzzy_word.rb +4 -4
  24. data/test/test_lunar_nest.rb +46 -0
  25. data/test/{test_lunar_scoring.rb → test_scoring.rb} +5 -5
  26. metadata +72 -68
  27. data/.document +0 -5
  28. data/DATA +0 -41
  29. data/README.md +0 -80
  30. data/examples/ohm.rb +0 -40
  31. data/lib/lunar/search.rb +0 -68
  32. data/lib/lunar/sets.rb +0 -86
  33. data/test/test_lunar_fuzzy.rb +0 -118
  34. data/test/test_lunar_index.rb +0 -191
  35. data/test/test_lunar_search.rb +0 -261
  36. data/test/test_sets.rb +0 -48
  37. data/vendor/nest/nest.rb +0 -7
  38. data/vendor/redis/.gitignore +0 -9
  39. data/vendor/redis/LICENSE +0 -20
  40. data/vendor/redis/README.markdown +0 -120
  41. data/vendor/redis/Rakefile +0 -75
  42. data/vendor/redis/benchmarking/logging.rb +0 -62
  43. data/vendor/redis/benchmarking/pipeline.rb +0 -44
  44. data/vendor/redis/benchmarking/speed.rb +0 -21
  45. data/vendor/redis/benchmarking/suite.rb +0 -24
  46. data/vendor/redis/benchmarking/worker.rb +0 -71
  47. data/vendor/redis/bin/distredis +0 -33
  48. data/vendor/redis/examples/basic.rb +0 -15
  49. data/vendor/redis/examples/dist_redis.rb +0 -43
  50. data/vendor/redis/examples/incr-decr.rb +0 -17
  51. data/vendor/redis/examples/list.rb +0 -26
  52. data/vendor/redis/examples/pubsub.rb +0 -25
  53. data/vendor/redis/examples/sets.rb +0 -36
  54. data/vendor/redis/lib/edis.rb +0 -3
  55. data/vendor/redis/lib/redis.rb +0 -496
  56. data/vendor/redis/lib/redis/client.rb +0 -265
  57. data/vendor/redis/lib/redis/dist_redis.rb +0 -118
  58. data/vendor/redis/lib/redis/distributed.rb +0 -460
  59. data/vendor/redis/lib/redis/hash_ring.rb +0 -131
  60. data/vendor/redis/lib/redis/pipeline.rb +0 -13
  61. data/vendor/redis/lib/redis/raketasks.rb +0 -1
  62. data/vendor/redis/lib/redis/subscribe.rb +0 -79
  63. data/vendor/redis/profile.rb +0 -22
  64. data/vendor/redis/tasks/redis.tasks.rb +0 -140
  65. data/vendor/redis/test/db/.gitignore +0 -1
  66. data/vendor/redis/test/distributed_test.rb +0 -1131
  67. data/vendor/redis/test/redis_test.rb +0 -1134
  68. data/vendor/redis/test/test.conf +0 -8
  69. data/vendor/redis/test/test_helper.rb +0 -113
@@ -1,8 +0,0 @@
1
- dir ./test/db
2
- pidfile ./redis.pid
3
- port 6379
4
- timeout 300
5
- loglevel debug
6
- logfile stdout
7
- databases 16
8
- daemonize yes
@@ -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