[Groonga-commit] ranguba/groonga-client-model at b6892e8 [master] Support loading schema

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Dec 6 17:51:19 JST 2016


Kouhei Sutou	2016-12-06 17:51:19 +0900 (Tue, 06 Dec 2016)

  New Revision: b6892e8caaefe89d45c41972f4c5fa7883d009fa
  https://github.com/ranguba/groonga-client-model/commit/b6892e8caaefe89d45c41972f4c5fa7883d009fa

  Message:
    Support loading schema

  Added files:
    lib/groonga_client_model/railties/groonga.rake
  Modified files:
    .travis.yml
    groonga-client-model.gemspec
    lib/groonga_client_model/railtie.rb
    test/apps/rails5/Gemfile.lock

  Modified: .travis.yml (+1 -1)
===================================================================
--- .travis.yml    2016-12-06 17:25:02 +0900 (e4a6b4f)
+++ .travis.yml    2016-12-06 17:51:19 +0900 (5c78afc)
@@ -23,5 +23,5 @@ script:
     for test_app in ${PWD}/test/apps/*
     do
       (cd ${test_app} && \
-        BUNDLE_GEMFILE=${PWD}/Gemfile bin/rails test)
+        BUNDLE_GEMFILE=${PWD}/Gemfile bin/rails groonga:schema:load test)
     done

  Modified: groonga-client-model.gemspec (+1 -0)
===================================================================
--- groonga-client-model.gemspec    2016-12-06 17:25:02 +0900 (187f82b)
+++ groonga-client-model.gemspec    2016-12-06 17:51:19 +0900 (08336f3)
@@ -44,6 +44,7 @@ Gem::Specification.new do |spec|
   spec.test_files += Dir.glob("test/**/*")
 
   spec.add_runtime_dependency("groonga-client", ">= 0.3.2")
+  spec.add_runtime_dependency("groonga-command-parser")
   spec.add_runtime_dependency("activemodel")
 
   spec.add_development_dependency("bundler")

  Modified: lib/groonga_client_model/railtie.rb (+4 -0)
===================================================================
--- lib/groonga_client_model/railtie.rb    2016-12-06 17:25:02 +0900 (d6c2e8f)
+++ lib/groonga_client_model/railtie.rb    2016-12-06 17:51:19 +0900 (876c4a9)
@@ -34,6 +34,10 @@ module GroongaClientModel
 
     config.eager_load_namespaces << GroongaClientModel
 
+    rake_tasks do
+      load "groonga_client_model/railties/groonga.rake"
+    end
+
     initializer "groonga_client_model.logger" do
       ActiveSupport.on_load(:groonga_client_model) do
         self.logger ||= Rails.logger

  Added: lib/groonga_client_model/railties/groonga.rake (+49 -0) 100644
===================================================================
--- /dev/null
+++ lib/groonga_client_model/railties/groonga.rake    2016-12-06 17:51:19 +0900 (dfe8c0c)
@@ -0,0 +1,49 @@
+# -*- ruby -*-
+#
+# Copyright (C) 2016  Kouhei Sutou <kou �� clear-code.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+namespace :groonga do
+  namespace :config do
+    desc "Load config/groonga.rb"
+    task load: [:environment] do
+      config = Rails.application.config_for(:groonga)
+      GroongaClientModel::Client.url = config["url"]
+    end
+  end
+
+  namespace :schema do
+    desc "Loads config/schema.grn info Groonga"
+    task load: ["config:load"] do
+      require "groonga/command/parser"
+
+      schema_path = Rails.root + "db/schema.grn"
+      GroongaClientModel::Client.open do |client|
+        parser = Groonga::Command::Parser.new
+        parser.on_command do |command|
+          client.execute(command)
+        end
+
+        schema_path.open do |schema_file|
+          schema_file.each_line do |line|
+            parser << line
+          end
+        end
+        parser.finish
+      end
+    end
+  end
+end

  Modified: test/apps/rails5/Gemfile.lock (+8 -0)
===================================================================
--- test/apps/rails5/Gemfile.lock    2016-12-06 17:25:02 +0900 (0166670)
+++ test/apps/rails5/Gemfile.lock    2016-12-06 17:51:19 +0900 (9bd18a6)
@@ -4,6 +4,7 @@ PATH
     groonga-client-model (0.9.0)
       activemodel
       groonga-client (>= 0.3.2)
+      groonga-command-parser
 
 GEM
   remote: https://rubygems.org/
@@ -65,6 +66,8 @@ GEM
       factory_girl (~> 4.5.0)
       railties (>= 3.0.0)
     ffi (1.9.14)
+    ffi-yajl (2.3.0)
+      libyajl2 (~> 1.2)
     globalid (0.3.7)
       activesupport (>= 4.1.0)
     gqtp (1.0.6)
@@ -74,6 +77,10 @@ GEM
       hashie
     groonga-command (1.2.9)
       json
+    groonga-command-parser (1.0.5)
+      ffi
+      ffi-yajl
+      groonga-command (>= 1.0.9)
     hashie (3.4.6)
     i18n (0.7.0)
     jbuilder (2.6.1)
@@ -84,6 +91,7 @@ GEM
       railties (>= 4.2.0)
       thor (>= 0.14, < 2.0)
     json (2.0.2)
+    libyajl2 (1.2.0)
     listen (3.0.8)
       rb-fsevent (~> 0.9, >= 0.9.4)
       rb-inotify (~> 0.9, >= 0.9.7)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index