neo4apis 0.5.1 → 0.6.0

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: cad7db52ef054711d9a46ad72faf561c33362031
4
- data.tar.gz: 0e2e23ad1809609017197d73dbec931ce930bc4e
3
+ metadata.gz: 9dc39e5d15243ff0fd5af9801cbee5effc409a7d
4
+ data.tar.gz: cc39d6d2a1975b0b77a5a7582ec0da1351e13dc3
5
5
  SHA512:
6
- metadata.gz: 414105a2a254d9ff77289b2b6a2f91d09b03476ac3bcfde76747bf2ed7a0d7b9c3f743f5f70a7b89765e1bced4931367ff64be9613776ec6b55913a73f28dc48
7
- data.tar.gz: af73110ad0007e807b88e7122887c3e0a25b079c536fecbef727a09ad4bc4f4420904aba4291fcbc1a92cfb35ba8354dcab216fc92054aedfcad529a503c448b
6
+ metadata.gz: ab9c88c313865a7d42d04f0ffa1ab12d0ed52e3ad016cbf982d54af3258dbdc0b824facb430c2c2c965f6bcde5d813cc9ce674769e45a203df11de62ec7957f9
7
+ data.tar.gz: fbd2705473967bc5e41e3adb9ef80e8ee9eef09b8685bf4f64202387f155d6cad00be40e0c7d502e0545883eeb3e1f5ecb3f3f712b6907e529a43e8dd27dc66c
data/bin/neo4apis CHANGED
@@ -5,9 +5,10 @@ require 'neo4apis/cli/base'
5
5
 
6
6
  # Require all of the neo4apis gems so that we can include their CLI classes
7
7
  # This is rubygems specific. Happy for other solutions that anybody can provide
8
- Gem::Specification.all.select do |spec|
8
+ Gem::Specification.select do |spec|
9
9
  spec.name =~ /neo4apis-/
10
10
  end.map(&:name).map do |name|
11
+ puts "requiring #{name}"
11
12
  require name
12
13
  end
13
14
 
data/lib/neo4apis/base.rb CHANGED
@@ -62,8 +62,12 @@ module Neo4Apis
62
62
  self.instance_exec(*args, &IMPORTERS[label.to_sym])
63
63
  end
64
64
 
65
- def self.prefix(prefix)
66
- @prefix = prefix
65
+ def self.common_label(common_label = nil)
66
+ if common_label.nil?
67
+ @common_label
68
+ else
69
+ @common_label = common_label
70
+ end
67
71
  end
68
72
 
69
73
  def self.importer(label, &block)
@@ -114,27 +118,27 @@ module Neo4Apis
114
118
  private
115
119
 
116
120
  def create_node_query(node_proxy)
117
- Neo4j::Core::Query.new.
118
- merge(node: {self.class.full_label(node_proxy.label) => {node_proxy.uuid_field => node_proxy.uuid_value}}).
121
+ query = Neo4j::Core::Query.new.
122
+ merge(node: {node_proxy.label => {node_proxy.uuid_field => node_proxy.uuid_value}}).
119
123
  break.
120
124
  set(node: node_proxy.props)
125
+
126
+ query = query.set("node:#{self.class.common_label}") if self.class.common_label
127
+
128
+ query
121
129
  end
122
130
 
123
131
  def create_relationship_query(type, source, target, props)
124
132
  Neo4j::Core::Query.new.
125
- match(source: {self.class.full_label(source.label) => {source.uuid_field => source.uuid_value}}).
126
- match(target: {self.class.full_label(target.label) => {target.uuid_field => target.uuid_value}}).
133
+ match(source: {source.label => {source.uuid_field => source.uuid_value}}).
134
+ match(target: {target.label => {target.uuid_field => target.uuid_value}}).
127
135
  merge("source-[rel:#{type}]->target").
128
136
  break.
129
137
  set(rel: props)
130
138
  end
131
139
 
132
140
  def create_constraint_query(label, uuid_field)
133
- Neo4j::Core::Query.new.create("CONSTRAINT ON (node:`#{self.class.full_label(label)}`) ASSERT node.#{uuid_field} IS UNIQUE")
134
- end
135
-
136
- def self.full_label(label)
137
- "#{@prefix}#{label}".to_sym
141
+ Neo4j::Core::Query.new.create("CONSTRAINT ON (node:`#{label}`) ASSERT node.#{uuid_field} IS UNIQUE")
138
142
  end
139
143
 
140
144
  def require_batch
@@ -2,7 +2,6 @@ module Neo4Apis
2
2
  module CLI
3
3
  class Base < ::Thor
4
4
  class_option :neo4j_url, type: :string, default: 'http://localhost:7474'
5
-
6
5
  end
7
6
  end
8
7
  end
@@ -34,6 +34,8 @@ module Neo4Apis
34
34
  private
35
35
 
36
36
  def execute
37
+ return if empty?
38
+
37
39
  @faraday_connection.post do |req|
38
40
  req.url '/db/data/transaction/commit'
39
41
  req.headers['Accept'] = 'application/json; charset=UTF-8'
data/neo4apis.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.unshift lib unless $:.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "neo4apis"
6
- s.version = '0.5.1'
6
+ s.version = '0.6.0'
7
7
  s.required_ruby_version = ">= 1.9.1"
8
8
 
9
9
  s.authors = "Brian Underwood"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4apis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Underwood
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday