ultrasphinx 1.5.2 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data.tar.gz.sig +2 -3
  2. data/CHANGELOG +2 -0
  3. data/Manifest +134 -28
  4. data/TODO +0 -1
  5. data/examples/{app.multi → ap.multi} +1 -1
  6. data/examples/default.base +2 -0
  7. data/lib/ultrasphinx.rb +19 -17
  8. data/lib/ultrasphinx/configure.rb +36 -28
  9. data/lib/ultrasphinx/core_extensions.rb +11 -1
  10. data/lib/ultrasphinx/fields.rb +16 -9
  11. data/lib/ultrasphinx/hex_to_int.sql +15 -0
  12. data/lib/ultrasphinx/is_indexed.rb +9 -7
  13. data/lib/ultrasphinx/search.rb +27 -13
  14. data/lib/ultrasphinx/search/internals.rb +36 -16
  15. data/lib/ultrasphinx/spell.rb +13 -4
  16. data/lib/ultrasphinx/ultrasphinx.rb +30 -20
  17. data/tasks/ultrasphinx.rake +31 -6
  18. data/test/integration/app/README +182 -0
  19. data/test/integration/app/Rakefile +10 -0
  20. data/test/integration/app/app/controllers/addresses_controller.rb +85 -0
  21. data/test/integration/app/app/controllers/application.rb +7 -0
  22. data/test/integration/app/app/controllers/sellers_controller.rb +85 -0
  23. data/test/integration/app/app/controllers/states_controller.rb +85 -0
  24. data/test/integration/app/app/controllers/users_controller.rb +85 -0
  25. data/test/integration/app/app/helpers/addresses_helper.rb +2 -0
  26. data/test/integration/app/app/helpers/application_helper.rb +3 -0
  27. data/test/integration/app/app/helpers/sellers_helper.rb +28 -0
  28. data/test/integration/app/app/helpers/states_helper.rb +2 -0
  29. data/test/integration/app/app/helpers/users_helper.rb +2 -0
  30. data/test/integration/app/app/models/geo/address.rb +8 -0
  31. data/test/integration/app/app/models/geo/state.rb +5 -0
  32. data/test/integration/app/app/models/person/user.rb +9 -0
  33. data/test/integration/app/app/models/seller.rb +20 -0
  34. data/test/integration/app/app/views/addresses/edit.html.erb +12 -0
  35. data/test/integration/app/app/views/addresses/index.html.erb +18 -0
  36. data/test/integration/app/app/views/addresses/new.html.erb +11 -0
  37. data/test/integration/app/app/views/addresses/show.html.erb +3 -0
  38. data/test/integration/app/app/views/layouts/addresses.html.erb +17 -0
  39. data/test/integration/app/app/views/layouts/sellers.html.erb +17 -0
  40. data/test/integration/app/app/views/layouts/states.html.erb +17 -0
  41. data/test/integration/app/app/views/layouts/users.html.erb +17 -0
  42. data/test/integration/app/app/views/sellers/edit.html.erb +12 -0
  43. data/test/integration/app/app/views/sellers/index.html.erb +20 -0
  44. data/test/integration/app/app/views/sellers/new.html.erb +11 -0
  45. data/test/integration/app/app/views/sellers/show.html.erb +3 -0
  46. data/test/integration/app/app/views/states/edit.html.erb +12 -0
  47. data/test/integration/app/app/views/states/index.html.erb +19 -0
  48. data/test/integration/app/app/views/states/new.html.erb +11 -0
  49. data/test/integration/app/app/views/states/show.html.erb +3 -0
  50. data/test/integration/app/app/views/users/edit.html.erb +12 -0
  51. data/test/integration/app/app/views/users/index.html.erb +22 -0
  52. data/test/integration/app/app/views/users/new.html.erb +11 -0
  53. data/test/integration/app/app/views/users/show.html.erb +3 -0
  54. data/test/integration/app/config/boot.rb +45 -0
  55. data/test/integration/app/config/database.yml +21 -0
  56. data/test/integration/app/config/environment.rb +11 -0
  57. data/test/integration/app/config/environments/development.rb +7 -0
  58. data/test/integration/app/config/environments/production.rb +18 -0
  59. data/test/integration/app/config/environments/test.rb +19 -0
  60. data/test/integration/app/config/locomotive.yml +6 -0
  61. data/test/integration/app/config/routes.rb +33 -0
  62. data/test/integration/app/config/ultrasphinx/default.base +56 -0
  63. data/test/integration/app/config/ultrasphinx/development.conf +159 -0
  64. data/test/integration/app/config/ultrasphinx/development.conf.canonical +159 -0
  65. data/test/integration/app/db/migrate/001_create_users.rb +16 -0
  66. data/test/integration/app/db/migrate/002_create_sellers.rb +14 -0
  67. data/test/integration/app/db/migrate/003_create_addresses.rb +19 -0
  68. data/test/integration/app/db/migrate/004_create_states.rb +12 -0
  69. data/test/integration/app/db/migrate/005_add_capitalization_to_seller.rb +9 -0
  70. data/test/integration/app/db/migrate/006_add_deleted_to_user.rb +9 -0
  71. data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +11 -0
  72. data/test/integration/app/db/migrate/008_add_mission_statement_to_seller.rb +9 -0
  73. data/test/integration/app/db/schema.rb +45 -0
  74. data/test/integration/app/doc/README_FOR_APP +2 -0
  75. data/test/integration/app/public/404.html +30 -0
  76. data/test/integration/app/public/500.html +30 -0
  77. data/test/integration/app/public/dispatch.cgi +10 -0
  78. data/test/integration/app/public/dispatch.fcgi +24 -0
  79. data/test/integration/app/public/dispatch.rb +10 -0
  80. data/test/integration/app/public/favicon.ico +0 -0
  81. data/test/integration/app/public/images/rails.png +0 -0
  82. data/test/integration/app/public/index.html +277 -0
  83. data/test/integration/app/public/javascripts/application.js +2 -0
  84. data/test/integration/app/public/javascripts/controls.js +833 -0
  85. data/test/integration/app/public/javascripts/dragdrop.js +942 -0
  86. data/test/integration/app/public/javascripts/effects.js +1088 -0
  87. data/test/integration/app/public/javascripts/prototype.js +2515 -0
  88. data/test/integration/app/public/robots.txt +1 -0
  89. data/test/integration/app/public/stylesheets/scaffold.css +74 -0
  90. data/test/integration/app/script/about +3 -0
  91. data/test/integration/app/script/breakpointer +3 -0
  92. data/test/integration/app/script/console +3 -0
  93. data/test/integration/app/script/destroy +3 -0
  94. data/test/integration/app/script/generate +3 -0
  95. data/test/integration/app/script/performance/benchmarker +3 -0
  96. data/test/integration/app/script/performance/profiler +3 -0
  97. data/test/integration/app/script/plugin +3 -0
  98. data/test/integration/app/script/process/inspector +3 -0
  99. data/test/integration/app/script/process/reaper +3 -0
  100. data/test/integration/app/script/process/spawner +3 -0
  101. data/test/integration/app/script/runner +3 -0
  102. data/test/integration/app/script/server +3 -0
  103. data/test/integration/app/test/fixtures/addresses.yml +13 -0
  104. data/test/integration/app/test/fixtures/sellers.yml +11 -0
  105. data/test/integration/app/test/fixtures/states.yml +216 -0
  106. data/test/integration/app/test/fixtures/users.yml +11 -0
  107. data/test/integration/app/test/functional/addresses_controller_test.rb +57 -0
  108. data/test/integration/app/test/functional/sellers_controller_test.rb +57 -0
  109. data/test/integration/app/test/functional/states_controller_test.rb +57 -0
  110. data/test/integration/app/test/functional/users_controller_test.rb +57 -0
  111. data/test/integration/app/test/test_helper.rb +28 -0
  112. data/test/integration/app/test/unit/address_test.rb +10 -0
  113. data/test/integration/app/test/unit/seller_test.rb +10 -0
  114. data/test/integration/app/test/unit/state_test.rb +10 -0
  115. data/test/integration/app/test/unit/user_test.rb +10 -0
  116. data/test/integration/configure_test.rb +23 -0
  117. data/test/integration/search_test.rb +221 -0
  118. data/test/integration/server_test.rb +38 -0
  119. data/test/integration/spell_test.rb +15 -0
  120. data/test/setup.rb +12 -0
  121. data/test/test_all.rb +1 -0
  122. data/test/test_helper.rb +13 -24
  123. data/test/ts.multi +2 -0
  124. data/test/unit/parser_test.rb +86 -86
  125. data/ultrasphinx.gemspec +12 -5
  126. metadata +136 -30
  127. metadata.gz.sig +0 -0
@@ -0,0 +1,85 @@
1
+ class UsersController < ApplicationController
2
+ # GET /users
3
+ # GET /users.xml
4
+ def index
5
+ @users = User.find(:all)
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @users }
10
+ end
11
+ end
12
+
13
+ # GET /users/1
14
+ # GET /users/1.xml
15
+ def show
16
+ @user = User.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @user }
21
+ end
22
+ end
23
+
24
+ # GET /users/new
25
+ # GET /users/new.xml
26
+ def new
27
+ @user = User.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @user }
32
+ end
33
+ end
34
+
35
+ # GET /users/1/edit
36
+ def edit
37
+ @user = User.find(params[:id])
38
+ end
39
+
40
+ # POST /users
41
+ # POST /users.xml
42
+ def create
43
+ @user = User.new(params[:user])
44
+
45
+ respond_to do |format|
46
+ if @user.save
47
+ flash[:notice] = 'User was successfully created.'
48
+ format.html { redirect_to(@user) }
49
+ format.xml { render :xml => @user, :status => :created, :location => @user }
50
+ else
51
+ format.html { render :action => "new" }
52
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
53
+ end
54
+ end
55
+ end
56
+
57
+ # PUT /users/1
58
+ # PUT /users/1.xml
59
+ def update
60
+ @user = User.find(params[:id])
61
+
62
+ respond_to do |format|
63
+ if @user.update_attributes(params[:user])
64
+ flash[:notice] = 'User was successfully updated.'
65
+ format.html { redirect_to(@user) }
66
+ format.xml { head :ok }
67
+ else
68
+ format.html { render :action => "edit" }
69
+ format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
70
+ end
71
+ end
72
+ end
73
+
74
+ # DELETE /users/1
75
+ # DELETE /users/1.xml
76
+ def destroy
77
+ @user = User.find(params[:id])
78
+ @user.destroy
79
+
80
+ respond_to do |format|
81
+ format.html { redirect_to(users_url) }
82
+ format.xml { head :ok }
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,2 @@
1
+ module AddressesHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,28 @@
1
+ module SellersHelper
2
+
3
+ def display_address(seller)
4
+ logger.info "Seller Data ===================="
5
+ logger.info seller.inspect
6
+ logger.info "Seller responds to address " + seller.respond_to?("address").to_s
7
+ logger.info "Seller responds to address= " + seller.respond_to?("address=").to_s
8
+ # logger.info seller.methods.sort.inspect
9
+ logger.info "User Data ===================="
10
+ logger.info seller.user.inspect
11
+ logger.info "User responds to address " + seller.user.respond_to?("address").to_s
12
+ logger.info "User responds to address= " + seller.user.respond_to?("address=").to_s
13
+ # logger.info seller.user.methods.sort.inspect
14
+ display_address = Array.new
15
+ if seller.address
16
+ display_address << seller.address.city if seller.address.city
17
+ display_address << seller.address.state.abbreviation if seller.address.state && seller.address.state.abbreviation
18
+ display_address << seller.address.zip_postal_code if seller.address.zip_postal_code
19
+ end
20
+
21
+ unless display_address.empty?
22
+ "Location: " + display_address.join(", ")
23
+ else
24
+ "Location: unknown"
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,2 @@
1
+ module StatesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,8 @@
1
+ class Geo::Address < ActiveRecord::Base
2
+ belongs_to :user
3
+ belongs_to :state, :class_name => 'Geo::State'
4
+
5
+ is_indexed 'fields' => ['name'],
6
+ 'concatenate' => [{'fields' => ['line_1', 'line_2', 'city', 'province_region', 'zip_postal_code'], 'as' => 'content'}],
7
+ 'include' => [{'class_name' => 'Geo::State', 'field' => 'name', 'as' => 'state'}]
8
+ end
@@ -0,0 +1,5 @@
1
+ class Geo::State < ActiveRecord::Base
2
+ has_many :"geo/addresses"
3
+
4
+ is_indexed :concatenate => [{:class_name => 'Geo::Address', :field => 'name', :as => 'address_name'}]
5
+ end
@@ -0,0 +1,9 @@
1
+ class User < ActiveRecord::Base
2
+ has_one :seller
3
+ has_one :address, :class_name => "Geo::Address"
4
+
5
+ is_indexed :fields => ['login', 'email', 'deleted'],
6
+ :include => [{:class_name => 'Seller', :field => 'company_name', :as => 'company'}],
7
+ :conditions => 'deleted = 0'
8
+
9
+ end
@@ -0,0 +1,20 @@
1
+ class Seller < ActiveRecord::Base
2
+ belongs_to :user
3
+ delegate :address, :to => :user
4
+
5
+ is_indexed :fields => [
6
+ {:field => 'company_name', :facet => true},
7
+ {:field => 'mission_statement', :sortable => true},
8
+ 'created_at',
9
+ 'capitalization',
10
+ 'user_id'
11
+ ]
12
+
13
+ def name
14
+ company_name
15
+ end
16
+
17
+ def metadata
18
+ "sfdkjl fsdjkl sdfjl fdsjk #{company_name} " * 5
19
+ end
20
+ end
@@ -0,0 +1,12 @@
1
+ <h1>Editing address</h1>
2
+
3
+ <%= error_messages_for :address %>
4
+
5
+ <% form_for(@address) do |f| %>
6
+ <p>
7
+ <%= f.submit "Update" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Show', @address %> |
12
+ <%= link_to 'Back', addresses_path %>
@@ -0,0 +1,18 @@
1
+ <h1>Listing addresses</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ </tr>
6
+
7
+ <% for address in @addresses %>
8
+ <tr>
9
+ <td><%= link_to 'Show', address %></td>
10
+ <td><%= link_to 'Edit', edit_address_path(address) %></td>
11
+ <td><%= link_to 'Destroy', address, :confirm => 'Are you sure?', :method => :delete %></td>
12
+ </tr>
13
+ <% end %>
14
+ </table>
15
+
16
+ <br />
17
+
18
+ <%= link_to 'New address', new_address_path %>
@@ -0,0 +1,11 @@
1
+ <h1>New address</h1>
2
+
3
+ <%= error_messages_for :address %>
4
+
5
+ <% form_for(@address) do |f| %>
6
+ <p>
7
+ <%= f.submit "Create" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Back', addresses_path %>
@@ -0,0 +1,3 @@
1
+
2
+ <%= link_to 'Edit', edit_address_path(@address) %> |
3
+ <%= link_to 'Back', addresses_path %>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Addresses: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Sellers: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>States: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7
+ <title>Users: <%= controller.action_name %></title>
8
+ <%= stylesheet_link_tag 'scaffold' %>
9
+ </head>
10
+ <body>
11
+
12
+ <p style="color: green"><%= flash[:notice] %></p>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,12 @@
1
+ <h1>Editing seller</h1>
2
+
3
+ <%= error_messages_for :seller %>
4
+
5
+ <% form_for(@seller) do |f| %>
6
+ <p>
7
+ <%= f.submit "Update" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Show', @seller %> |
12
+ <%= link_to 'Back', sellers_path %>
@@ -0,0 +1,20 @@
1
+ <h1>Listing sellers</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ </tr>
6
+
7
+ <% for seller in @sellers %>
8
+ <tr>
9
+ <td><%= h(seller.company_name) %></td>
10
+ <td><%= h(display_address(seller)) %></td>
11
+ <td><%= link_to 'Show', seller %></td>
12
+ <td><%= link_to 'Edit', edit_seller_path(seller) %></td>
13
+ <td><%= link_to 'Destroy', seller, :confirm => 'Are you sure?', :method => :delete %></td>
14
+ </tr>
15
+ <% end %>
16
+ </table>
17
+
18
+ <br />
19
+
20
+ <%= link_to 'New seller', new_seller_path %>
@@ -0,0 +1,11 @@
1
+ <h1>New seller</h1>
2
+
3
+ <%= error_messages_for :seller %>
4
+
5
+ <% form_for(@seller) do |f| %>
6
+ <p>
7
+ <%= f.submit "Create" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Back', sellers_path %>
@@ -0,0 +1,3 @@
1
+
2
+ <%= link_to 'Edit', edit_seller_path(@seller) %> |
3
+ <%= link_to 'Back', sellers_path %>
@@ -0,0 +1,12 @@
1
+ <h1>Editing state</h1>
2
+
3
+ <%= error_messages_for :state %>
4
+
5
+ <% form_for(@state) do |f| %>
6
+ <p>
7
+ <%= f.submit "Update" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Show', @state %> |
12
+ <%= link_to 'Back', states_path %>
@@ -0,0 +1,19 @@
1
+ <h1>Listing states</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ </tr>
6
+
7
+ <% for state in @states %>
8
+ <tr>
9
+ <td><%= state.name %></td>
10
+ <td><%= link_to 'Show', state %></td>
11
+ <td><%= link_to 'Edit', edit_state_path(state) %></td>
12
+ <td><%= link_to 'Destroy', state, :confirm => 'Are you sure?', :method => :delete %></td>
13
+ </tr>
14
+ <% end %>
15
+ </table>
16
+
17
+ <br />
18
+
19
+ <%= link_to 'New state', new_state_path %>
@@ -0,0 +1,11 @@
1
+ <h1>New state</h1>
2
+
3
+ <%= error_messages_for :state %>
4
+
5
+ <% form_for(@state) do |f| %>
6
+ <p>
7
+ <%= f.submit "Create" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Back', states_path %>
@@ -0,0 +1,3 @@
1
+
2
+ <%= link_to 'Edit', edit_state_path(@state) %> |
3
+ <%= link_to 'Back', states_path %>
@@ -0,0 +1,12 @@
1
+ <h1>Editing user</h1>
2
+
3
+ <%= error_messages_for :user %>
4
+
5
+ <% form_for(@user) do |f| %>
6
+ <p>
7
+ <%= f.submit "Update" %>
8
+ </p>
9
+ <% end %>
10
+
11
+ <%= link_to 'Show', @user %> |
12
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,22 @@
1
+ <h1>Listing users</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ </tr>
6
+
7
+ <% for user in @users %>
8
+ <tr>
9
+ <td><%= h(user.login) %></td>
10
+ <td><%= h(user.address.line_1) %></td>
11
+ <td><%= h(user.address.city) %></td>
12
+ <td><%= h(user.address.state.name) %></td>
13
+ <td><%= link_to 'Show', user %></td>
14
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
15
+ <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
16
+ </tr>
17
+ <% end %>
18
+ </table>
19
+
20
+ <br />
21
+
22
+ <%= link_to 'New user', new_user_path %>