red_grape 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,25 +2,25 @@
2
2
 
3
3
  * https://github.com/technohippy/red-grape
4
4
 
5
- ## DESCRIPTION:
5
+ ## Description:
6
6
 
7
- RedGrape is an in-memory graph database written in ruby. I made this in order to learn how graph databases work so that please do not use this for any serious purpose.
7
+ redGrape is an in-memory graph database written in ruby. I made this in order to learn how graph databases work so that please do not use this for any serious purpose.
8
8
 
9
- ## FEATURES/PROBLEMS:
9
+ ## Features/Problems:
10
10
 
11
11
  * REPL
12
12
  * load GraphML
13
13
  * construct a graph programmatically
14
14
  * traverse nodes and edges
15
15
 
16
- ## SYNOPSIS:
16
+ ## Synopsis:
17
17
 
18
18
  g1 = RedGrape.load_graph 'data/graph-example-1.xml'
19
19
  g1.v(1).out('knows').filter{it.age < 30}.name.transform{it.size}.take
20
20
  # => [5]
21
21
 
22
22
  g2 = RedGrape.load_graph 'data/graph-example-2.xml'
23
- g2.v(89).as('x').outE.inV.loop('x'){loops < 3}.path.take
23
+ g2.v(89).as('x').outE.inV.loop('x'){it.loops < 3}.path.take
24
24
  # => [[v[89], e[7006][89-followed_by->127], v[127], e[7786][127-sung_by->340], v[340]], [v[89],
25
25
 
26
26
  ## REPL:
@@ -63,9 +63,9 @@ RedGrape is an in-memory graph database written in ruby. I made this in order to
63
63
 
64
64
  In REPL, the `take' method which invokes all pipes is automatically called.
65
65
 
66
- ## CLIENT/SERVER:
66
+ ## Server/Client:
67
67
 
68
- ### SERVER:
68
+ ### Server:
69
69
 
70
70
  $ ./bin/trellis
71
71
  +=================+
@@ -76,45 +76,45 @@ In REPL, the `take' method which invokes all pipes is automatically called.
76
76
  Start server: druby://localhost:28282
77
77
  [Ctrl+C to stop]
78
78
 
79
- ### CLIENT:
79
+ ### Client:
80
80
 
81
81
  $ ./bin/redgrape
82
82
  T
83
83
  oOOOo
84
84
  oOo
85
85
  -------- O --------
86
- ruby-1.9.3-head :001 > store = RedGrape::GraphStore.open
86
+ ruby :001 > $store
87
87
  => #<RedGrape::GraphStore:0x007fb615137a90>
88
- ruby-1.9.3-head :002 > store.graphs
88
+ ruby :002 > $store.graphs
89
89
  => [:tinker]
90
- ruby-1.9.3-head :003 > g = store.graph :tinker
90
+ ruby :003 > g = $store.graph :tinker
91
91
  => redgrape[vertices:6 edges:6]
92
- ruby-1.9.3-head :004 > g.add_vertex 7
92
+ ruby :004 > g.add_vertex 7
93
93
  => redgrape[vertices:7 edges:6]
94
- ruby-1.9.3-head :005 > store.put_graph :tinker, g
94
+ ruby :005 > store.put_graph :tinker, g
95
95
  => redgrape[vertices:7 edges:6]
96
96
 
97
97
  Changes on a graph are not committed until the put_graph method called.
98
98
 
99
- ## REQUIREMENTS:
99
+ ## Requirements:
100
100
 
101
101
  * Nokogiri (http://nokogiri.org/)
102
102
 
103
- ## DEVELOPERS:
103
+ ## Developers:
104
104
 
105
- After checking out the source, run:
105
+ after checking out the source, run:
106
106
 
107
107
  $ rake newb
108
108
 
109
109
  This task will install any missing dependencies, run the tests/specs,
110
110
  and generate the RDoc.
111
111
 
112
- ## REFERENCES:
112
+ ## References:
113
113
 
114
114
  * [Gremlin](https://github.com/tinkerpop/gremlin/wiki)
115
115
  * [Pipes](https://github.com/tinkerpop/pipes/wiki/)
116
116
 
117
- ## LICENSE:
117
+ ## License:
118
118
 
119
119
  (The MIT License)
120
120
 
@@ -1,4 +1,3 @@
1
- require 'nokogiri'
2
1
  require 'red_grape/vertex'
3
2
  require 'red_grape/edge'
4
3
  require 'red_grape/property_description'
@@ -11,6 +10,7 @@ module RedGrape
11
10
  self.new.load filename
12
11
  end
13
12
 
13
+ # Returns the default graph which has 6 vertices and 6 edges.
14
14
  def create_tinker_graph
15
15
  self.new do |g|
16
16
  v1 = g.add_vertex 1, name:'marko', age:29
@@ -28,6 +28,7 @@ module RedGrape
28
28
  end
29
29
  end
30
30
 
31
+ # Returns the features as a hash
31
32
  def features
32
33
  {
33
34
  ignores_supplied_ids:false,
@@ -63,6 +64,9 @@ module RedGrape
63
64
 
64
65
  attr_accessor :serializer
65
66
 
67
+ # Returns a new instance
68
+ # _block_ :: a block which is given the instance as the first argument
69
+ # to initialize it
66
70
  def initialize(&block)
67
71
  @serializer = Serializer::GraphMLSerializer.new self
68
72
  @vertices = {}
@@ -71,7 +75,7 @@ module RedGrape
71
75
  block.call self if block
72
76
  end
73
77
 
74
- def items(type, *id)
78
+ def items(type, *id) # :nodoc:
75
79
  items = case type
76
80
  when :vertex, :vertices
77
81
  @vertices
@@ -88,6 +88,12 @@ module RedGrape
88
88
 
89
89
  def eval(args={}, &block)
90
90
  args.each {|k, v| self.send "#{k}=", v}
91
+ if @it
92
+ # so aggressive way...
93
+ def @it.loops=(l); @loops = l end
94
+ def @it.loops; @loops end
95
+ @it.loops = @loops
96
+ end
91
97
  instance_eval(&block)
92
98
  end
93
99
  end
@@ -1,3 +1,3 @@
1
1
  module RedGrape
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -59,8 +59,7 @@ class TraversalPatternsTest < Test::Unit::TestCase
59
59
  g = RedGrape.load_graph 'data/graph-example-2.xml'
60
60
  assert_equal 36, g.v(89).outE.inV.path.take.size
61
61
 
62
- #path = g.v(89).outE.inV.loop(2){it.loops < 3}.path.take #TODO: it.
63
- path = g.v(89).outE.inV.loop(2){loops < 3}.path.take.first
62
+ path = g.v(89).outE.inV.loop(2){it.loops < 3}.path.take.first
64
63
  assert_equal '[v[89], e[7006][89-followed_by->127], v[127], e[7786][127-sung_by->340], v[340]]', path.to_s
65
64
  assert_equal RedGrape::Vertex, path[0].class
66
65
  assert_equal RedGrape::Edge, path[1].class
@@ -68,7 +67,7 @@ class TraversalPatternsTest < Test::Unit::TestCase
68
67
  assert_equal RedGrape::Edge, path[3].class
69
68
  assert_equal RedGrape::Vertex, path[4].class
70
69
 
71
- path = g.v(89).as('x').outE.inV.loop('x'){loops < 3}.path.take.first
70
+ path = g.v(89).as('x').outE.inV.loop('x'){it.loops < 3}.path.take.first
72
71
  assert_equal '[v[89], e[7006][89-followed_by->127], v[127], e[7786][127-sung_by->340], v[340]]', path.to_s
73
72
  assert_equal RedGrape::Vertex, path[0].class
74
73
  assert_equal RedGrape::Edge, path[1].class
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red_grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-08 00:00:00.000000000 Z
12
+ date: 2012-06-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70107699251780 !ruby/object:Gem::Requirement
16
+ requirement: &70169527487200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70107699251780
24
+ version_requirements: *70169527487200
25
25
  description: RedGrape is an in-memory graph database written in ruby. I made this
26
26
  in order to learn how graph databases work so that please do not use this for any
27
27
  serious purpose.