geoff 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/geoff.gemspec +3 -1
- data/lib/geoff/importer.rb +0 -21
- data/lib/geoff/version.rb +1 -1
- data/lib/geoff.rb +17 -2
- data/spec/models/geoff_spec.rb +4 -6
- metadata +2 -2
data/geoff.gemspec
CHANGED
@@ -19,7 +19,9 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.require_paths = ["lib"]
|
20
20
|
gem.version = Geoff::VERSION
|
21
21
|
|
22
|
-
|
22
|
+
if RUBY_PLATFORM=="java"
|
23
|
+
gem.add_dependency 'neo4j'
|
24
|
+
end
|
23
25
|
gem.add_dependency 'activesupport', '~> 3.2.3'
|
24
26
|
gem.add_dependency 'json'
|
25
27
|
|
data/lib/geoff/importer.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'java'
|
2
1
|
require 'fileutils'
|
3
2
|
Dir["lib/jars/*"].each {|file| require file }
|
4
3
|
|
@@ -43,7 +42,6 @@ class Geoff
|
|
43
42
|
|
44
43
|
def go
|
45
44
|
raise Geoff::InvalidRules.new('Invalid rules') unless validate_rules(@rules)
|
46
|
-
delete_database if drop?
|
47
45
|
|
48
46
|
log 'importing the database'
|
49
47
|
|
@@ -55,21 +53,6 @@ class Geoff
|
|
55
53
|
|
56
54
|
private
|
57
55
|
|
58
|
-
def delete_database
|
59
|
-
if testmode?
|
60
|
-
Neo4j::Transaction.run do
|
61
|
-
Neo4j.db.each_node do |n|
|
62
|
-
n.del unless n.neo_id == 0
|
63
|
-
end
|
64
|
-
end
|
65
|
-
else
|
66
|
-
Neo4j.db.shutdown
|
67
|
-
FileUtils.rm_rf Neo4j::Config[:storage_path]
|
68
|
-
log "restarting the database #{Neo4j::Config[:storage_path]}"
|
69
|
-
Neo4j.db.start
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
56
|
def import_geoff_rules(rules)
|
74
57
|
sub_graph = Subgraph.new(rules)
|
75
58
|
node_map = build_node_map
|
@@ -131,10 +114,6 @@ class Geoff
|
|
131
114
|
$stdout.puts message unless silent?
|
132
115
|
end
|
133
116
|
|
134
|
-
def drop?
|
135
|
-
option_value?(:drop, false)
|
136
|
-
end
|
137
|
-
|
138
117
|
def silent?
|
139
118
|
option_value? :silent
|
140
119
|
end
|
data/lib/geoff/version.rb
CHANGED
data/lib/geoff.rb
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
require "json"
|
2
2
|
require "geoff/version"
|
3
3
|
require 'geoff/node_dsl'
|
4
|
-
require 'geoff/importer'
|
5
4
|
require 'geoff/children_dsl'
|
6
5
|
|
6
|
+
def java_present?
|
7
|
+
require 'java'
|
8
|
+
true
|
9
|
+
rescue LoadError
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
if java_present?
|
14
|
+
require 'geoff/importer'
|
15
|
+
else
|
16
|
+
$stderr.puts "In order to use the Geoff::Importer class and Geoff.import you must
|
17
|
+
be running under jruby"
|
18
|
+
end
|
19
|
+
|
7
20
|
class Geoff::Error < StandardError; end
|
8
21
|
class Geoff::MissingNodeDefinition < Geoff::Error ; end
|
9
22
|
class Geoff::ContainerLabelMissing < Geoff::Error ; end
|
@@ -38,9 +51,11 @@ class Geoff
|
|
38
51
|
end
|
39
52
|
|
40
53
|
def to_geoff
|
54
|
+
return @geoff if @geoff
|
55
|
+
|
41
56
|
geoff = "#{add_classes}\n"
|
42
57
|
geoff += @children_dsl.to_geoff if @children_dsl
|
43
|
-
geoff.chomp
|
58
|
+
@geoff = geoff.chomp
|
44
59
|
end
|
45
60
|
|
46
61
|
def <=> other
|
data/spec/models/geoff_spec.rb
CHANGED
@@ -134,8 +134,7 @@ describe Geoff do
|
|
134
134
|
EOS
|
135
135
|
}
|
136
136
|
|
137
|
-
specify "with parent node is root node, but no relationship,
|
138
|
-
don't create relationship to root node" do
|
137
|
+
specify "with parent node is root node, but no relationship, don't create relationship to root node" do
|
139
138
|
Geoff.new(Cafe, Branch) do
|
140
139
|
cafe 'Starbucks' do
|
141
140
|
children 'owns' do
|
@@ -145,7 +144,7 @@ describe Geoff do
|
|
145
144
|
end
|
146
145
|
|
147
146
|
end.to_geoff.should == expected
|
148
|
-
|
147
|
+
end
|
149
148
|
end
|
150
149
|
|
151
150
|
describe 'called second time' do
|
@@ -155,13 +154,12 @@ describe Geoff do
|
|
155
154
|
end
|
156
155
|
end
|
157
156
|
|
158
|
-
let(:
|
157
|
+
let(:geoff_returned_by_first_call) do
|
159
158
|
node.to_geoff
|
160
159
|
end
|
161
160
|
|
162
161
|
it 'returns same geoff as on first call' do
|
163
|
-
|
164
|
-
node.to_geoff.should == expected_geoff
|
162
|
+
node.to_geoff.should == geoff_returned_by_first_call
|
165
163
|
end
|
166
164
|
end
|
167
165
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: geoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- David Rouchy
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-08-
|
16
|
+
date: 2012-08-31 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: neo4j
|