neoscout 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/root/README.md ADDED
@@ -0,0 +1,3 @@
1
+ Toplevel file of neoscout sinatra webroot
2
+
3
+ Mainly exists so that `root/` gets created when checking out from git
data/script/neoscout ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby --1.9
2
+ # -*- mode: ruby -*-
3
+
4
+ require 'rubygems'
5
+
6
+ # Set up gems listed in the Gemfile to deal with rubygems-bundle-nastyness
7
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
8
+ require 'bundler/setup'
9
+
10
+ # Patch in actual gem path. Yay.
11
+ $:.push File.expand_path("../../lib", __FILE__)
12
+ require 'neoscout'
13
+ require 'neoscout/main'
14
+
15
+ NeoScout::Main.new.run
@@ -0,0 +1,25 @@
1
+ require 'spec/spec_helper'
2
+ require 'neoscout'
3
+
4
+ module NeoScout
5
+ module Constraints
6
+
7
+ describe PropConstraint do
8
+
9
+ it 'should require names to be strings' do
10
+ lambda { PropConstraint.new name: 1 }.should raise_error(ArgumentError)
11
+ end
12
+
13
+ it 'should require names to have length > 0' do
14
+ lambda { PropConstraint.new name: '' }.should raise_error(ArgumentError)
15
+ end
16
+
17
+ it 'should properly implement to_str' do
18
+ (PropConstraint.new name: 'dingo').to_s.should be == 'dingo'
19
+ (PropConstraint.new name: 'dingo', opt: true).to_s.should be == 'dingo (opt.)'
20
+ (PropConstraint.new name: 'dingo', opt: true, type: :int).to_s.should be == 'dingo: int (opt.)'
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,81 @@
1
+ require 'spec/spec_helper'
2
+ require 'neoscout'
3
+
4
+ require 'fileutils'
5
+
6
+ module NeoScout
7
+ module GDB_Neo4j
8
+
9
+ describe Constraints do
10
+
11
+ it "should render constraints properly to_s" do
12
+ @it = ::NeoScout::GDB_Neo4j::Scout.new
13
+ (@it.verifier.new_node_prop_constr name: 'foo').to_s.should be == "foo"
14
+ end
15
+
16
+ end
17
+
18
+ describe Scout do
19
+
20
+ def load_schema
21
+ ::JSON.parse(::IO.read('spec/lib/neoscout/gdb_neo4j_spec_schema.json'))
22
+ end
23
+
24
+ def load_counts
25
+ ::JSON.parse(::IO.read('spec/lib/neoscout/gdb_neo4j_spec_counts.json'))
26
+ end
27
+
28
+ before(:each) do
29
+ @schema_json = load_schema
30
+ @schema_counts = load_counts
31
+
32
+ ::Neo4j::Transaction.run do
33
+ @user_a = ::Neo4j::Node.new type: 'users', name: 'Alfons'
34
+ @user_b = ::Neo4j::Node.new type: 'users', name: 'Bernhard', age: '33'
35
+ @user_c = ::Neo4j::Node.new type: 'users', name: 'Claudio'
36
+ @user_d = ::Neo4j::Node.new type: 'users', name: 'Diderot'
37
+ @user_e = ::Neo4j::Node.new type: 'users', name: 'Ephraim'
38
+ @user_f = ::Neo4j::Node.new type: 'users', name: 'Francois'
39
+ @user_g = ::Neo4j::Node.new type: 'users'
40
+ @user_h = ::Neo4j::Node.new type: 'users', name: 0xbaadf00d
41
+
42
+ @challenge1 = ::Neo4j::Node.new type: 'challenges', descr: 'Eat fish on friday'
43
+
44
+ @user_a.outgoing(:challenger) << @challenge1
45
+ @user_b.incoming(:challengee) << @challenge1
46
+ @rel0 = ::Neo4j::Relationship.new(:fugleman, @challenge1, @user_a)
47
+ @rel0['accepted'] = true
48
+ @rel1 = ::Neo4j::Relationship.new(:fugleman, @challenge1, @user_b)
49
+ @user_e.outgoing(:spectator) << @challenge1
50
+ @user_e.outgoing(:spectator) << @user_g
51
+ end
52
+
53
+ @storage_path = ::Neo4j.db.storage_path
54
+ puts "Initialized at '#{@storage_path}'..."
55
+ end
56
+
57
+ after(:each) do
58
+ ::Neo4j.shutdown
59
+ puts "Deleting '#{@storage_path}'..."
60
+ FileUtils.rm_rf @storage_path unless (ENV['NEOSCOUT_KEEP_DB']=='YES')
61
+ end
62
+
63
+ it 'should verify properties correctly' do
64
+ @it = ::NeoScout::GDB_Neo4j::Scout.new
65
+ @it.typer.type_attr = 'type'
66
+ @it.typer.value_type_table['string'] = lambda { |n,v| v.kind_of? String }
67
+ @it.verifier.init_from_json @schema_json
68
+ @counts = @it.new_counts
69
+ @it.count_edges counts: @counts
70
+ @it.count_nodes counts: @counts
71
+ @counts.add_to_json @schema_json
72
+ puts '<<RESULT'
73
+ puts @schema_json.to_json
74
+ puts 'RESULT'
75
+ @schema_json.should be == @schema_counts
76
+ end
77
+
78
+ end
79
+
80
+ end
81
+ end
@@ -0,0 +1,282 @@
1
+ {"nodes":{
2
+ "users":{
3
+ "properties":{
4
+ "type":{
5
+ "relevant":true,
6
+ "counts":{
7
+ "num_failed":0,
8
+ "num_total":8
9
+ }
10
+ },
11
+ "name":{
12
+ "relevant":true,
13
+ "type":"string",
14
+ "counts":{
15
+ "num_failed":1,
16
+ "num_total":8
17
+ }
18
+ },
19
+ "age":{
20
+ "counts":{
21
+ "num_failed":1,
22
+ "num_total":1
23
+ }
24
+ }
25
+ },
26
+ "counts":{
27
+ "num_failed":2,
28
+ "num_total":8
29
+ },
30
+ "src_stats":{
31
+ "challenger":{
32
+ "num_failed":0,
33
+ "num_total":1
34
+ },
35
+ "spectator":{
36
+ "num_failed":1,
37
+ "num_total":2
38
+ }
39
+ },
40
+ "dst_stats":{
41
+ "challengee":{
42
+ "num_failed":0,
43
+ "num_total":1
44
+ },
45
+ "fugleman":{
46
+ "num_failed":1,
47
+ "num_total":2
48
+ },
49
+ "spectator":{
50
+ "num_failed":1,
51
+ "num_total":1
52
+ }
53
+ }
54
+ },
55
+ "challenges":{
56
+ "properties":{
57
+ "type":{
58
+ "relevant":true,
59
+ "counts":{
60
+ "num_failed":0,
61
+ "num_total":1
62
+ }
63
+ },
64
+ "descr":{
65
+ "relevant":false,
66
+ "counts":{
67
+ "num_failed":0,
68
+ "num_total":1
69
+ }
70
+ }
71
+ },
72
+ "counts":{
73
+ "num_failed":0,
74
+ "num_total":1
75
+ },
76
+ "src_stats":{
77
+ "challengee":{
78
+ "num_failed":0,
79
+ "num_total":1
80
+ },
81
+ "fugleman":{
82
+ "num_failed":1,
83
+ "num_total":2
84
+ }
85
+ },
86
+ "dst_stats":{
87
+ "challenger":{
88
+ "num_failed":0,
89
+ "num_total":1
90
+ },
91
+ "spectator":{
92
+ "num_failed":0,
93
+ "num_total":1
94
+ }
95
+ }
96
+ }
97
+ }, "connections":{
98
+ "challenger":{
99
+ "sources":["users"],
100
+ "targets":["challenges"],
101
+ "properties":{},
102
+ "counts":{
103
+ "num_failed":0,
104
+ "num_total":1
105
+ },
106
+ "src_stats":[
107
+ {
108
+ "name":"users",
109
+ "to_dst":[
110
+ {
111
+ "name":"challenges",
112
+ "counts":{
113
+ "num_failed":0,
114
+ "num_total":1
115
+ }
116
+ }
117
+ ]
118
+ }
119
+ ],
120
+ "dst_stats":[
121
+ {
122
+ "name":"challenges",
123
+ "from_src":[
124
+ {
125
+ "name":"users",
126
+ "counts":{
127
+ "num_failed":0,
128
+ "num_total":1
129
+ }
130
+ }
131
+ ]
132
+ }
133
+ ]
134
+ },
135
+ "spectator":{
136
+ "sources":["users"],
137
+ "targets":["challenges"],
138
+ "properties":{},
139
+ "counts":{
140
+ "num_failed":1,
141
+ "num_total":2
142
+ },
143
+ "src_stats":[
144
+ {
145
+ "name":"users",
146
+ "to_dst":[
147
+ {
148
+ "name":"challenges",
149
+ "counts":{
150
+ "num_failed":0,
151
+ "num_total":1
152
+ }
153
+ },
154
+ {
155
+ "name":"users",
156
+ "counts":{
157
+ "num_failed":1,
158
+ "num_total":1
159
+ }
160
+ }
161
+ ]
162
+ }
163
+ ],
164
+ "dst_stats":[
165
+ {
166
+ "name":"challenges",
167
+ "from_src":[
168
+ {
169
+ "name":"users",
170
+ "counts":{
171
+ "num_failed":0,
172
+ "num_total":1
173
+ }
174
+ }
175
+ ]
176
+ },
177
+ {
178
+ "name":"users",
179
+ "from_src":[
180
+ {
181
+ "name":"users",
182
+ "counts":{
183
+ "num_failed":1,
184
+ "num_total":1
185
+ }
186
+ }
187
+ ]
188
+ }
189
+ ]
190
+ },
191
+ "challengee":{
192
+ "targets":["users"],
193
+ "sources":["challenges"],
194
+ "properties":{},
195
+ "counts":{
196
+ "num_failed":0,
197
+ "num_total":1
198
+ },
199
+ "src_stats":[
200
+ {
201
+ "name":"challenges",
202
+ "to_dst":[
203
+ {
204
+ "name":"users",
205
+ "counts":{
206
+ "num_failed":0,
207
+ "num_total":1
208
+ }
209
+ }
210
+ ]
211
+ }
212
+ ],
213
+ "dst_stats":[
214
+ {
215
+ "name":"users",
216
+ "from_src":[
217
+ {
218
+ "name":"challenges",
219
+ "counts":{
220
+ "num_failed":0,
221
+ "num_total":1
222
+ }
223
+ }
224
+ ]
225
+ }
226
+ ]
227
+ },
228
+ "fugleman":{
229
+ "properties":{
230
+ "accepted":{
231
+ "relevant":true,
232
+ "counts":{
233
+ "num_failed":1,
234
+ "num_total":2
235
+ }
236
+ }
237
+ },
238
+ "targets":["users"],
239
+ "sources":["challenges"],
240
+ "counts":{
241
+ "num_failed":1,
242
+ "num_total":2
243
+ },
244
+ "src_stats":[
245
+ {
246
+ "name":"challenges",
247
+ "to_dst":[
248
+ {
249
+ "name":"users",
250
+ "counts":{
251
+ "num_failed":1,
252
+ "num_total":2
253
+ }
254
+ }
255
+ ]
256
+ }
257
+ ],
258
+ "dst_stats":[
259
+ {
260
+ "name":"users",
261
+ "from_src":[
262
+ {
263
+ "name":"challenges",
264
+ "counts":{
265
+ "num_failed":1,
266
+ "num_total":2
267
+ }
268
+ }
269
+ ]
270
+ }
271
+ ]
272
+ }
273
+ }, "all":{
274
+ "node_counts":{
275
+ "num_failed":2,
276
+ "num_total":9
277
+ },
278
+ "connection_counts":{
279
+ "num_failed":2,
280
+ "num_total":6
281
+ }
282
+ }}
@@ -0,0 +1,46 @@
1
+ {
2
+ "nodes":{
3
+ "users":{
4
+ "properties":{
5
+ "type":{
6
+ "relevant":true
7
+ },
8
+ "name":{
9
+ "relevant":true,
10
+ "type":"string"
11
+ }
12
+ }
13
+ },
14
+ "challenges":{
15
+ "properties":{
16
+ "type":{
17
+ "relevant":true
18
+ },
19
+ "descr":{
20
+ "relevant":false
21
+ }
22
+ }
23
+ }
24
+ },
25
+ "connections":{
26
+ "challenger":{
27
+ "sources":["users"],
28
+ "targets":["challenges"]
29
+ },
30
+ "spectator":{
31
+ "sources":["users"],
32
+ "targets":["challenges"]
33
+ },
34
+ "challengee":{
35
+ "targets":["users"],
36
+ "sources":["challenges"]
37
+ },
38
+ "fugleman":{
39
+ "properties":{
40
+ "accepted": {"relevant": true}
41
+ },
42
+ "targets":["users"],
43
+ "sources":["challenges"]
44
+ }
45
+ }
46
+ }