neo4apis 0.0.4 → 0.1.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: ce1c0386a3c09c46b8f6121ec5365767cf3fa6c0
4
- data.tar.gz: b5fc80eab66e2437df93b80710862cbd01ce37e0
3
+ metadata.gz: 263a1abd3e312305779129128e2d57f89f40f322
4
+ data.tar.gz: 581cde3d29596bc38e767cfbc681d5d16a49124c
5
5
  SHA512:
6
- metadata.gz: a843d25cf552b8768ac50409674769d86f909127935e91e79aa93260e8db16b58222a1e84307bfdf0c95f9e3e27c6cdadf10d62aba23b9131d3443a4ec1b33a4
7
- data.tar.gz: b975297653c2c9cedd06a68dbd8db4c71cd7045649edf1c49bf8b1fb752807783f78cd44c43228abaa68d06ad28de45ceda2a0bfcae7d1e7f3b0d2739202f1a7
6
+ metadata.gz: 3a6cea13605e886f0d60ad96ce4d2021823cb0b8c5990032d3a5da33547d96e3c50c46d802edb09a7aa2dd96119314934ef54ed9b40b30eab5acb550e11f06c5
7
+ data.tar.gz: f7a4e1b8c9fe255acc05d2f86bfe5eeca35235ef376f89154155e4d68d8308d5ca7507d80506d5a034abe946f2031312d99fae94dd34f903601b14bc79afae7f
data/README.md CHANGED
@@ -21,10 +21,11 @@ In the below example we assume that a variable `awesome_client` is passed in whi
21
21
  user_node = add_user(widget.owner)
22
22
 
23
23
  # add_node comes from From Neo4Apis::Base
24
- node = add_node :Widget, {
25
- uuid: widget.uuid,
26
- text: widget.text,
27
- }
24
+ # Imports the uuid and text values from the widget object to the node
25
+ node = add_node(:Widget, widget, [:uuid, :text]) do |node|
26
+ # Imports the double_foo property to the node which isn't a simple copy
27
+ node.double_foo = widget.foo * 2
28
+ end
28
29
 
29
30
  # add_relationship comes from Neo4Apis::Base
30
31
  add_relationship(:owns, user_node, node)
@@ -33,11 +34,7 @@ In the below example we assume that a variable `awesome_client` is passed in whi
33
34
  end
34
35
 
35
36
  importer :User do |user|
36
- add_node :User, {
37
- id: user.id,
38
- username: user.username,
39
- name: user.name,
40
- }
37
+ add_node :User, user, [:id, :username, :name]
41
38
  end
42
39
 
43
40
  end
data/lib/neo4apis/base.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'ostruct'
2
+
1
3
  module Neo4Apis
2
4
  class Base
3
5
  UUID_FIELDS = {}
@@ -16,12 +18,22 @@ module Neo4Apis
16
18
  @buffer.flush
17
19
  end
18
20
 
19
- def add_node(label, props = {})
21
+ def add_node(label, object = nil, columns = [])
22
+ props = OpenStruct.new
23
+
24
+ if object
25
+ columns.each do |column|
26
+ props[column] = object.send(column)
27
+ end
28
+ end
29
+
30
+ yield props if block_given?
31
+
20
32
  require_batch
21
33
 
22
34
  raise ArgumentError, "No UUID specified for label `#{label}`" if not UUID_FIELDS[label.to_sym]
23
35
 
24
- self.class.node_proxy(label).new(props).tap do |node_proxy|
36
+ self.class.node_proxy(label).new(props.to_h).tap do |node_proxy|
25
37
  @buffer << create_node_query(node_proxy)
26
38
  end
27
39
  end
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.0.4'
6
+ s.version = '0.1.0'
7
7
  s.required_ruby_version = ">= 1.9.1"
8
8
 
9
9
  s.authors = "Brian Underwood"
@@ -19,6 +19,6 @@ A core library for importing data from APIs into neo4j. Designed to be used wit
19
19
  s.files = Dir.glob("{bin,lib,config}/**/*") + %w(README.md Gemfile neo4apis.gemspec)
20
20
 
21
21
  s.add_dependency('faraday', "~> 0.9.0")
22
- s.add_dependency("neo4j-core", "~> 3.0.3")
22
+ s.add_dependency("neo4j-core", "~> 3.0.4")
23
23
 
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4apis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Underwood
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.3
33
+ version: 3.0.4
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.3
40
+ version: 3.0.4
41
41
  description: |
42
42
  A core library for importing data from APIs into neo4j. Designed to be used with an adapter
43
43
  email: public@brian-underwood.codes