groonga-client-rails 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +6 -0
  3. data/Gemfile +21 -0
  4. data/README.md +57 -0
  5. data/Rakefile +44 -0
  6. data/doc/text/lgpl-2.1.txt +502 -0
  7. data/doc/text/news.md +5 -0
  8. data/groonga-client-rails.gemspec +52 -0
  9. data/lib/groonga-client-rails.rb +23 -0
  10. data/lib/groonga/client/rails/fixture.rb +35 -0
  11. data/lib/groonga/client/rails/groonga_server_runner.rb +164 -0
  12. data/lib/groonga/client/rails/spec_helper.rb +39 -0
  13. data/lib/groonga/client/rails/test_helper.rb +39 -0
  14. data/lib/groonga/client/rails/version.rb +23 -0
  15. data/lib/groonga/client/railtie.rb +70 -0
  16. data/lib/groonga/client/searcher.rb +165 -0
  17. data/lib/groonga/client/searcher/error.rb +37 -0
  18. data/lib/groonga/client/searcher/raw_request.rb +85 -0
  19. data/lib/groonga/client/searcher/schema.rb +74 -0
  20. data/lib/groonga/client/searcher/schema_synchronizer.rb +137 -0
  21. data/lib/groonga/client/searcher/select.rb +18 -0
  22. data/lib/groonga/client/searcher/select/request.rb +266 -0
  23. data/lib/groonga/client/searcher/select/result_set.rb +117 -0
  24. data/lib/groonga/client/searcher/source.rb +59 -0
  25. data/test/apps/rails4-mongoid/Gemfile +50 -0
  26. data/test/apps/rails4-mongoid/Gemfile.lock +190 -0
  27. data/test/apps/rails4-mongoid/README.rdoc +28 -0
  28. data/test/apps/rails4-mongoid/Rakefile +6 -0
  29. data/test/apps/rails4-mongoid/app/assets/javascripts/application.js +16 -0
  30. data/test/apps/rails4-mongoid/app/assets/javascripts/posts.coffee +3 -0
  31. data/test/apps/rails4-mongoid/app/assets/stylesheets/application.css +15 -0
  32. data/test/apps/rails4-mongoid/app/assets/stylesheets/posts.scss +3 -0
  33. data/test/apps/rails4-mongoid/app/assets/stylesheets/scaffolds.scss +73 -0
  34. data/test/apps/rails4-mongoid/app/controllers/application_controller.rb +5 -0
  35. data/test/apps/rails4-mongoid/app/controllers/posts_controller.rb +74 -0
  36. data/test/apps/rails4-mongoid/app/helpers/application_helper.rb +2 -0
  37. data/test/apps/rails4-mongoid/app/helpers/posts_helper.rb +2 -0
  38. data/test/apps/rails4-mongoid/app/models/post.rb +12 -0
  39. data/test/apps/rails4-mongoid/app/searchers/application_searcher.rb +2 -0
  40. data/test/apps/rails4-mongoid/app/searchers/posts_searcher.rb +16 -0
  41. data/test/apps/rails4-mongoid/app/views/layouts/application.html.erb +14 -0
  42. data/test/apps/rails4-mongoid/app/views/posts/_form.html.erb +25 -0
  43. data/test/apps/rails4-mongoid/app/views/posts/edit.html.erb +6 -0
  44. data/test/apps/rails4-mongoid/app/views/posts/index.html.erb +29 -0
  45. data/test/apps/rails4-mongoid/app/views/posts/index.json.jbuilder +4 -0
  46. data/test/apps/rails4-mongoid/app/views/posts/new.html.erb +5 -0
  47. data/test/apps/rails4-mongoid/app/views/posts/show.html.erb +14 -0
  48. data/test/apps/rails4-mongoid/app/views/posts/show.json.jbuilder +1 -0
  49. data/test/apps/rails4-mongoid/bin/bundle +3 -0
  50. data/test/apps/rails4-mongoid/bin/rails +4 -0
  51. data/test/apps/rails4-mongoid/bin/rake +4 -0
  52. data/test/apps/rails4-mongoid/bin/setup +29 -0
  53. data/test/apps/rails4-mongoid/config.ru +4 -0
  54. data/test/apps/rails4-mongoid/config/application.rb +32 -0
  55. data/test/apps/rails4-mongoid/config/boot.rb +3 -0
  56. data/test/apps/rails4-mongoid/config/environment.rb +5 -0
  57. data/test/apps/rails4-mongoid/config/environments/development.rb +38 -0
  58. data/test/apps/rails4-mongoid/config/environments/production.rb +76 -0
  59. data/test/apps/rails4-mongoid/config/environments/test.rb +42 -0
  60. data/test/apps/rails4-mongoid/config/groonga_client.yml +22 -0
  61. data/test/apps/rails4-mongoid/config/initializers/assets.rb +11 -0
  62. data/test/apps/rails4-mongoid/config/initializers/backtrace_silencers.rb +7 -0
  63. data/test/apps/rails4-mongoid/config/initializers/cookies_serializer.rb +3 -0
  64. data/test/apps/rails4-mongoid/config/initializers/filter_parameter_logging.rb +4 -0
  65. data/test/apps/rails4-mongoid/config/initializers/inflections.rb +16 -0
  66. data/test/apps/rails4-mongoid/config/initializers/mime_types.rb +4 -0
  67. data/test/apps/rails4-mongoid/config/initializers/session_store.rb +3 -0
  68. data/test/apps/rails4-mongoid/config/initializers/wrap_parameters.rb +9 -0
  69. data/test/apps/rails4-mongoid/config/locales/en.yml +23 -0
  70. data/test/apps/rails4-mongoid/config/mongoid.yml +142 -0
  71. data/test/apps/rails4-mongoid/config/routes.rb +57 -0
  72. data/test/apps/rails4-mongoid/config/secrets.yml +22 -0
  73. data/test/apps/rails4-mongoid/db/seeds.rb +7 -0
  74. data/test/apps/rails4-mongoid/log/development.log +764 -0
  75. data/test/apps/rails4-mongoid/log/test.log +15736 -0
  76. data/test/apps/rails4-mongoid/public/404.html +67 -0
  77. data/test/apps/rails4-mongoid/public/422.html +67 -0
  78. data/test/apps/rails4-mongoid/public/500.html +66 -0
  79. data/test/apps/rails4-mongoid/public/favicon.ico +0 -0
  80. data/test/apps/rails4-mongoid/public/robots.txt +5 -0
  81. data/test/apps/rails4-mongoid/test/controllers/posts_controller_test.rb +51 -0
  82. data/test/apps/rails4-mongoid/test/factories/posts.rb +6 -0
  83. data/test/apps/rails4-mongoid/test/models/post_test.rb +9 -0
  84. data/test/apps/rails4-mongoid/test/searchers/posts_searcher_test.rb +119 -0
  85. data/test/apps/rails4-mongoid/test/test_helper.rb +9 -0
  86. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/-Xhj-Mbb82rk571sDsQxrdCywGX36vsenBH1RUlK-LY.cache +1 -0
  87. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/0f_MbWM7kHYaEii2fU46RtcPM1c5AvKKzZXw_HiM0CE.cache +1 -0
  88. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/2PZE0O2lwq-MOTwxKTZxLxQwY8_QyhrbRsthl3Lc4lQ.cache +0 -0
  89. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
  90. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/5dV_yE4FDckg8xSumojLvTuflbNyhpApq7LPOy-e1X0.cache +0 -0
  91. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/7efkcYvlMpIQU8kuDy1jAKDLjakVGoH6N5V-AuzuTZc.cache +0 -0
  92. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/8Zm1d9-lBPsGG_HUw8FP2OCCVucGDVhWAOGaopvOdss.cache +0 -0
  93. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/9B_fDWO-7yTtWLP7C6kgtW5LN2zlpAqr1km-1jSQx2w.cache +1 -0
  94. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/9X7nmZiJ1BxgVp80vJFjKw2uuEfdS1ik3B66O4_iWPo.cache +0 -0
  95. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/APY89OAPJx9A3D3xcCoktvEvQUs7NcWChYXnjjjPzz0.cache +0 -0
  96. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/CWMzfW8FmEfR6gB4BwariPLjTZTtLc4bCVc0r0m2VV4.cache +0 -0
  97. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/C_ZXB0e-P6-9Ty60eBWeAui5uzzA0NzDW8amqmtTk9g.cache +0 -0
  98. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Cg1VzEm4v80ed-e0X3WGAHJWYiC_ybnfBrRrIvltPXc.cache +1 -0
  99. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Cjhm36F4tzUHdc1e0Bho51N0H4HYybVTrxTmbtiqih4.cache +1 -0
  100. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/DSOLSc6A5RVSmvM415eEWAWG_AgOvZcLZOXQjsXyWQA.cache +2 -0
  101. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/EBtbhweQl74JQNkwFL3ahZH_9x44ceqa9hOT8lQ_SfM.cache +2 -0
  102. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/EQICjEOYeXNTngMqEgET0L1SuE4AVuoKyJgio4ks43A.cache +1 -0
  103. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Edyy4hZsoEraZijGtQOEBXtG2121KJUoZeUxxPjVoD8.cache +1 -0
  104. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/HfA_T6XraGo2Ny22jLyDJkU33FwcVIBOxUIXJAfTZnw.cache +1 -0
  105. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/I-oUhfEICgXeCJ30YmQbpoYtgGAJK0-Pql8kOvfHUIs.cache +1 -0
  106. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/ITBgBGR9-8E08Y63Vjo65c8DzPESTHJuYCXZp0y6k_I.cache +0 -0
  107. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/JImLmTmbMkDKlN30hse8U-u0IV8hvfdebOL3EFz71FE.cache +0 -0
  108. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Joxxq6tZo5Z61fNSWcPCGgCyehta1sNKXM0i53ziK0o.cache +2 -0
  109. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/KPHQh44WoGRX0SuVORNxUqq129kPRQ4Sfwr0MgBGTWg.cache +1 -0
  110. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/MQWJrWW-vCooFa9lpB2Z7KDIE9ilL54d5Sf_SRtQhTM.cache +1 -0
  111. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
  112. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Olyga_OJ5Sz5He_RVZLO_BraSHgGvt9BG0ORecSD4A4.cache +1 -0
  113. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/OoG10cMLeO2eGZxk483Gx75vNDQz7Id8sxVt3g26jQE.cache +0 -0
  114. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/P2sNuT6usNXi8DQFFQ2SMByy1v98zmNdwdx6wduUQDg.cache +1 -0
  115. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Pm3ENYpCrQMOJGd-d8lACN_nbGZWiivq_KyPLJoD9Xk.cache +0 -0
  116. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/PrxeUFTxE6CmNlJ4CQLxcmAQKwOGBKNCFYluKNhVPdI.cache +0 -0
  117. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/PuNKoh-EB-UU-NnPetIEhS3emExlV586tfFJnBFhaxo.cache +0 -0
  118. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/QyBzeHR44VD1fMDrJcMOaVyyn1xgHnmhPX2VL3R6EdE.cache +0 -0
  119. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/QyU_Bdj5YdiIQef2XhSDP5MQf7l3u_A81md3KFPQ2N4.cache +2 -0
  120. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/R9YbLXVmFuZvXntmUsVoP9gdFgZaoKuww_0l-ulu_Sw.cache +0 -0
  121. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/RbDvgwCB1ggHONj2Gglg9cljN_KExx-gHiSiItOFBVw.cache +1 -0
  122. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Rkd99KDYtUtVb3U566M9L4YD2Kh-Qp147dHVmyXnDhg.cache +0 -0
  123. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Sin6bEoASrNa45108CpfgF2jcifz-KpbsvvZJtqVZ68.cache +0 -0
  124. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/SuhtC6f7E2-1SXl4bkRvOKqhzFKTjPvbglVtjbjV6WQ.cache +0 -0
  125. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/WDXpPe61HDYBIqMMzcYJWujunl4HLJBvhn0OOP1yQso.cache +1 -0
  126. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Y2HHx2PygDVpbc258EY6XyZq_3ocHy5fEq-5UHSNfh0.cache +0 -0
  127. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/Zot5Dwe9yQ1wvCpegdXXjC8DUGHfH1xLxerosBjUsns.cache +0 -0
  128. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/ZwSejSAeaXOqaevCGNDw6GT4jzf6iGxiDfUGqtjYqxE.cache +0 -0
  129. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/bsYyBqujQ9Bb_NkqKjx8J9lC8MPb-Ed59b__aV46Bic.cache +1 -0
  130. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/cnfLEWE92uT-WDII157E3Z5XISKK99q6__D2IiTRhOM.cache +0 -0
  131. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/cnk28xBZ2NhIHyeh4bImJu1D8MsQZksGaVeYZSDL-Mw.cache +0 -0
  132. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/cyuaVF0ZckKku_VGsQYOntnl3oNlSP381WW5VhCMbE4.cache +1 -0
  133. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/ee9ZqYM3D8GORlAyhQhVVtyNcEArBAXuuAcPhnfTNT8.cache +5 -0
  134. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/fQe7NSWabAv2wB6jtw0Tjp5CT06xwpla822ipJiUCy0.cache +1 -0
  135. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/fme939QD_yb-kVcNE40VAdyOZYRTHgZCxYLVDZLuzF0.cache +1 -0
  136. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/gl7MP7d46hviHXVnGFYORtcWessT58E75rSQUFjfiII.cache +0 -0
  137. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/hHOboG408ksat1oQaCWVNxzf-FIyTREQFXHdFZurlZQ.cache +1 -0
  138. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/i5GV8tvuWRKqi-plBB0bdaAqfdW_CpIMlk_3qZYyask.cache +1 -0
  139. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/ioEvK0rblqqEotrMItm0VrKhWOXnC3vwC-CIU9UCZEg.cache +1 -0
  140. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/ivzms341pOxkVrOTXM3Yog9cLwq3SmsXcwGMbRGmM6s.cache +1 -0
  141. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/j0l28m8jfc6vnBWrkD0zWt2ELCJfEOMeEjW0Q4GADNY.cache +0 -0
  142. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/jPuyl--LQd6DGNNoxSkPhBGx_ul_1kfka93EDJmnc8c.cache +1 -0
  143. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/jaYo3RHF_E7SipTqBJcsnR0JcOOa0rFpEHmp3nLDrQI.cache +1 -0
  144. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/kSkCWaAJCcTgZ_AhrRCjZhNtkE12cubiq70uNtditqk.cache +0 -0
  145. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/mXFXPQpdpe6VdLyG_ATkrFvhK-DzKohwq6B2GOQo9R8.cache +0 -0
  146. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/q2eC-e4sz4yzY37JZQfdjar0jjp4v7rHuGin5JEKV7Q.cache +1 -0
  147. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/s6DK-YkFoxYJMKXt21m9PdMtZi3TJhRoHIi0R5i69Zs.cache +1 -0
  148. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/sLDAakEn7_JrPiyZe0ZUsCLDnaTAal-5HajraaAgdhE.cache +2 -0
  149. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/teXpzhiur3Mnn2KsTY8q4HhEqpbdmKBfBW2iS5-MvUI.cache +1 -0
  150. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/tgZjQMFX0Ebx2i8ovlwnvwULhvrhFNJLAIQjUNZN1RM.cache +0 -0
  151. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/tihMlIo90U72qN2BzGajipIJOWppg8OIJuVnnluwVJM.cache +1 -0
  152. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/vpD8YcdUFmWVggV1ANqLIWcTbMItiGv1aOUd3i_Sf_w.cache +1 -0
  153. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/wBoZhq66JcV9m6-FvOoZ-Q3Cy9mgT-ynjPWZWZdafLw.cache +0 -0
  154. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/wTWJ6pQBopl4RdCt1QzngFCI6BQsl97QiZJO8bkGZd4.cache +1 -0
  155. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/wjVbFqqSw39d-ryprJ1NYmKProunHG47jEI6RFHcLM4.cache +0 -0
  156. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/wm5Vu6DEN0ZExnKV0oAADsKfEn3yvO4aBQJwp6b8FbU.cache +1 -0
  157. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/x0qPZqkeQj_x2GoHegxhwuHhPMrz8iHGdALgbSEtYB0.cache +1 -0
  158. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/xESXQaQoarUInNLmS7yPvF7D9FlSfaR8n8CsT6vIfmU.cache +1 -0
  159. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/xJpeFclkEQS028sCHKPl9C6EyiAcTgUW_lBAqjRuP_c.cache +0 -0
  160. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/yinyMcV6eKC4p76ZeetFBkRq8qYD5b8fWOHbukaCUNk.cache +1 -0
  161. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/ytg8J2fjBhc978nkpdl0f5cBPdcKpig523h4O4eN664.cache +1 -0
  162. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/z5Cl2oKorg00CGt089PLdPdoE1ELvsz4CdtXnlUk7KM.cache +0 -0
  163. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/z6uhOy1uoRnC6c9iKrzc1vRqGH1KQrhArDe51rZL1_k.cache +1 -0
  164. data/test/apps/rails4-mongoid/tmp/cache/assets/sprockets/v3.0/zIFdfoc8nFjrQhTXHyamSnNA6CVVrOcsP4qfDQhOcVI.cache +1 -0
  165. data/test/run-test.rb +43 -0
  166. data/test/unit/run-test.rb +25 -0
  167. data/test/unit/searcher/select/filter_parameter_test.rb +99 -0
  168. data/test/unit/searcher/select/match_columns_parameter_test.rb +59 -0
  169. data/test/unit/searcher/select/output_columns_parameter_test.rb +68 -0
  170. data/test/unit/searcher/select/sortby_parameter_test.rb +63 -0
  171. data/test/unit/test_helper.rb +19 -0
  172. metadata +480 -0
data/doc/text/news.md ADDED
@@ -0,0 +1,5 @@
1
+ # NEWS
2
+
3
+ ## 0.9.0 - 2016-03-28
4
+
5
+ Initial release!!!
@@ -0,0 +1,52 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ clean_white_space = lambda do |entry|
18
+ entry.gsub(/(\A\n+|\n+\z)/, "") + "\n"
19
+ end
20
+
21
+ $LOAD_PATH.unshift(File.join(__dir__, "lib"))
22
+ require "groonga/client/rails/version"
23
+
24
+ Gem::Specification.new do |spec|
25
+ spec.name = "groonga-client-rails"
26
+ spec.version = Groonga::Client::Rails::VERSION
27
+ spec.homepage = "https://github.com/ranguba/groonga-client-rails"
28
+ spec.authors = ["Kouhei Sutou"]
29
+ spec.email = ["kou@clear-code.com"]
30
+
31
+ readme = File.read("README.md", :encoding => "UTF-8")
32
+ entries = readme.split(/^\#\#\s(.*)$/)
33
+ clean_white_space.call(entries[entries.index("Description") + 1])
34
+ description = clean_white_space.call(entries[entries.index("Description") + 1])
35
+ spec.summary, spec.description, = description.split(/\n\n+/, 3)
36
+ spec.license = "LGPLv2.1+"
37
+ spec.files = ["README.md", "Rakefile", "Gemfile", "#{spec.name}.gemspec"]
38
+ spec.files += [".yardopts"]
39
+ spec.files += Dir.glob("lib/**/*.rb")
40
+ spec.files += Dir.glob("doc/text/*")
41
+ spec.test_files += Dir.glob("test/**/*")
42
+
43
+ spec.add_runtime_dependency("groonga-client", ">= 0.2.4")
44
+ spec.add_runtime_dependency("rails")
45
+
46
+ spec.add_development_dependency("bundler")
47
+ spec.add_development_dependency("rake")
48
+ spec.add_development_dependency("test-unit")
49
+ spec.add_development_dependency("test-unit-rr")
50
+ spec.add_development_dependency("packnga")
51
+ spec.add_development_dependency("kramdown")
52
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "groonga/client/rails/version"
18
+
19
+ require "groonga/client/searcher"
20
+
21
+ if defined?(Rails)
22
+ require "groonga/client/railtie"
23
+ end
@@ -0,0 +1,35 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "groonga/client/rails/groonga_server_runner"
18
+
19
+ module Groonga
20
+ class Client
21
+ module Rails
22
+ module Fixture
23
+ def setup_groonga
24
+ @groonga_server_runner = GroongaServerRunner.new
25
+ @groonga_server_runner.run
26
+ end
27
+
28
+ def teardown_groonga
29
+ return if @groonga_server_runner.nil?
30
+ @groonga_server_runner.stop
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,164 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "rbconfig"
18
+ require "fileutils"
19
+
20
+ module Groonga
21
+ class Client
22
+ module Rails
23
+ class GroongaServerRunner
24
+ def initialize
25
+ @pid = nil
26
+ @using_running_server = false
27
+ @url = build_url
28
+ @groonga = find_groonga
29
+ @tmp_dir = nil
30
+ end
31
+
32
+ def run
33
+ if groonga_server_running?
34
+ @using_running_server = true
35
+ else
36
+ return if @groonga.nil?
37
+ @tmp_dir = create_tmp_dir
38
+ db_path = @tmp_dir + "db"
39
+ @pid = spawn(@groonga,
40
+ "--port", @url.port.to_s,
41
+ "--log-path", (@tmp_dir + "groonga.log").to_s,
42
+ "--query-log-path", (@tmp_dir + "query.log").to_s,
43
+ "--protocol", "http",
44
+ "-s",
45
+ "-n", db_path.to_s)
46
+ wait_groonga_ready
47
+ end
48
+ sync_schema
49
+ end
50
+
51
+ def stop
52
+ if @using_running_server
53
+ Groonga::Client.open do |client|
54
+ schema = client.schema
55
+ schema.tables.each do |name, _|
56
+ client.delete(table: name,
57
+ filter: "true")
58
+ end
59
+ end
60
+ else
61
+ if @pid
62
+ Groonga::Client.open do |client|
63
+ client.shutdown
64
+ end
65
+ wait_groonga_shutdown
66
+ end
67
+ if @tmp_dir
68
+ FileUtils.rm_rf(@tmp_dir)
69
+ end
70
+ end
71
+ end
72
+
73
+ private
74
+ def build_url
75
+ default_options = Groonga::Client.default_options
76
+ url = default_options[:url]
77
+ if url.nil?
78
+ host = default_options[:host] || default_options[:address]
79
+ port = default_options[:port] || 10041
80
+ path = default_options[:path]
81
+ url = URI("http://#{host}:#{port}#{path}")
82
+ end
83
+ url
84
+ end
85
+
86
+ def groonga_server_running?
87
+ begin
88
+ TCPSocket.open(@url.host, @url.port) do
89
+ end
90
+ rescue SystemCallError
91
+ false
92
+ else
93
+ true
94
+ end
95
+ end
96
+
97
+ def sync_schema
98
+ ::Rails.application.eager_load!
99
+ ObjectSpace.each_object(Class) do |klass|
100
+ klass.sync_schema if klass < Searcher
101
+ end
102
+ end
103
+
104
+ def find_groonga
105
+ paths = ENV["PATH"].split(File::PATH_SEPARATOR)
106
+ exeext = RbConfig::CONFIG["EXEEXT"]
107
+ paths.each do |path|
108
+ groonga = File.join(path, "groonga#{exeext}")
109
+ return groonga if File.executable?(groonga)
110
+ end
111
+ nil
112
+ end
113
+
114
+ def create_tmp_dir
115
+ tmpfs_dir = "/dev/shm"
116
+ if File.directory?(tmpfs_dir)
117
+ base_tmp_dir = Pathname(tmpfs_dir)
118
+ else
119
+ base_tmp_dir = ::Rails.root + "tmp"
120
+ end
121
+ tmp_dir = base_tmp_dir + "groonga-client-rails.#{Process.pid}"
122
+ FileUtils.rm_rf(tmp_dir)
123
+ FileUtils.mkdir_p(tmp_dir)
124
+ tmp_dir
125
+ end
126
+
127
+ def wait_groonga_ready
128
+ n_retried = 0
129
+ while n_retried <= 20
130
+ n_retried += 1
131
+ sleep(0.05)
132
+ if groonga_server_running?
133
+ break
134
+ else
135
+ begin
136
+ pid = Process.waitpid(@pid, Process::WNOHANG)
137
+ rescue SystemCallError
138
+ @pid = nil
139
+ break
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ def wait_groonga_shutdown
146
+ # TODO: Remove me when Groonga 6.0.1 has been released.
147
+ # Workaround to shutdown as soon as possible.
148
+ groonga_server_running?
149
+
150
+ n_retried = 0
151
+ while n_retried <= 20
152
+ n_retried += 1
153
+ sleep(0.05)
154
+ pid = Process.waitpid(@pid, Process::WNOHANG)
155
+ return if pid
156
+ end
157
+
158
+ Process.kill(:KILL, @pid)
159
+ Process.waitpid(@pid)
160
+ end
161
+ end
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,39 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "groonga/client/rails/fixture"
18
+
19
+ module Groonga
20
+ class Client
21
+ module Rails
22
+ module SpecHelper
23
+ include Fixture
24
+
25
+ extend ActiveSupport::Concern
26
+
27
+ included do
28
+ before(:each) do
29
+ setup_groonga
30
+ end
31
+
32
+ after(:each) do
33
+ teardown_groonga
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "groonga/client/rails/fixture"
18
+
19
+ module Groonga
20
+ class Client
21
+ module Rails
22
+ module TestHelper
23
+ include Fixture
24
+
25
+ extend ActiveSupport::Concern
26
+
27
+ included do
28
+ setup do
29
+ setup_groonga
30
+ end
31
+
32
+ teardown do
33
+ teardown_groonga
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,23 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ module Groonga
18
+ class Client
19
+ module Rails
20
+ VERSION = "0.9.0"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,70 @@
1
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License as published by the Free Software Foundation; either
6
+ # version 2.1 of the License, or (at your option) any later version.
7
+ #
8
+ # This library is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
+ # Lesser General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU Lesser General Public
14
+ # License along with this library; if not, write to the Free Software
15
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
+
17
+ require "groonga/client"
18
+
19
+ module Groonga
20
+ class Client
21
+ # @private
22
+ class Railtie < ::Rails::Railtie
23
+ rake_tasks do
24
+ load "groonga/client/railties/groonga.rake"
25
+ end
26
+
27
+ initializer "groonga-client.eager_load" do |app|
28
+ app.paths.add("app/searchers",
29
+ eager_load: true,
30
+ glob: "**/*_searcher.rb")
31
+ end
32
+
33
+ initializer "groonga-client.configure" do |app|
34
+ config_name = :groonga_client
35
+ config_path = Pathname(app.paths["config"].existent.first)
36
+ yaml_path = config_path + "#{config_name}.yml"
37
+ unless yaml_path.exist?
38
+ yaml_path.open("w") do |yaml|
39
+ yaml.puts(<<-YAML)
40
+ default: &default
41
+ protocol: http
42
+ # protocol: https
43
+ host: 127.0.0.1
44
+ port: 10041
45
+ # user: alice
46
+ # password: secret
47
+ read_timeout: -1
48
+ # read_timeout: 3
49
+ backend: synchronous
50
+
51
+ development:
52
+ <<: *default
53
+
54
+ test:
55
+ <<: *default
56
+ port: 20041
57
+
58
+ production:
59
+ <<: *default
60
+ host: 127.0.0.1
61
+ read_timeout: 10
62
+ YAML
63
+ end
64
+ end
65
+ Groonga::Client.default_options =
66
+ app.config_for(:groonga_client).deep_symbolize_keys
67
+ end
68
+ end
69
+ end
70
+ end