Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:rhomobile/rhosync
Browse files Browse the repository at this point in the history
  • Loading branch information
adamblum committed Feb 13, 2009
2 parents 0ce04a9 + 1b56003 commit 0401f24
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
6 changes: 6 additions & 0 deletions app/controllers/sources_controller.rb
Expand Up @@ -55,6 +55,12 @@ def ask
raise "You need to provide a question to answer"
end

@object_values.collect! { |x|
x.id = x.hash_from_data(x.attrib,x.object,x.update_type,x.source_id,x.user_id,x.value)
x.db_operation = 'insert'
x.update_type = 'query'
x
}
respond_to do |format|
format.html { render :action=>"show"}
format.xml { render :action=>"show"}
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Expand Up @@ -22,6 +22,7 @@

map.connect 'sources/:id/clientcreate', :controller => 'sources', :action => 'clientcreate'
map.connect 'sources/:id/client_login', :controller => 'sessions', :action => 'client_login'
map.connect 'sources/:id/ask', :controller => 'sources', :action => 'ask'

# build in CRUD
map.connect 'sources/:id/create', :controller => 'sources', :action => 'create'
Expand All @@ -43,6 +44,7 @@
map.connect 'apps/:app_id/sources/:id/updateobjects', :controller => 'sources', :action => 'updateobjects'
map.connect 'apps/:app_id/sources/:id/createobjects', :controller => 'sources', :action => 'createobjects'
map.connect 'apps/:app_id/sources/:id/deleteobjects', :controller => 'sources', :action => 'deleteobjects'
map.connect 'apps/:app_id/sources/:id/ask', :controller => 'sources', :action => 'ask'

map.connect 'sources/:id/refresh', :controller => 'sources', :action => 'refresh'
map.connect 'apps/:app_id/sources/:id/refresh', :controller => 'sources', :action => 'refresh'
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20090212192727_add_anonymous_user_to_users.rb
@@ -0,0 +1,8 @@
class AddAnonymousUserToUsers < ActiveRecord::Migration
def self.up
User.create(:login => "anonymous", :password => "password", :password_confirmation=> "password", :email => "anonymous@rhomobile.com")
end

def self.down
end
end
4 changes: 3 additions & 1 deletion db/migrate/users.yml
Expand Up @@ -2,9 +2,11 @@
anonymous:
id: 1
login: anonymous
name: anonymous
password:
email: anonymous@rhomobile.com

crypted_password: 60f34fbfd74fd167441847fbf1972bb7618171b2

admin:
id: 2
login: admin
Expand Down
14 changes: 9 additions & 5 deletions lib/wikipedia.rb
Expand Up @@ -14,13 +14,17 @@ def initialize(source,credential)
def ask(question)
puts "Wikipedia ask with #{question.inspect.to_s}\n"

@search_query = question[:search]

data = ask_wikipedia @search_query
data = ask_wikipedia question

# return array of objects that correspond
[ ObjectValue.new(:source_id=>@source.id, :object => @search_query, :attrib => "data_length", :value => data.length.to_s),
ObjectValue.new(:source_id=>@source.id, :object => @search_query, :attrib => "data", :value => data) ]
[ ObjectValue.new(:source_id=>@source.id,
:object => question,
:attrib => "data_length",
:value => data.length.to_s),
ObjectValue.new(:source_id=>@source.id,
:object => question,
:attrib => "data",
:value => data) ]
end

####### begin legacy interface #######
Expand Down

0 comments on commit 0401f24

Please sign in to comment.