Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 16, 2012
@pangloss pangloss Add route description method -- inspect without trying to execute the…
… route.
f954cfa
@pangloss pangloss spelling 9196ae2
@pangloss pangloss Support backticks in where statement for quoting property names.
Adds support for statements like:

```ruby
g.v.where('`a long property name` == "something"')
```
4e43dd0
View
8 lib/pacer/core/route.rb
@@ -133,6 +133,10 @@ def pipe
iterator
end
+ def description(join = ' -> ')
+ "#<#{inspect_strings.join(join)}>"
+ end
+
# Returns a string representation of the route definition. If there are
# less than Graph#inspect_limit matches, it will also output all matching
# elements formatted in columns up to a maximum character width of
@@ -142,7 +146,7 @@ def pipe
# @return [String]
def inspect(limit = nil)
if Pacer.hide_route_elements or hide_elements or source_iterator.nil?
- "#<#{inspect_strings.join(' -> ')}>"
+ description
else
Pacer.hide_route_elements do
count = 0
@@ -169,7 +173,7 @@ def inspect(limit = nil)
end
end
puts "Total: #{ count }"
- "#<#{inspect_strings.join(' -> ')}>"
+ description
end
end
end
View
40 lib/pacer/filter/where_filter/node_visitor.rb
@@ -34,11 +34,11 @@ class NodeVisitor
'>=' => FilterPipe::Filter::LESS_THAN_EQUAL
)
- COMPARITORS = %w[ == != > < >= <= ]
+ COMPARATORS = %w[ == != > < >= <= ]
METHODS = %w[ + - * / % ]
- REGEX_COMPARITORS = %w[ =~ !~ ]
+ REGEX_COMPARATORS = %w[ =~ !~ ]
- VALID_OPERATIONS = COMPARITORS + METHODS # + REGEX_COMPARITORS
+ VALID_OPERATIONS = COMPARATORS + METHODS # + REGEX_COMPARATORS
class Pipe
def initialize(pipe, *args)
@@ -118,7 +118,7 @@ def build_comparison(a, b, name)
# TODO: support regex matches
raise "Operation not supported: #{ name }" unless VALID_OPERATIONS.include? name
- if COMPARITORS.include? name
+ if COMPARATORS.include? name
if a.is_a? Value and b.is_a? Value
if a.value.send name, b.value
Pipe.new IdentityPipe
@@ -139,7 +139,7 @@ def build_comparison(a, b, name)
Pipe.new CrossProductTransformPipe, name, a, b
end
end
- end
+ end
def negate(pipe)
Pipe.new(Pipeline, pipe, Pipe.new(HasCountPipe, -1, 0), Pipe.new(ObjectFilterPipe, true, Filters['==']))
@@ -166,11 +166,11 @@ def visitAndNode(node)
else
Pipe.new AndFilterPipe, a, b
end
- end
+ end
def visitArrayNode(node)
Value.new Value.new(node.child_nodes.map { |n| n.accept self }).values!
- end
+ end
def visitBignumNode(node)
Value.new node.value.to_s
@@ -205,11 +205,11 @@ def visitCallNode(node)
def visitFalseNode(node)
Pipe.new NeverPipe
- end
+ end
def visitFixnumNode(node)
Value.new node.value
- end
+ end
def visitFloatNode(node)
Value.new node.value
@@ -223,7 +223,7 @@ def visitLocalAsgnNode(node)
a = Pipe.new PropertyPipe, node.name
b = node.value_node.accept(self)
build_comparison(a, b, '==')
- end
+ end
def visitLocalVarNode(node)
Pipe.new PropertyPipe, node.name
@@ -231,11 +231,11 @@ def visitLocalVarNode(node)
def visitNewlineNode(node)
node.next_node.accept(self)
- end
+ end
def visitNilNode(node)
Value.new nil
- end
+ end
def visitOrNode(node)
a = comparable_pipe node.first_node.accept(self)
@@ -250,7 +250,7 @@ def visitOrNode(node)
else
Pipe.new OrFilterPipe, a, b
end
- end
+ end
def visitRootNode(node)
pipe = node.body_node.accept self
@@ -265,23 +265,27 @@ def visitRootNode(node)
else
Pipe.new AndFilterPipe, comparable_pipe(pipe)
end
- end
+ end
def visitStrNode(node)
Value.new node.value
- end
+ end
def visitSymbolNode(node)
Value.new values.fetch(node.name.to_sym, node.name.to_sym)
- end
+ end
def visitTrueNode(node)
Pipe.new IdentityPipe
- end
+ end
def visitVCallNode(node)
Pipe.new PropertyPipe, node.name
- end
+ end
+
+ def visitXStrNode(node)
+ Pipe.new PropertyPipe, node.value
+ end
def visitYieldNode(node)
block = node.args_node.child_nodes.first.accept(self)

No commit comments for this range

Something went wrong with that request. Please try again.