neo4j-core 3.0.0.alpha.12 → 3.0.0.alpha.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 996e8bf0524717f822fd3b4817ae67de19a1fc4a
4
- data.tar.gz: 0dd0cce3404ead0e0f9dfa292949e2a352891ae6
3
+ metadata.gz: 0891328716d7d33fe34f80594d6eb556f1fc9dea
4
+ data.tar.gz: 392ae0f4c6f87c7b8427b73b19174ad4e2c1a3b8
5
5
  SHA512:
6
- metadata.gz: 288a4758d5ef9cd416ca964305ee1bd024c6b6632167138a3af5bcebbbb652df68ae7c2b081d8122632a4b1423d98c30304bffccc97fdaaf3ec5bb7bab1a2c2a
7
- data.tar.gz: 40de5b9275d65d987b7784754822991cf417a4f964adea529b2df94c31e926bcb0e47c0f88ee31f0ac0d0a7389013267d0bcc3e3910c8f2fc7fa8863756e7b1b
6
+ metadata.gz: 28bc9d2ae875b076be3804f0302dd98d2f16d9f06b814aed395ca30c018cf5439880a0c8954ea62e3b2cc6f6a6446bd965fd0e05cc369db823a17c69850f6144
7
+ data.tar.gz: 8b7ea7e28e2bb8ef5f4cec71c18e40bef87de52bf01d9b6f3a762fba6dc9f688f7b35067f5005e7280a0e0e454fb0ebdc0d31dd01185868983e4ad9ef1727527
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'neo4j-cypher', '~> 1.0.1'
6
-
6
+ gem 'zip'
7
7
 
8
8
  #gem 'neo4j-advanced', '>= 1.8.1', '< 2.0', :require => false
9
9
  #gem 'neo4j-enterprise', '>= 1.8.1', '< 2.0', :require => false
data/README.md CHANGED
@@ -55,6 +55,16 @@ No need to start the server since it is embedded.
55
55
 
56
56
  ## Neo4j-core API, v3.0
57
57
 
58
+ ### API Documentation
59
+
60
+ * [Neo4j::Node](http://www.rubydoc.info/github/andreasronge/neo4j-core/Neo4j/Node)
61
+ * [Neo4j::Relationship](http://www.rubydoc.info/github/andreasronge/neo4j-core/Neo4j/Relationship)
62
+ * [Neo4j::Session](http://www.rubydoc.info/github/andreasronge/neo4j-core/Neo4j/Session)
63
+ * [Neo4j::Label](http://www.rubydoc.info/github/andreasronge/neo4j-core/Neo4j/Label)
64
+
65
+ See also [Neo4j Docs](http://docs.neo4j.org/)
66
+
67
+
58
68
  ### Database Session
59
69
 
60
70
  There are currently two available types of session, one for connecting to a neo4j server
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Core
3
- VERSION = "3.0.0.alpha.12"
3
+ VERSION = "3.0.0.alpha.13"
4
4
  end
5
5
  end
@@ -62,6 +62,39 @@ module Neo4j::Embedded
62
62
 
63
63
  alias_method :_labels, :getLabels
64
64
 
65
+ def _java_label(label_name)
66
+ Java::OrgNeo4jGraphdb.DynamicLabel.label(label_name)
67
+ end
68
+
69
+
70
+ def _add_label(*label_name)
71
+ label_name.each do |name|
72
+ addLabel(_java_label(name))
73
+ end
74
+ end
75
+
76
+ alias_method :add_label, :_add_label
77
+ tx_methods :add_label
78
+
79
+ def _remove_label(*label_name)
80
+ label_name.each do |name|
81
+ removeLabel(_java_label(name))
82
+ end
83
+ end
84
+
85
+ alias_method :remove_label, :_remove_label
86
+ tx_methods :remove_label
87
+
88
+ def set_label(*label_names)
89
+ label_as_symbols = label_names.map(&:to_sym)
90
+ to_keep = labels & label_as_symbols
91
+ to_remove = labels - to_keep
92
+ _remove_label(*to_remove)
93
+ to_add = label_as_symbols - to_keep
94
+ _add_label(*to_add)
95
+ end
96
+ tx_methods :set_label
97
+
65
98
  def del
66
99
  _rels.each { |r| r.del }
67
100
  delete
@@ -84,6 +84,34 @@ module Neo4j::Server
84
84
  r.map(&:to_sym)
85
85
  end
86
86
 
87
+ def _cypher_label_list(labels)
88
+ ':' + labels.map{|label| "`#{label}`"}.join(':')
89
+ end
90
+
91
+ def add_label(*labels)
92
+ @session._query_or_fail("START n=node(#{neo_id}) SET n #{_cypher_label_list(labels)}")
93
+ end
94
+
95
+ def remove_label(*labels)
96
+ @session._query_or_fail("START n=node(#{neo_id}) REMOVE n #{_cypher_label_list(labels)}")
97
+ end
98
+
99
+ def set_label(*label_names)
100
+ label_as_symbols = label_names.map(&:to_sym)
101
+ to_keep = labels & label_as_symbols
102
+ to_remove = labels - to_keep
103
+ to_set = label_as_symbols - to_keep
104
+
105
+ # no change ?
106
+ return if to_set.empty? && to_remove.empty?
107
+
108
+ q = "START n=node(#{neo_id})"
109
+ q += " SET n #{_cypher_label_list(to_set)}" unless to_set.empty?
110
+ q += " REMOVE n #{_cypher_label_list(to_remove)}" unless to_remove.empty?
111
+
112
+ @session._query_or_fail(q)
113
+ end
114
+
87
115
  # (see Neo4j::Node#del)
88
116
  def del
89
117
  @session._query_or_fail("START n = node(#{neo_id}) MATCH n-[r]-() DELETE r")
@@ -28,9 +28,11 @@ module Neo4j::Server
28
28
 
29
29
  def each()
30
30
  data.each do |row|
31
+ hash = {}
31
32
  row.each_with_index do |row, i|
32
- yield columns[i].to_sym => row
33
+ hash[columns[i].to_sym] = row
33
34
  end
35
+ yield hash
34
36
  end
35
37
  end
36
38
  end
@@ -110,4 +112,4 @@ module Neo4j::Server
110
112
  cr
111
113
  end
112
114
  end
113
- end
115
+ end
data/lib/neo4j/label.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  module Neo4j
2
+ # A label is a named graph construct that is used to group nodes.
3
+ # See Neo4j::Node how to create and delete nodes
4
+ # @see http://docs.neo4j.org/chunked/milestone/graphdb-neo4j-labels.html
2
5
  class Label
3
6
 
4
7
  # @abstract
data/lib/neo4j/node.rb CHANGED
@@ -92,6 +92,17 @@ module Neo4j
92
92
  raise 'not implemented'
93
93
  end
94
94
 
95
+ # Sets label on the node. Any old labels will be removed
96
+ def set_label(*labels)
97
+ raise 'not implemented'
98
+ end
99
+
100
+ # Removes given labels
101
+ def remove_label(*labels)
102
+ raise 'not implemented'
103
+ end
104
+
105
+ #
95
106
  # @return all labels on the node
96
107
  def labels()
97
108
  raise 'not implemented'
@@ -1,28 +1,43 @@
1
1
  # borrowed from architect4r
2
2
  require 'os'
3
+ require 'httparty'
4
+ require 'zip'
3
5
 
4
6
  namespace :neo4j do
5
- desc "Install Neo4j"
7
+
8
+ def download_neo4j(file)
9
+ if OS::Underlying.windows? then
10
+ file_name = "neo4j.zip"
11
+ download_url = "http://dist.neo4j.org/neo4j-#{file}-windows.zip"
12
+ else
13
+ file_name = "neo4j-unix.tar.gz"
14
+ download_url = "http://dist.neo4j.org/neo4j-#{file}-unix.tar.gz"
15
+ end
16
+
17
+ unless File.exist?(file_name)
18
+ df = File.open(file_name, 'wb')
19
+ begin
20
+ df << HTTParty.get(download_url)
21
+ ensure
22
+ df.close()
23
+ end
24
+ end
25
+ file_name
26
+ end
27
+
28
+ desc "Install Neo4j, example neo4j:install[community,2.0.3]"
6
29
  task :install, :edition, :version do |t, args|
7
30
  args.with_defaults(:edition => "community")
8
31
 
9
32
  file = args[:version] ? "#{args[:edition]}-#{args[:version]}" : "#{args[:edition]}"
10
33
  puts "Installing Neo4j-#{file}"
34
+
35
+ downloaded_file = download_neo4j file
11
36
 
12
37
  if OS::Underlying.windows?
13
- # Download Neo4j
14
- unless File.exist?('neo4j.zip')
15
- df = File.open('neo4j.zip', 'wb')
16
- begin
17
- df << HTTParty.get("http://dist.neo4j.org/neo4j-#{file}-windows.zip")
18
- ensure
19
- df.close()
20
- end
21
- end
22
-
23
38
  # Extract and move to neo4j directory
24
39
  unless File.exist?('neo4j')
25
- Zip::ZipFile.open('neo4j.zip') do |zip_file|
40
+ Zip::ZipFile.open(downloaded_file) do |zip_file|
26
41
  zip_file.each do |f|
27
42
  f_path=File.join(".", f.name)
28
43
  FileUtils.mkdir_p(File.dirname(f_path))
@@ -34,6 +49,7 @@ namespace :neo4j do
34
49
  end
35
50
  end
36
51
  FileUtils.mv "neo4j-#{file}", "neo4j"
52
+ FileUtils.rm downloaded_file
37
53
  end
38
54
 
39
55
  # Install if running with Admin Privileges
@@ -43,11 +59,9 @@ namespace :neo4j do
43
59
  end
44
60
 
45
61
  else
46
- # E.g. http://dist.neo4j.org/neo4j-community-2.0.0-unix.tar.gz
47
- %x[wget http://dist.neo4j.org/neo4j-#{file}-unix.tar.gz]
48
- %x[tar -xvzf neo4j-#{file}-unix.tar.gz]
62
+ %x[tar -xvf #{downloaded_file}]
49
63
  %x[mv neo4j-#{file} neo4j]
50
- %x[rm neo4j-#{file}-unix.tar.gz]
64
+ %x[rm #{downloaded_file}]
51
65
  puts "Neo4j Installed in to neo4j directory."
52
66
  end
53
67
  puts "Type 'rake neo4j:start' to start it"
data/neo4j-core.gemspec CHANGED
@@ -31,7 +31,8 @@ It comes included with the Apache Lucene document database.
31
31
  # Not released yet
32
32
  s.add_dependency("httparty")
33
33
  s.add_dependency("json")
34
- s.add_dependency("os")
34
+ s.add_dependency("os") # for Rake task
35
+ s.add_dependency("zip") # for Rake task
35
36
  s.add_dependency("neo4j-cypher")
36
37
 
37
38
  if RUBY_PLATFORM =~ /java/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha.12
4
+ version: 3.0.0.alpha.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-27 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: zip
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: neo4j-cypher
57
71
  requirement: !ruby/object:Gem::Requirement