ultrasphinx 1.5.2 → 1.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -3
- data/CHANGELOG +2 -0
- data/Manifest +134 -28
- data/TODO +0 -1
- data/examples/{app.multi → ap.multi} +1 -1
- data/examples/default.base +2 -0
- data/lib/ultrasphinx.rb +19 -17
- data/lib/ultrasphinx/configure.rb +36 -28
- data/lib/ultrasphinx/core_extensions.rb +11 -1
- data/lib/ultrasphinx/fields.rb +16 -9
- data/lib/ultrasphinx/hex_to_int.sql +15 -0
- data/lib/ultrasphinx/is_indexed.rb +9 -7
- data/lib/ultrasphinx/search.rb +27 -13
- data/lib/ultrasphinx/search/internals.rb +36 -16
- data/lib/ultrasphinx/spell.rb +13 -4
- data/lib/ultrasphinx/ultrasphinx.rb +30 -20
- data/tasks/ultrasphinx.rake +31 -6
- data/test/integration/app/README +182 -0
- data/test/integration/app/Rakefile +10 -0
- data/test/integration/app/app/controllers/addresses_controller.rb +85 -0
- data/test/integration/app/app/controllers/application.rb +7 -0
- data/test/integration/app/app/controllers/sellers_controller.rb +85 -0
- data/test/integration/app/app/controllers/states_controller.rb +85 -0
- data/test/integration/app/app/controllers/users_controller.rb +85 -0
- data/test/integration/app/app/helpers/addresses_helper.rb +2 -0
- data/test/integration/app/app/helpers/application_helper.rb +3 -0
- data/test/integration/app/app/helpers/sellers_helper.rb +28 -0
- data/test/integration/app/app/helpers/states_helper.rb +2 -0
- data/test/integration/app/app/helpers/users_helper.rb +2 -0
- data/test/integration/app/app/models/geo/address.rb +8 -0
- data/test/integration/app/app/models/geo/state.rb +5 -0
- data/test/integration/app/app/models/person/user.rb +9 -0
- data/test/integration/app/app/models/seller.rb +20 -0
- data/test/integration/app/app/views/addresses/edit.html.erb +12 -0
- data/test/integration/app/app/views/addresses/index.html.erb +18 -0
- data/test/integration/app/app/views/addresses/new.html.erb +11 -0
- data/test/integration/app/app/views/addresses/show.html.erb +3 -0
- data/test/integration/app/app/views/layouts/addresses.html.erb +17 -0
- data/test/integration/app/app/views/layouts/sellers.html.erb +17 -0
- data/test/integration/app/app/views/layouts/states.html.erb +17 -0
- data/test/integration/app/app/views/layouts/users.html.erb +17 -0
- data/test/integration/app/app/views/sellers/edit.html.erb +12 -0
- data/test/integration/app/app/views/sellers/index.html.erb +20 -0
- data/test/integration/app/app/views/sellers/new.html.erb +11 -0
- data/test/integration/app/app/views/sellers/show.html.erb +3 -0
- data/test/integration/app/app/views/states/edit.html.erb +12 -0
- data/test/integration/app/app/views/states/index.html.erb +19 -0
- data/test/integration/app/app/views/states/new.html.erb +11 -0
- data/test/integration/app/app/views/states/show.html.erb +3 -0
- data/test/integration/app/app/views/users/edit.html.erb +12 -0
- data/test/integration/app/app/views/users/index.html.erb +22 -0
- data/test/integration/app/app/views/users/new.html.erb +11 -0
- data/test/integration/app/app/views/users/show.html.erb +3 -0
- data/test/integration/app/config/boot.rb +45 -0
- data/test/integration/app/config/database.yml +21 -0
- data/test/integration/app/config/environment.rb +11 -0
- data/test/integration/app/config/environments/development.rb +7 -0
- data/test/integration/app/config/environments/production.rb +18 -0
- data/test/integration/app/config/environments/test.rb +19 -0
- data/test/integration/app/config/locomotive.yml +6 -0
- data/test/integration/app/config/routes.rb +33 -0
- data/test/integration/app/config/ultrasphinx/default.base +56 -0
- data/test/integration/app/config/ultrasphinx/development.conf +159 -0
- data/test/integration/app/config/ultrasphinx/development.conf.canonical +159 -0
- data/test/integration/app/db/migrate/001_create_users.rb +16 -0
- data/test/integration/app/db/migrate/002_create_sellers.rb +14 -0
- data/test/integration/app/db/migrate/003_create_addresses.rb +19 -0
- data/test/integration/app/db/migrate/004_create_states.rb +12 -0
- data/test/integration/app/db/migrate/005_add_capitalization_to_seller.rb +9 -0
- data/test/integration/app/db/migrate/006_add_deleted_to_user.rb +9 -0
- data/test/integration/app/db/migrate/007_add_lat_and_long_to_address.rb +11 -0
- data/test/integration/app/db/migrate/008_add_mission_statement_to_seller.rb +9 -0
- data/test/integration/app/db/schema.rb +45 -0
- data/test/integration/app/doc/README_FOR_APP +2 -0
- data/test/integration/app/public/404.html +30 -0
- data/test/integration/app/public/500.html +30 -0
- data/test/integration/app/public/dispatch.cgi +10 -0
- data/test/integration/app/public/dispatch.fcgi +24 -0
- data/test/integration/app/public/dispatch.rb +10 -0
- data/test/integration/app/public/favicon.ico +0 -0
- data/test/integration/app/public/images/rails.png +0 -0
- data/test/integration/app/public/index.html +277 -0
- data/test/integration/app/public/javascripts/application.js +2 -0
- data/test/integration/app/public/javascripts/controls.js +833 -0
- data/test/integration/app/public/javascripts/dragdrop.js +942 -0
- data/test/integration/app/public/javascripts/effects.js +1088 -0
- data/test/integration/app/public/javascripts/prototype.js +2515 -0
- data/test/integration/app/public/robots.txt +1 -0
- data/test/integration/app/public/stylesheets/scaffold.css +74 -0
- data/test/integration/app/script/about +3 -0
- data/test/integration/app/script/breakpointer +3 -0
- data/test/integration/app/script/console +3 -0
- data/test/integration/app/script/destroy +3 -0
- data/test/integration/app/script/generate +3 -0
- data/test/integration/app/script/performance/benchmarker +3 -0
- data/test/integration/app/script/performance/profiler +3 -0
- data/test/integration/app/script/plugin +3 -0
- data/test/integration/app/script/process/inspector +3 -0
- data/test/integration/app/script/process/reaper +3 -0
- data/test/integration/app/script/process/spawner +3 -0
- data/test/integration/app/script/runner +3 -0
- data/test/integration/app/script/server +3 -0
- data/test/integration/app/test/fixtures/addresses.yml +13 -0
- data/test/integration/app/test/fixtures/sellers.yml +11 -0
- data/test/integration/app/test/fixtures/states.yml +216 -0
- data/test/integration/app/test/fixtures/users.yml +11 -0
- data/test/integration/app/test/functional/addresses_controller_test.rb +57 -0
- data/test/integration/app/test/functional/sellers_controller_test.rb +57 -0
- data/test/integration/app/test/functional/states_controller_test.rb +57 -0
- data/test/integration/app/test/functional/users_controller_test.rb +57 -0
- data/test/integration/app/test/test_helper.rb +28 -0
- data/test/integration/app/test/unit/address_test.rb +10 -0
- data/test/integration/app/test/unit/seller_test.rb +10 -0
- data/test/integration/app/test/unit/state_test.rb +10 -0
- data/test/integration/app/test/unit/user_test.rb +10 -0
- data/test/integration/configure_test.rb +23 -0
- data/test/integration/search_test.rb +221 -0
- data/test/integration/server_test.rb +38 -0
- data/test/integration/spell_test.rb +15 -0
- data/test/setup.rb +12 -0
- data/test/test_all.rb +1 -0
- data/test/test_helper.rb +13 -24
- data/test/ts.multi +2 -0
- data/test/unit/parser_test.rb +86 -86
- data/ultrasphinx.gemspec +12 -5
- metadata +136 -30
- 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,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,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,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,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,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,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,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,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 %>
|