Browse files

Added link to documentation

  • Loading branch information...
1 parent 4f3d1fa commit 5895bb99f6c7836c3d506999291b83bc3088e60e @jayniz jayniz committed Jan 23, 2012
Showing with 21 additions and 14 deletions.
  1. +21 −14 README.markdown
View
35 README.markdown
@@ -9,48 +9,48 @@ Jogger does two things:
1. Keep the current pacer traversal in an instance variable and allow for method chaining as well as changing the internal state of the traversal
2. Allows you to group together parts of a traversal (single pipes or groups of them) and give them a name. Named traversals. Helps to stay DRY.
-The former is really just a syntax thing, whereas the latter can help you a great deal modeling semantics of your business logic as parts of traversals. These sentences confuse me, so I will give you examples.
+The former is really just a syntax thing, whereas the latter can help you a great deal modeling semantics of your business logic as parts of traversals. These sentences confuse me, so I will give you:
# Example time!
-## 1. Keep track of the current traversal
+## 1. Keep the current traversal
To demonstrate why point 1) in the list above can be useful, look at this traversal. It helps me find out what movies my female friends like the most, so I can impress them in a conversation:
t = my_pacer_vertex.in(:friends)
- t = t.filter{ |v| v.properties['gender'] == 'female}
+ t = t.filter{|v| v.properties['gender'] == 'female}
t = t.out(:likes)
t = t.filter{ |v| v.properties['type'] == 'Movie' }
- t = t.group_count{ |v| v }
t = t.sort_by{ |v, c| -c }
+ t = t.group_count{ |v| v }
Since I'm a very lazy person, I would prefer to write it a little shorter. Especially, since these multi step traversals are a pattern I found in our code at [moviepilot.com](http://moviepilot.com)) a lot.
-So here's the Jogger way of expressing the same traversal:
+So here's the Jogger way of expressing this:
t = Jogger.new(my_pacer_vertex)
t.in(:friends)
t.filter{ |v| v.properties['gender'] == 'female' }
t.out(:likes)
t.filter{ |v| v.properties['type'] == 'Movie' }
- t.group_count{ |v| v }
t.sort_by{ |v, c| -c }
+ t.group_count{ |v| v }
See what I did there? Jogger keeps the current pacer traversal and forwards all method calls to that traversal, and then returns itself. So you could also write (in jogger as well as pacer):
Jogger.new(my_pacer_node).in(:friends).filter{ … }.out(:likes).group_count{…}
-Just saying, you can chain your methods, but I don't like it because I can only focus on 72 characters per line at max. If you want to access the current traversal, just call `result` on your Jogger instance.
+Just saying, you can chain your methods, but I don't like it cause I can only focus on 72 characters per line at max. If you want the current traversal, just call `result` on your Jogger instance.
## 2. Named traversals
-So that traversal above, traversing from a node to all its friends, is pretty simple, but it could be simpler. Especially if it does things that you want to reuse in many other places. If you would explain the traveral to somebody, you'd say something along the lines of "The most popular movies amongst my friends, but only girls". How cool would it be if I just had to write this:
+So that traversal above, traversing from a node to all its friends, is pretty simple, but it could be simpler. Especially if it does things that you want to reuse in many other places. How cool would it be if I just had to write this:
t = Jogger.new(my_pacer_vertex)
t.friends(:female)
t.top_list(:movies)
-No problem. Just define a few named traversals that do exactly this.
+No problem. Just define a named traversal that does it.
class Jogger
module NamedTraversals
@@ -60,13 +60,12 @@ No problem. Just define a few named traversals that do exactly this.
t = current_traversal.in(:friends)
t = t.filter{|v| v.properties['gender'] == gender}
end
-
+
# Group and sort
def self.top_list(current_traversal, type)
t = current_traversal.out(type)
t = t.filter{ |v| v.properties['type'] == 'Movie' }
t = t.group_count{ |v| v }
- t = t.sort_by{ |v, c| -c }
end
end
end
@@ -75,16 +74,24 @@ These are silly examples, but if you look at your traversals I guarantee that yo
# Installation
-First, you need to load pacer and whatever graph db connector you need (we use pacer-neo4j, by the way) and define your named traversals as above. Jogger doesn't include these on purpose. Then, you have to:
+First, you need to load pacer and whatever graph db connector you need (we use neo4j, by the way) and define your named traversals as above. Jogger doesn't include these on purpose. Then, you have to
gem install pacer-jogger
-and
+and
require 'jogger'
-or if you're using bundler, add this to your Gemfile and bundle:
+or for your Gemfile
gem "pacer-jogger", :require => "jogger"
That's it!
+
+# Documentation
+
+I gave YARD a shot, so to open the documentation in your browser just do this in the jogger directory:
+
+ yard server & sleep 3 && open http://localhost:8808/docs/file/README.markdown
+
+Or you can (browse the documentation online)[http://rubydoc.info/github/jayniz/jogger/master/frames]

0 comments on commit 5895bb9

Please sign in to comment.