riddle 0.9.8.1112 → 0.9.8.1198

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/README +17 -4
  2. data/lib/riddle.rb +4 -2
  3. data/lib/riddle/client.rb +51 -12
  4. data/spec/functional/keywords_spec.rb +40 -0
  5. data/spec/unit/client_spec.rb +26 -0
  6. metadata +3 -61
  7. data/spec/fixtures/data/anchor.bin +0 -0
  8. data/spec/fixtures/data/any.bin +0 -0
  9. data/spec/fixtures/data/boolean.bin +0 -0
  10. data/spec/fixtures/data/distinct.bin +0 -0
  11. data/spec/fixtures/data/field_weights.bin +0 -0
  12. data/spec/fixtures/data/filter.bin +0 -0
  13. data/spec/fixtures/data/filter_array.bin +0 -0
  14. data/spec/fixtures/data/filter_array_exclude.bin +0 -0
  15. data/spec/fixtures/data/filter_floats.bin +0 -0
  16. data/spec/fixtures/data/filter_floats_exclude.bin +0 -0
  17. data/spec/fixtures/data/filter_floats_range.bin +0 -0
  18. data/spec/fixtures/data/filter_range.bin +0 -0
  19. data/spec/fixtures/data/filter_range_exclude.bin +0 -0
  20. data/spec/fixtures/data/group.bin +0 -0
  21. data/spec/fixtures/data/index.bin +0 -0
  22. data/spec/fixtures/data/index_weights.bin +0 -0
  23. data/spec/fixtures/data/phrase.bin +0 -0
  24. data/spec/fixtures/data/rank_mode.bin +0 -0
  25. data/spec/fixtures/data/simple.bin +0 -0
  26. data/spec/fixtures/data/sort.bin +0 -0
  27. data/spec/fixtures/data/update_simple.bin +0 -0
  28. data/spec/fixtures/data/weights.bin +0 -0
  29. data/spec/fixtures/data_generator.php +0 -130
  30. data/spec/fixtures/sphinx/configuration.erb +0 -38
  31. data/spec/fixtures/sphinx/people.old.spa +0 -0
  32. data/spec/fixtures/sphinx/people.old.spd +0 -0
  33. data/spec/fixtures/sphinx/people.old.sph +0 -0
  34. data/spec/fixtures/sphinx/people.old.spi +0 -0
  35. data/spec/fixtures/sphinx/people.old.spm +0 -0
  36. data/spec/fixtures/sphinx/people.old.spp +0 -0
  37. data/spec/fixtures/sphinx/people.spa +0 -0
  38. data/spec/fixtures/sphinx/people.spd +0 -0
  39. data/spec/fixtures/sphinx/people.sph +0 -0
  40. data/spec/fixtures/sphinx/people.spi +0 -0
  41. data/spec/fixtures/sphinx/people.spm +0 -0
  42. data/spec/fixtures/sphinx/people.spp +0 -0
  43. data/spec/fixtures/sphinx/searchd.log +0 -4732
  44. data/spec/fixtures/sphinx/searchd.query.log +0 -783
  45. data/spec/fixtures/sphinx/spec.conf +0 -38
  46. data/spec/fixtures/sphinxapi.php +0 -1066
  47. data/spec/fixtures/sql/conf.example.yml +0 -3
  48. data/spec/fixtures/sql/conf.yml +0 -3
  49. data/spec/fixtures/sql/data.sql +0 -25000
  50. data/spec/fixtures/sql/structure.sql +0 -16
  51. data/spec/spec_helper.rb +0 -26
  52. data/spec/sphinx_helper.rb +0 -92
@@ -1,16 +0,0 @@
1
- DROP TABLE `people`;
2
-
3
- CREATE TABLE `people` (
4
- `id` int(11) NOT NULL auto_increment,
5
- `first_name` varchar(50) NOT NULL,
6
- `middle_initial` varchar(10) NOT NULL,
7
- `last_name` varchar(50) NOT NULL,
8
- `gender` varchar(10) NOT NULL,
9
- `street_address` varchar(200) NOT NULL,
10
- `city` varchar(100) NOT NULL,
11
- `state` varchar(100) NOT NULL,
12
- `postcode` varchar(10) NOT NULL,
13
- `email` varchar(100) NOT NULL,
14
- `birthday` datetime NOT NULL,
15
- PRIMARY KEY (`id`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
data/spec/spec_helper.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'riddle'
2
- require 'spec/sphinx_helper'
3
-
4
- Spec::Runner.configure do |config|
5
- sphinx = SphinxHelper.new
6
- sphinx.setup_mysql
7
- sphinx.generate_configuration
8
- sphinx.index
9
-
10
- config.before :all do
11
- `php -f spec/fixtures/data_generator.php`
12
- sphinx.start
13
- end
14
-
15
- # config.before :each do
16
- # sphinx.reset
17
- # end
18
-
19
- config.after :all do
20
- sphinx.stop
21
- end
22
- end
23
-
24
- def query_contents(key)
25
- open("spec/fixtures/data/#{key.to_s}.bin") { |f| f.read }
26
- end
@@ -1,92 +0,0 @@
1
- require 'mysql'
2
- require 'erb'
3
- require 'yaml'
4
-
5
- class SphinxHelper
6
- attr_accessor :host, :username, :password
7
- attr_reader :path
8
-
9
- def initialize
10
- @host = "localhost"
11
- @username = "anonymous"
12
- @password = ""
13
-
14
- if File.exist?("spec/fixtures/sql/conf.yml")
15
- config = YAML.load(File.open("spec/fixtures/sql/conf.yml"))
16
- @host = config["host"]
17
- @username = config["username"]
18
- @password = config["password"]
19
- end
20
-
21
- @path = File.expand_path(File.dirname(__FILE__))
22
- end
23
-
24
- def setup_mysql
25
- server = Mysql.new @host, @username, @password
26
-
27
- unless server.list_dbs.include?("riddle_sphinx_spec")
28
- server.create_db "riddle_sphinx_spec"
29
- end
30
-
31
- server.query "USE riddle_sphinx_spec;"
32
-
33
- structure = File.open("spec/fixtures/sql/structure.sql") { |f| f.read }
34
- # Block ensures multiple statements can be run
35
- server.query(structure) { }
36
- data = File.open("spec/fixtures/sql/data.sql") { |f|
37
- while line = f.gets
38
- server.query line
39
- end
40
- }
41
-
42
- server.close
43
- end
44
-
45
- def reset
46
- setup_mysql
47
- index
48
- end
49
-
50
- def generate_configuration
51
- template = File.open("spec/fixtures/sphinx/configuration.erb") { |f| f.read }
52
- File.open("spec/fixtures/sphinx/spec.conf", "w") { |f|
53
- f.puts ERB.new(template).result(binding)
54
- }
55
- end
56
-
57
- def index
58
- cmd = "indexer --config #{@path}/fixtures/sphinx/spec.conf --all"
59
- cmd << " --rotate" if running?
60
- `#{cmd}`
61
- end
62
-
63
- def start
64
- return if running?
65
-
66
- cmd = "searchd --config #{@path}/fixtures/sphinx/spec.conf"
67
- `#{cmd}`
68
-
69
- sleep(1)
70
-
71
- unless running?
72
- puts "Failed to start searchd daemon. Check fixtures/sphinx/searchd.log."
73
- end
74
- end
75
-
76
- def stop
77
- return unless running?
78
- `kill #{pid}`
79
- end
80
-
81
- def pid
82
- if File.exists?("#{@path}/fixtures/sphinx/searchd.pid")
83
- `cat #{@path}/fixtures/sphinx/searchd.pid`[/\d+/]
84
- else
85
- nil
86
- end
87
- end
88
-
89
- def running?
90
- pid && `ps #{pid} | wc -l`.to_i > 1
91
- end
92
- end