tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ok...@apache.org
Subject [4/7] tinkerpop git commit: made things safer -- not longer wraps by step name, but by character. much cleaner.
Date Tue, 28 Jun 2016 01:37:37 GMT
made things safer -- not longer wraps by step name, but by character. much cleaner.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/090efe3b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/090efe3b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/090efe3b

Branch: refs/heads/TINKERPOP-1278
Commit: 090efe3be4b40e90dba4731d8233b5dd62c08204
Parents: 21a533d
Author: Marko A. Rodriguez <okrammarko@gmail.com>
Authored: Tue Jun 21 16:44:19 2016 -0600
Committer: Marko A. Rodriguez <okrammarko@gmail.com>
Committed: Tue Jun 21 16:44:19 2016 -0600

----------------------------------------------------------------------
 .../tinkerpop/gremlin/console/Console.groovy    |  6 ++---
 .../traversal/util/TraversalExplanation.java    | 23 +++++++++-----------
 .../util/TraversalExplanationTest.java          | 16 +++++++++-----
 3 files changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/090efe3b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
index 3d748eb..8dcb272 100644
--- a/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
+++ b/gremlin-console/src/main/groovy/org/apache/tinkerpop/gremlin/console/Console.groovy
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.console
 
 import jline.TerminalFactory
+import jline.console.history.FileHistory
 import org.apache.commons.cli.Option
 import org.apache.tinkerpop.gremlin.console.commands.GremlinSetCommand
 import org.apache.tinkerpop.gremlin.console.commands.InstallCommand
@@ -29,7 +30,6 @@ import org.apache.tinkerpop.gremlin.console.commands.UninstallCommand
 import org.apache.tinkerpop.gremlin.console.plugin.PluggedIn
 import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader
 import org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin
-import jline.console.history.FileHistory
 import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalExplanation
 import org.apache.tinkerpop.gremlin.util.Gremlin
 import org.apache.tinkerpop.gremlin.util.iterator.ArrayIterator
@@ -252,8 +252,8 @@ class Console {
                             return null
                         }
                     } else if (result instanceof TraversalExplanation) {
-                        final int width = TerminalFactory.get().getWidth() - 25
-                        io.out.println(buildResultPrompt() + result.prettyPrint(width <
10 ? 100 : width))
+                        final int width = TerminalFactory.get().getWidth();
+                        io.out.println(buildResultPrompt() + result.prettyPrint(width <
20 ? 80 : width))
                         return null
                     } else {
                         io.out.println(buildResultPrompt() + ((null == result) ? NULL : result.toString()))

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/090efe3b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
index 2baccdb..6e3692a 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanation.java
@@ -156,26 +156,23 @@ public class TraversalExplanation implements Serializable {
 
         StringBuilder builder = new StringBuilder();
         int counter = 0;
-        for (final String shortString : longString.split(", ")) {
-            if (0 == counter)
-                builder.append(shortString).append(", ");
-            else if (counter < maxLengthPerLine)
-                builder.append(shortString).append(", ");
-            else {
-                builder.deleteCharAt(builder.length() - 1); // remove the " "
+        for (int i = 0; i < longString.length(); i++) {
+            if (0 == counter) {
+                builder.append(longString.charAt(i));
+            } else if (counter < maxLengthPerLine) {
+                builder.append(longString.charAt(i));
+            } else {
                 builder.append("\n");
-                for (int i = 0; i < newLineIndent; i++) {
+                for (int j = 0; j < newLineIndent; j++) {
                     builder.append(" ");
                 }
-                builder.append(shortString).append(", ");
+                builder.append(longString.charAt(i));
                 counter = 0;
             }
-            counter = counter + shortString.length();
+            counter++;
         }
 
-        return builder
-                .delete(builder.length() - 2, builder.length()) // remove the final ", "
-                .toString();
+        return builder.toString();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/090efe3b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
index 3350a87..3040fe8 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalExplanationTest.java
@@ -55,7 +55,7 @@ public class TraversalExplanationTest {
         ///
         traversal = __.V().out().out().out().out();
         toString = traversal.explain().prettyPrint();
-        assertTrue(toString.contains("VertexStep(OUT,vertex),\n"));
+        assertTrue(toString.contains("VertexStep(OUT,vertex),"));
         //System.out.println(toString);
         ///
         for (int i = 0; i < 30; i++) {
@@ -68,15 +68,20 @@ public class TraversalExplanationTest {
             if (i < 3)
                 assertFalse(toString.contains("VertexStep(OUT,vertex),\n"));
             else {
-                assertFalse(Stream.of(toString.split("\n"))
+                assertTrue(Stream.of(toString.split("\n"))
                         .filter(s -> s.startsWith(" "))
                         .map(String::trim)
                         .filter(s -> Character.isLowerCase(s.charAt(0)))
                         .findAny()
                         .isPresent()); // all indented word wraps should start with steps
-                assertTrue(toString.contains("VertexStep(OUT,vertex),\n"));
+                assertTrue(toString.contains("vertex"));
             }
-            //System.out.println(toString);
+            for (int j = 80; j < 200; j++) {
+                for (final String line : traversal.explain().prettyPrint(j).split("\n"))
{
+                    assertTrue(line.length() <= j);
+                }
+            }
+            // System.out.println(toString);
         }
     }
 
@@ -118,8 +123,7 @@ public class TraversalExplanationTest {
         assertEquals(4, found);
         //
         found = 0;
-        for (final String line : traversal.explain().prettyPrint().split("]\n")) { // need
to split cause of word wrap
-            //System.out.println(line + "\n\n");
+        for (final String line : traversal.explain().prettyPrint(158).split("]\n")) { //
need to split cause of word wrap
             if (line.contains("IncidentToAdjacentStrategy") && line.contains("[VertexStep(IN,vertex)"))
                 found++;
             if (line.contains("IncidentToAdjacentStrategy") && line.contains("[VertexStep(OUT,vertex)"))


Mime
View raw message