[Groonga-commit] groonga/groonga-test [master] Introduce context object

Back to archive index

null+****@clear***** null+****@clear*****
2012年 3月 5日 (月) 17:52:18 JST


Kouhei Sutou	2012-03-05 17:52:18 +0900 (Mon, 05 Mar 2012)

  New Revision: 220407adafb3f28a189dd87312eb7d7c7f124099

  Log:
    Introduce context object

  Modified files:
    bin/groonga-test

  Modified: bin/groonga-test (+16 -9)
===================================================================
--- bin/groonga-test    2012-03-05 17:43:49 +0900 (d2889c4)
+++ bin/groonga-test    2012-03-05 17:52:18 +0900 (0b47edb)
@@ -171,12 +171,19 @@ class GroongaTester
   end
 
   class Executer
-    def initialize(groonga, result=[])
+    class Context
+      attr_accessor :logging, :result
+      def initialize
+        @logging = true
+        @result = []
+      end
+    end
+
+    def initialize(groonga, context=nil)
       @groonga = groonga
-      @logging = true
       @loading = false
       @pending_command = ""
-      @result = result
+      @context = context || Context.new
     end
 
     def execute(script_path)
@@ -190,7 +197,7 @@ class GroongaTester
         end
       end
 
-      @result
+      @context.result
     end
 
     private
@@ -236,9 +243,9 @@ class GroongaTester
     def execute_comment(content)
       case content.strip
       when "disable-logging"
-        @logging = false
+        @context.logging = false
       when "enable-logging"
-        @logging = true
+        @context.logging = true
       when /\Ainclude\s+/
         path = $POSTMATCH.strip
         return if path.empty?
@@ -247,7 +254,7 @@ class GroongaTester
     end
 
     def execute_script(path)
-      executer = self.class.new(@groonga, @result)
+      executer = self.class.new(@groonga, @context)
       executer.execute(Pathname(path))
     end
 
@@ -278,9 +285,9 @@ class GroongaTester
     end
 
     def log(tag, content)
-      return unless @logging
+      return unles****@conte*****
       return if content.empty?
-      @result << [tag, content]
+      @context.result << [tag, content]
     end
 
     def log_input(content)




Groonga-commit メーリングリストの案内
Back to archive index