dpickett-thinking-sphinx 1.1.4 → 1.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.textile +126 -0
  2. data/lib/thinking_sphinx/active_record/attribute_updates.rb +48 -0
  3. data/lib/thinking_sphinx/active_record/delta.rb +14 -1
  4. data/lib/thinking_sphinx/active_record.rb +23 -5
  5. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +9 -1
  6. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +3 -2
  7. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +4 -3
  8. data/lib/thinking_sphinx/association.rb +17 -0
  9. data/lib/thinking_sphinx/attribute.rb +106 -95
  10. data/lib/thinking_sphinx/class_facet.rb +0 -5
  11. data/lib/thinking_sphinx/collection.rb +7 -1
  12. data/lib/thinking_sphinx/configuration.rb +9 -4
  13. data/lib/thinking_sphinx/core/string.rb +3 -10
  14. data/lib/thinking_sphinx/deltas/default_delta.rb +8 -5
  15. data/lib/thinking_sphinx/deltas/delayed_delta.rb +4 -2
  16. data/lib/thinking_sphinx/deltas.rb +7 -2
  17. data/lib/thinking_sphinx/deploy/capistrano.rb +80 -0
  18. data/lib/thinking_sphinx/facet.rb +22 -9
  19. data/lib/thinking_sphinx/facet_collection.rb +27 -12
  20. data/lib/thinking_sphinx/field.rb +4 -96
  21. data/lib/thinking_sphinx/index/builder.rb +46 -15
  22. data/lib/thinking_sphinx/index.rb +58 -66
  23. data/lib/thinking_sphinx/property.rb +133 -0
  24. data/lib/thinking_sphinx/rails_additions.rb +7 -4
  25. data/lib/thinking_sphinx/search.rb +181 -44
  26. data/lib/thinking_sphinx/tasks.rb +4 -4
  27. data/lib/thinking_sphinx.rb +47 -11
  28. data/spec/unit/thinking_sphinx/active_record/delta_spec.rb +2 -2
  29. data/spec/unit/thinking_sphinx/active_record_spec.rb +64 -4
  30. data/spec/unit/thinking_sphinx/attribute_spec.rb +16 -1
  31. data/spec/unit/thinking_sphinx/facet_collection_spec.rb +64 -0
  32. data/spec/unit/thinking_sphinx/facet_spec.rb +46 -0
  33. data/spec/unit/thinking_sphinx/index_spec.rb +90 -0
  34. data/spec/unit/thinking_sphinx/rails_additions_spec.rb +183 -0
  35. data/spec/unit/thinking_sphinx/search_spec.rb +44 -0
  36. data/spec/unit/thinking_sphinx_spec.rb +10 -6
  37. data/tasks/distribution.rb +1 -1
  38. data/tasks/testing.rb +7 -15
  39. data/vendor/after_commit/init.rb +3 -0
  40. data/vendor/after_commit/lib/after_commit/active_record.rb +27 -4
  41. data/vendor/after_commit/lib/after_commit/connection_adapters.rb +1 -1
  42. data/vendor/after_commit/lib/after_commit.rb +4 -1
  43. metadata +12 -3
  44. data/README +0 -107
@@ -53,13 +53,15 @@ describe ThinkingSphinx do
53
53
 
54
54
  describe "use_group_by_shortcut? method" do
55
55
  before :each do
56
- unless ::ActiveRecord::ConnectionAdapters.const_defined?(:MysqlAdapter)
56
+ adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter
57
+ unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter)
57
58
  pending "No MySQL"
58
59
  return
59
60
  end
60
61
 
61
- @connection = ::ActiveRecord::ConnectionAdapters::MysqlAdapter.stub_instance(
62
- :select_all => true
62
+ @connection = ::ActiveRecord::ConnectionAdapters.const_get(adapter).stub_instance(
63
+ :select_all => true,
64
+ :config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'}
63
65
  )
64
66
  ::ActiveRecord::Base.stub_method(
65
67
  :connection => @connection
@@ -103,12 +105,14 @@ describe ThinkingSphinx do
103
105
 
104
106
  describe "if not using MySQL" do
105
107
  before :each do
106
- unless ::ActiveRecord::ConnectionAdapters.const_defined?(:PostgreSQLAdapter)
108
+ adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :PostgreSQLAdapter
109
+ unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter)
107
110
  pending "No PostgreSQL"
108
111
  return
109
112
  end
110
- @connection = ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.stub_instance(
111
- :select_all => true
113
+ @connection = ::ActiveRecord::ConnectionAdapters.const_get(adapter).stub_instance(
114
+ :select_all => true,
115
+ :config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcpostgresql' : 'postgresql'}
112
116
  )
113
117
  ::ActiveRecord::Base.stub_method(
114
118
  :connection => @connection
@@ -29,7 +29,7 @@ spec = Gem::Specification.new do |s|
29
29
  s.files = FileList[
30
30
  "lib/**/*.rb",
31
31
  "LICENCE",
32
- "README",
32
+ "README.textile",
33
33
  "tasks/**/*.rb",
34
34
  "tasks/**/*.rake",
35
35
  "vendor/**/*"
data/tasks/testing.rb CHANGED
@@ -20,13 +20,7 @@ namespace :features do
20
20
  def add_task(name, description)
21
21
  Cucumber::Rake::Task.new(name, description) do |t|
22
22
  t.cucumber_opts = "--format pretty"
23
- t.step_pattern = [
24
- "features/support/env",
25
- "features/support/db/#{name}",
26
- "features/support/db/active_record",
27
- "features/support/post_database",
28
- "features/step_definitions/**.rb"
29
- ]
23
+ t.profile = name
30
24
  end
31
25
  end
32
26
 
@@ -46,13 +40,7 @@ namespace :rcov do
46
40
  def add_task(name, description)
47
41
  Cucumber::Rake::Task.new(name, description) do |t|
48
42
  t.cucumber_opts = "--format pretty"
49
- t.step_pattern = [
50
- "features/support/env",
51
- "features/support/db/#{name}",
52
- "features/support/db/active_record",
53
- "features/support/post_database",
54
- "features/step_definitions/**.rb"
55
- ]
43
+ t.profile = name
56
44
  t.rcov = true
57
45
  t.rcov_opts = [
58
46
  '--exclude', 'spec',
@@ -80,7 +68,11 @@ task :cucumber_defaults do
80
68
  "--require #{path}"
81
69
  }.join(" ")
82
70
 
71
+ features = FileList["features/*.feature"].join(" ")
72
+
83
73
  File.open('cucumber.yml', 'w') { |f|
84
- f.write "default: \"#{default_requires} #{step_definitions}\""
74
+ f.write "default: \"#{default_requires} #{step_definitions}\"\n\n"
75
+ f.write "mysql: \"#{default_requires} #{step_definitions} #{features}\"\n\n"
76
+ f.write "postgresql: \"#{default_requires.gsub(/mysql/, 'postgresql')} #{step_definitions} #{features}\""
85
77
  }
86
78
  end
@@ -3,3 +3,6 @@ ActiveRecord::Base.send(:include, AfterCommit::ActiveRecord)
3
3
  Object.subclasses_of(ActiveRecord::ConnectionAdapters::AbstractAdapter).each do |klass|
4
4
  klass.send(:include, AfterCommit::ConnectionAdapters)
5
5
  end
6
+ if defined?(JRUBY_VERSION) and defined?(JdbcSpec::MySQL)
7
+ JdbcSpec::MySQL.send :include, AfterCommit::ConnectionAdapters
8
+ end
@@ -71,19 +71,42 @@ module AfterCommit
71
71
  # after_commit callback can be made from the ConnectionAdapters when
72
72
  # the commit for the transaction has finally succeeded.
73
73
  def after_commit_callback
74
- callback(:after_commit)
74
+ call_after_commit_callback :after_commit
75
75
  end
76
76
 
77
77
  def after_commit_on_create_callback
78
- callback(:after_commit_on_create)
78
+ call_after_commit_callback :after_commit_on_create
79
79
  end
80
80
 
81
81
  def after_commit_on_update_callback
82
- callback(:after_commit_on_update)
82
+ call_after_commit_callback :after_commit_on_update
83
83
  end
84
84
 
85
85
  def after_commit_on_destroy_callback
86
- callback(:after_commit_on_destroy)
86
+ call_after_commit_callback :after_commit_on_destroy
87
+ end
88
+
89
+ private
90
+
91
+ def call_after_commit_callback(call)
92
+ if can_call_after_commit call
93
+ callback call
94
+ clear_after_commit_call call
95
+ end
96
+ end
97
+
98
+ def can_call_after_commit(call)
99
+ @calls ||= {}
100
+ @calls[call] ||= false
101
+ if @calls[call]
102
+ return false
103
+ else
104
+ @calls[call] = true
105
+ end
106
+ end
107
+
108
+ def clear_after_commit_call(call)
109
+ @calls[call] = false
87
110
  end
88
111
  end
89
112
  end
@@ -7,7 +7,7 @@ module AfterCommit
7
7
  # override it so that after this happens, any records that were saved
8
8
  # or destroyed within this transaction now get their after_commit
9
9
  # callback fired.
10
- def commit_db_transaction_with_callback
10
+ def commit_db_transaction_with_callback
11
11
  commit_db_transaction_without_callback
12
12
  trigger_after_commit_callbacks
13
13
  trigger_after_commit_on_create_callbacks
@@ -39,4 +39,7 @@ ActiveRecord::Base.send(:include, AfterCommit::ActiveRecord)
39
39
 
40
40
  Object.subclasses_of(ActiveRecord::ConnectionAdapters::AbstractAdapter).each do |klass|
41
41
  klass.send(:include, AfterCommit::ConnectionAdapters)
42
- end
42
+ end
43
+ if defined?(JRUBY_VERSION) and defined?(JdbcSpec::MySQL)
44
+ JdbcSpec::MySQL.send :include, AfterCommit::ConnectionAdapters
45
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpickett-thinking-sphinx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Allan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-19 00:00:00 -08:00
12
+ date: 2009-05-11 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -22,6 +22,7 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
+ - lib/thinking_sphinx/active_record/attribute_updates.rb
25
26
  - lib/thinking_sphinx/active_record/delta.rb
26
27
  - lib/thinking_sphinx/active_record/has_many_association.rb
27
28
  - lib/thinking_sphinx/active_record/search.rb
@@ -42,18 +43,20 @@ files:
42
43
  - lib/thinking_sphinx/deltas/delayed_delta/job.rb
43
44
  - lib/thinking_sphinx/deltas/delayed_delta.rb
44
45
  - lib/thinking_sphinx/deltas.rb
46
+ - lib/thinking_sphinx/deploy/capistrano.rb
45
47
  - lib/thinking_sphinx/facet.rb
46
48
  - lib/thinking_sphinx/facet_collection.rb
47
49
  - lib/thinking_sphinx/field.rb
48
50
  - lib/thinking_sphinx/index/builder.rb
49
51
  - lib/thinking_sphinx/index/faux_column.rb
50
52
  - lib/thinking_sphinx/index.rb
53
+ - lib/thinking_sphinx/property.rb
51
54
  - lib/thinking_sphinx/rails_additions.rb
52
55
  - lib/thinking_sphinx/search.rb
53
56
  - lib/thinking_sphinx/tasks.rb
54
57
  - lib/thinking_sphinx.rb
55
58
  - LICENCE
56
- - README
59
+ - README.textile
57
60
  - tasks/distribution.rb
58
61
  - tasks/testing.rb
59
62
  - tasks/rails.rake
@@ -106,10 +109,13 @@ files:
106
109
  - spec/unit/thinking_sphinx/collection_spec.rb
107
110
  - spec/unit/thinking_sphinx/configuration_spec.rb
108
111
  - spec/unit/thinking_sphinx/core/string_spec.rb
112
+ - spec/unit/thinking_sphinx/facet_collection_spec.rb
113
+ - spec/unit/thinking_sphinx/facet_spec.rb
109
114
  - spec/unit/thinking_sphinx/field_spec.rb
110
115
  - spec/unit/thinking_sphinx/index/builder_spec.rb
111
116
  - spec/unit/thinking_sphinx/index/faux_column_spec.rb
112
117
  - spec/unit/thinking_sphinx/index_spec.rb
118
+ - spec/unit/thinking_sphinx/rails_additions_spec.rb
113
119
  - spec/unit/thinking_sphinx/search_spec.rb
114
120
  - spec/unit/thinking_sphinx_spec.rb
115
121
  has_rdoc: true
@@ -150,9 +156,12 @@ test_files:
150
156
  - spec/unit/thinking_sphinx/collection_spec.rb
151
157
  - spec/unit/thinking_sphinx/configuration_spec.rb
152
158
  - spec/unit/thinking_sphinx/core/string_spec.rb
159
+ - spec/unit/thinking_sphinx/facet_collection_spec.rb
160
+ - spec/unit/thinking_sphinx/facet_spec.rb
153
161
  - spec/unit/thinking_sphinx/field_spec.rb
154
162
  - spec/unit/thinking_sphinx/index/builder_spec.rb
155
163
  - spec/unit/thinking_sphinx/index/faux_column_spec.rb
156
164
  - spec/unit/thinking_sphinx/index_spec.rb
165
+ - spec/unit/thinking_sphinx/rails_additions_spec.rb
157
166
  - spec/unit/thinking_sphinx/search_spec.rb
158
167
  - spec/unit/thinking_sphinx_spec.rb
data/README DELETED
@@ -1,107 +0,0 @@
1
- = Thinking Sphinx
2
-
3
- == Usage
4
-
5
- First, if you haven't done so already, check out the main usage[http://ts.freelancing-gods.com/usage.html] page. Once you've done that, the next place to look for information is the specific method docs - ThinkingSphinx::Search and ThinkingSphinx::Index::Builder in particular.
6
-
7
- Keep in mind that while Thinking Sphinx works for ActiveRecord with Merb, it doesn't yet support DataMapper (although that is planned).
8
-
9
- == Contributing
10
-
11
- Fork on GitHub and after you've committed tested patches, send a pull request.
12
-
13
- To get the spec suite running, you will need to install the not-a-mock gem if you don't already have it:
14
-
15
- git clone git://github.com/freelancing-god/not-a-mock.git
16
- cd not-a-mock
17
- rake gem
18
- gem install pkg/not_a_mock-1.1.0.gem
19
-
20
- Then install the ginger gem. The steps are the same, except that you might need to sudo the gem install:
21
-
22
- git clone git://github.com/freelancing-god/ginger.git
23
- cd ginger
24
- rake gem
25
- sudo gem install pkg/ginger-1.1.0.gem
26
-
27
- Then set up your database:
28
-
29
- cp spec/fixtures/database.yml.default spec/fixtures/database.yml
30
- mysqladmin -u root create thinking_sphinx
31
-
32
- Make sure you don't have another Sphinx daemon (searchd) running. If you do, quit it with "rake ts:stop"
33
- in the app root.
34
-
35
- You should now have a passing test suite from which to build your patch on.
36
-
37
- rake spec
38
-
39
- If you get the message "Failed to start searchd daemon", run the spec with sudo:
40
-
41
- sudo rake spec
42
-
43
- If you quit the spec suite before it's completed, you may be left with data in the test
44
- database, causing the next run to have failures. Let that run complete and then try again.
45
-
46
- == Contributors
47
-
48
- Since I first released this library, there's been quite a few people who have submitted patches, to my immense gratitude. Others have suggested syntax changes and general improvements. So my thanks to the following people:
49
-
50
- - Joost Hietbrink
51
- - Jonathan Conway
52
- - Gregory Mirzayantz
53
- - Tung Nguyen
54
- - Sean Cribbs
55
- - Benoit Caccinolo
56
- - John Barton
57
- - Oliver Beddows
58
- - Arthur Zapparoli
59
- - Dusty Doris
60
- - Marcus Crafter
61
- - Patrick Lenz
62
- - Björn Andreasson
63
- - James Healy
64
- - Jae-Jun Hwang
65
- - Xavier Shay
66
- - Jason Rust
67
- - Gopal Patel
68
- - Chris Heald
69
- - Peter Vandenberk
70
- - Josh French
71
- - Andrew Bennett
72
- - Jordan Fowler
73
- - Seth Walker
74
- - Joe Noon
75
- - Wolfgang Postler
76
- - Rick Olson
77
- - Killian Murphy
78
- - Morten Primdahl
79
- - Ryan Bates
80
- - David Eisinger
81
- - Shay Arnett
82
- - Minh Tran
83
- - Jeremy Durham
84
- - Piotr Sarnacki
85
- - Matt Johnson
86
- - Nicolas Blanco
87
- - Max Lapshin
88
- - Josh Natanson
89
- - Philip Hallstrom
90
- - Christian Rishøj
91
- - Mike Flester
92
- - Jim Remsik
93
- - Kennon Ballou
94
- - Henrik Nyh
95
- - Emil Tin
96
- - Doug Cole
97
- - Ed Hickey
98
- - Evan Weaver
99
- - Thibaut Barrere
100
- - Kristopher Chambers
101
- - Dmitrij Smalko
102
- - Aleksey Yeschenko
103
- - Lachie Cox
104
- - Lourens Naude
105
- - Tom Davies
106
- - Dan Pickett
107
- - Alex Caudill