geoff-importer 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  db/*
19
+ .DS_Store
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ geoff
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ jruby-1.7.0
@@ -21,7 +21,9 @@ Gem::Specification.new do |gem|
21
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
22
  gem.require_paths = ["lib"]
23
23
 
24
- gem.add_dependency("neo4j-community", '>= 1.8.M05', '< 1.9')
24
+ gem.add_dependency("neo4j-community", '1.8.0')
25
+ gem.add_dependency("neo4j-advanced", '1.8.0')
26
+ gem.add_dependency("neo4j-enterprise", '1.8.0')
25
27
 
26
28
  gem.add_development_dependency 'jruby-openssl'
27
29
  gem.add_development_dependency 'rake'
@@ -1,6 +1,9 @@
1
1
  require 'fileutils'
2
2
  require 'neo4j-community'
3
- Dir["lib/jars/*"].each {|file| require file }
3
+ require 'neo4j-advanced'
4
+ require 'neo4j-enterprise'
5
+
6
+ Dir[File.join("#{File.dirname(__FILE__)}", "jars", "*.jar")].each { |file| require file }
4
7
 
5
8
  require "geoff-importer/version"
6
9
  require "geoff-importer/importer"
@@ -18,13 +18,16 @@ class Geoff
18
18
 
19
19
  Subgraph = org.neo4j.geoff.Subgraph
20
20
  EmbeddedDB = Java::OrgNeo4jKernel::EmbeddedGraphDatabase
21
+ HaDb = Java::OrgNeo4jKernel::HighlyAvailableGraphDatabase
21
22
 
22
23
  class << self
23
- def import geoff, db, node_map = {}
24
- set_geoff geoff
25
- set_db db
24
+ def import geoff, db, node_map = {}, options = {}
25
+ @options = options
26
+
27
+ set_geoff(geoff)
28
+ set_db(db)
26
29
 
27
- import_geoff node_map
30
+ import_geoff(node_map)
28
31
  shutdown if db.is_a? String
29
32
  end
30
33
 
@@ -63,7 +66,23 @@ class Geoff
63
66
 
64
67
  def start_db(db_path)
65
68
  Geoff.log 'starting database'
66
- @graph_db = EmbeddedDB.new(db_path)
69
+ @graph_db = if ha_enabled?
70
+ start_ha_db(db_path)
71
+ else
72
+ start_embedded_db(db_path)
73
+ end
74
+ end
75
+
76
+ def start_embedded_db(db_path)
77
+ EmbeddedDB.new(db_path)
78
+ end
79
+
80
+ def start_ha_db(db_path)
81
+ HaDb.new(db_path, @options)
82
+ end
83
+
84
+ def ha_enabled?
85
+ !!@options['ha.db']
67
86
  end
68
87
 
69
88
  def shutdown
@@ -1,5 +1,5 @@
1
1
  class Geoff
2
2
  module Importer
3
- VERSION = "0.0.2"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -3,13 +3,11 @@ require 'geoff-importer'
3
3
 
4
4
  describe Geoff::Importer do
5
5
  let(:db_path) { './db/test'}
6
- let(:geoff_string) { '(A) {"name": "Alice"}' }
7
-
6
+ let(:geoff_string) { '(A) {"name": "Alice", "test_array":["value1", "value2"]}' }
8
7
 
9
8
  context 'running db' do
10
9
  it 'raises error if db is passed in as string' do
11
10
  db = Java::OrgNeo4jKernel::EmbeddedGraphDatabase.new(db_path)
12
- # debugger
13
11
  expect { Geoff::Importer.import(geoff_string, db_path) }.to raise_error
14
12
  db.shutdown
15
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geoff-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,29 +9,53 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
12
+ date: 2013-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: neo4j-community
16
16
  version_requirements: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ! '>='
18
+ - - '='
19
+ - !ruby/object:Gem::Version
20
+ version: 1.8.0
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
19
25
  - !ruby/object:Gem::Version
20
- version: 1.8.M05
21
- - - !binary |-
22
- PA==
26
+ version: 1.8.0
27
+ none: false
28
+ prerelease: false
29
+ type: :runtime
30
+ - !ruby/object:Gem::Dependency
31
+ name: neo4j-advanced
32
+ version_requirements: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '='
23
35
  - !ruby/object:Gem::Version
24
- version: '1.9'
36
+ version: 1.8.0
25
37
  none: false
26
38
  requirement: !ruby/object:Gem::Requirement
27
39
  requirements:
28
- - - ! '>='
40
+ - - '='
29
41
  - !ruby/object:Gem::Version
30
- version: 1.8.M05
31
- - - !binary |-
32
- PA==
42
+ version: 1.8.0
43
+ none: false
44
+ prerelease: false
45
+ type: :runtime
46
+ - !ruby/object:Gem::Dependency
47
+ name: neo4j-enterprise
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '='
51
+ - !ruby/object:Gem::Version
52
+ version: 1.8.0
53
+ none: false
54
+ requirement: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - '='
33
57
  - !ruby/object:Gem::Version
34
- version: '1.9'
58
+ version: 1.8.0
35
59
  none: false
36
60
  prerelease: false
37
61
  type: :runtime
@@ -115,7 +139,8 @@ files:
115
139
  - .gitignore
116
140
  - .rbenv-version
117
141
  - .rspec
118
- - .rvmrc
142
+ - .ruby-gemset
143
+ - .ruby-version
119
144
  - Gemfile
120
145
  - LICENSE.txt
121
146
  - README.md
data/.rvmrc DELETED
@@ -1,54 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use jruby" > .rvmrc
9
- environment_id="jruby-1.7.0@geoff"
10
- export JRUBY_OPTS='-J-Xms1024m -J-Xmx1024m -J-XX:+UseConcMarkSweepGC -J-XX:MaxPermSize=512m -J-Djruby.thread.pooling=true'
11
-
12
- # Uncomment the following lines if you want to verify rvm version per project
13
- # rvmrc_rvm_version="1.16.19 (stable)" # 1.10.1 seams as a safe start
14
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
15
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
16
- # return 1
17
- # }
18
-
19
- # Uncomment following line if you want options to be set only for given project.
20
- # PROJECT_JRUBY_OPTS=( --1.9 )
21
- # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell:
22
- # chmod +x ${rvm_path}/hooks/after_use_jruby_opts
23
-
24
- # First we attempt to load the desired environment directly from the environment
25
- # file. This is very fast and efficient compared to running through the entire
26
- # CLI and selector. If you want feedback on which environment was used then
27
- # insert the word 'use' after --create as this triggers verbose mode.
28
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
29
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
30
- then
31
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
32
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
33
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
34
- else
35
- # If the environment file has not yet been created, use the RVM CLI to select.
36
- rvm --create "$environment_id" || {
37
- echo "Failed to create RVM environment '${environment_id}'."
38
- return 1
39
- }
40
- fi
41
-
42
- # If you use bundler, this might be useful to you:
43
- # if [[ -s Gemfile ]] && {
44
- # ! builtin command -v bundle >/dev/null ||
45
- # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
46
- # }
47
- # then
48
- # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
49
- # gem install bundler
50
- # fi
51
- # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
52
- # then
53
- # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
54
- # fi