KITAITI Makoto
null+****@clear*****
Thu Dec 25 03:42:28 JST 2014
KITAITI Makoto 2014-12-25 03:42:28 +0900 (Thu, 25 Dec 2014) New Revision: 627179aaab797d42269bdd12ee2caf3f1779b953 https://github.com/ranguba/epub-searcher/commit/627179aaab797d42269bdd12ee2caf3f1779b953 Message: Define RemoteDatabase#select Modified files: lib/epub-searcher/remote-database.rb test/epub-searcher/remote_database_test.rb Modified: lib/epub-searcher/remote-database.rb (+8 -0) =================================================================== --- lib/epub-searcher/remote-database.rb 2014-12-25 01:53:46 +0900 (681c84c) +++ lib/epub-searcher/remote-database.rb 2014-12-25 03:42:28 +0900 (2c024f6) @@ -2,6 +2,8 @@ require 'groonga/client' module EPUBSearcher class RemoteDatabase + GROONGA_COMMAND_VERSION = 2 + attr_reader :client def initialize(options={}) @@ -24,6 +26,12 @@ module EPUBSearcher groonga_setup_db_terms end + def select(params = {}) + params = params.dup + params[:command_version] ||= GROONGA_COMMAND_VERSION + @client.select(params).records + end + private def groonga_setup_db_books @client.table_create(:name => :Books, :flags => 'TABLE_NO_KEY') Modified: test/epub-searcher/remote_database_test.rb (+24 -0) =================================================================== --- test/epub-searcher/remote_database_test.rb 2014-12-25 01:53:46 +0900 (5c697c0) +++ test/epub-searcher/remote_database_test.rb 2014-12-25 03:42:28 +0900 (d02178b) @@ -73,8 +73,32 @@ class TestRemoteDatabase < Test::Unit::TestCase end end + def test_select_records + select_params = { + :table => :Books, + :query => 'query words', + :match_columns => 'author,title,main_text', + :output_columns => 'author,title,snippet_html(main_text)', + :command_version => 2 + } + @database.client.expects(:select).with(select_params).returns(search_result) + + @database.select( + :table => :Books, + :query => 'query words', + :match_columns => 'author,title,main_text', + :output_columns => 'author,title,snippet_html(main_text)' + ) + end + private def fixture_path(basename) File.join(__dir__, 'fixtures', basename) end + + def search_result + result = Object.new + result.stubs(:records) + result + end end -------------- next part -------------- HTML����������������������������...다운로드