neo4apis 0.1.0 → 0.2.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: 263a1abd3e312305779129128e2d57f89f40f322
4
- data.tar.gz: 581cde3d29596bc38e767cfbc681d5d16a49124c
3
+ metadata.gz: b354c2fcdc459dfee003519187e331dbbdf18b21
4
+ data.tar.gz: 582a44a502d76bc64787c91b6adc8fe5d701bf94
5
5
  SHA512:
6
- metadata.gz: 3a6cea13605e886f0d60ad96ce4d2021823cb0b8c5990032d3a5da33547d96e3c50c46d802edb09a7aa2dd96119314934ef54ed9b40b30eab5acb550e11f06c5
7
- data.tar.gz: f7a4e1b8c9fe255acc05d2f86bfe5eeca35235ef376f89154155e4d68d8308d5ca7507d80506d5a034abe946f2031312d99fae94dd34f903601b14bc79afae7f
6
+ metadata.gz: 906c3561511e1d9896d5c9f53f6bde9613091672a0808a20ad2a67393eb730c4901c8dec1b441a66aa98c02f2d772397f6fada42b887873e4d3d8772103d913f
7
+ data.tar.gz: 3447ff2185d46f9327c6c5ccaf9892620ed73946317b67879074ad754e311c51d0b869077e9985da3e86d3b0b656324d05427d0a295c36ea894a7663cf6f262f
data/README.md CHANGED
@@ -1,13 +1,27 @@
1
1
 
2
- neo4apis is a ruby gem for building gems which import data into neo4j. Takes care of batching of queries for better import performance
2
+ ==Introduction==
3
+
4
+ neo4apis is a ruby gem for building objects which import data into neo4j. It takes care of batching of queries for better import performance and creating indexes for better query performance. It also uses MERGEs to make sure the same node/relationship isn't imported twice. neo4apis is for anybody who want to build a gem or even just an adapter in their application which encapsulates the logic of data import from some source. For examples see the drivers for [Twitter](https://github.com/neo4jrb/neo4apis-twitter) and [GitHub](https://github.com/neo4jrb/neo4apis-github)
3
5
 
4
6
  In the below example we assume that a variable `awesome_client` is passed in which allows us to make requests to the API. This may be, for example, provided by another gem.
5
7
 
8
+ ==To install==
9
+
10
+ `gem 'neo4apis'` in your Gemfile or `gem install neo4apis`
11
+
12
+ ==To use==
13
+
6
14
  ```ruby
7
15
  require 'neo4apis'
8
16
 
9
17
  module Neo4Apis
10
18
  class AwesomeSite < Base
19
+ # Adds a prefix to labels so that they become AwesomeSiteUser and AwesomeSiteWidget (optional)
20
+ prefix :AwesomeSite
21
+
22
+ # Number of queries which are built up until batch request to DB is made (optional, default = 500)
23
+ batch_size 2000
24
+
11
25
  uuid :User, :id
12
26
  uuid :Widget, :uuid
13
27
 
data/lib/neo4apis/base.rb CHANGED
@@ -5,11 +5,12 @@ module Neo4Apis
5
5
  UUID_FIELDS = {}
6
6
  NODE_PROXIES = {}
7
7
  IMPORTERS = {}
8
+ DEFAULT_BATCH_SIZE = 500
8
9
 
9
10
  attr_reader :options
10
11
 
11
12
  def initialize(neo4j_session, options = {})
12
- @buffer = QueryBuffer.new(neo4j_session, options[:flush_size] || self.class.default_flush_size)
13
+ @buffer = QueryBuffer.new(neo4j_session, options[:batch_size] || self.class.batch_size || DEFAULT_BATCH_SIZE)
13
14
  @options = options
14
15
 
15
16
  UUID_FIELDS.each do |label, uuid_field|
@@ -100,8 +101,14 @@ module Neo4Apis
100
101
  end
101
102
  end
102
103
 
103
- def self.default_flush_size
104
- 500
104
+ def self.batch_size(batch_size = nil)
105
+ if batch_size.is_a?(Integer)
106
+ @batch_size = batch_size
107
+ elsif batch_size.nil?
108
+ @batch_size
109
+ else
110
+ raise ArgumentError, "Invalid value for batch_size: #{batch_size.inspect}"
111
+ end
105
112
  end
106
113
 
107
114
  private
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.1.0'
6
+ s.version = '0.2.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.1.0
4
+ version: 0.2.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: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2014-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday