neoon 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +101 -0
- data/Rakefile +7 -0
- data/lib/neoon/client/connection.rb +46 -0
- data/lib/neoon/client/indexing.rb +25 -0
- data/lib/neoon/client/request.rb +46 -0
- data/lib/neoon/config.rb +9 -0
- data/lib/neoon/model/config.rb +19 -0
- data/lib/neoon/model/schema.rb +39 -0
- data/lib/neoon/model/service.rb +69 -0
- data/lib/neoon/node.rb +18 -0
- data/lib/neoon/railtie.rb +26 -0
- data/lib/neoon/railties/database.rake +2 -0
- data/lib/neoon/version.rb +3 -0
- data/lib/neoon.rb +40 -0
- data/lib/rails/neoon.rb +30 -0
- data/neoon.gemspec +33 -0
- data/spec/app/models/topic.rb +11 -0
- data/spec/neoon_spec.rb +45 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/database.yml +13 -0
- data/spec/support/schema.rb +7 -0
- metadata +187 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 08ac0ff644d4961a328938854c086db4a7d35689
|
4
|
+
data.tar.gz: 54aa3709453cecc5d1533036418812868547affe
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84a8aaca5d0e2a78c120517f29aba0ad0a63d9b8c4e818a4e5a9fbb5239f02d0611ce2d5d92a544e1fc7b99e41fbc8d2f8c6e55378394b191f818f81a8621494
|
7
|
+
data.tar.gz: 50662379431fe64b80fbd9d64930060d1a582adb737a52bddb92f9135b2c9880d53d3f0cff493f80492fafdfe29e0d60bb479799f25193f7389c9e3362c6070e
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format documentation --color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Amr Tamimi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
**The gem is not Production Ready™.**
|
2
|
+
|
3
|
+
# Neoon [![Build Status](https://travis-ci.org/amrnt/neoon.png?branch=master)](https://travis-ci.org/amrnt/neoon)
|
4
|
+
|
5
|
+
A simple Ruby wrapper for Neo4j with focus on Cypher and the features of Neo4j 2.0
|
6
|
+
|
7
|
+
#### Inspired by [Neoid](https://github.com/elado/neoid)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
gem 'neoon'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install neoon
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
First you have to initialize a client:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
ENV["NEO4J_URL"] ||= "http://localhost:7474"
|
29
|
+
|
30
|
+
$neo = Neoon.client ENV["NEO4J_URL"]
|
31
|
+
```
|
32
|
+
|
33
|
+
Set configuration:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
Neoon.configure do |config|
|
37
|
+
config.preload_models = true # (default: false) This will load your models — so to update the indexes at the (Rails) boot
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
To query using Cypher:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
$neo.q("START node=node(*) RETURN node")
|
45
|
+
```
|
46
|
+
|
47
|
+
To your ActiveRecord model, initialize Neoon like so (with example of using properties/index):
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class Topic < ActiveRecord::Base
|
51
|
+
|
52
|
+
include Neoon::Node
|
53
|
+
|
54
|
+
neoon do |c|
|
55
|
+
c.property :name
|
56
|
+
c.property :slug, :index => true do
|
57
|
+
"#{self.id}-#{self.name.underscore}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
### Indexing
|
65
|
+
|
66
|
+
This will be used internally to auto indexing the model depends on what described in the neoon model config.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
Neoon.db.list 'Topic' #=> ["slug"]
|
70
|
+
|
71
|
+
Neoon.db.create 'Topic', [:name, ...]
|
72
|
+
|
73
|
+
Neoon.db.drop 'Topic' [:name, ...]
|
74
|
+
|
75
|
+
# Alternativly
|
76
|
+
|
77
|
+
Topic.neo_index_list #=> ["slug"]
|
78
|
+
|
79
|
+
Topic.neo_index_create [:name, ...]
|
80
|
+
|
81
|
+
Topic.neo_index_drop [:name, ...]
|
82
|
+
|
83
|
+
# Sync the indexes you described in model config. It returns the indexed fields.
|
84
|
+
# Remember, this will be called on each model on the boot if preload_models set to true.
|
85
|
+
Topic.neo_index_update #=> ["slug"]
|
86
|
+
```
|
87
|
+
|
88
|
+
**The gem is still at heavy development. More to come!**
|
89
|
+
|
90
|
+
## TODO
|
91
|
+
|
92
|
+
1. ADD TESTS
|
93
|
+
2. ..
|
94
|
+
|
95
|
+
## Contributing
|
96
|
+
|
97
|
+
1. Fork it
|
98
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
99
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
100
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
101
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module Neoon
|
2
|
+
module Client
|
3
|
+
class Connection
|
4
|
+
|
5
|
+
attr_reader :connection
|
6
|
+
|
7
|
+
def initialize(url)
|
8
|
+
@uri = URI.parse(url)
|
9
|
+
end_point = "#{@uri.scheme}://#{@uri.host}:#{@uri.port}#{@uri.path}"
|
10
|
+
@connection ||= Faraday.new(end_point, connection_options.merge(:builder => middleware))
|
11
|
+
@connection.basic_auth(@uri.user, @uri.password) if @uri.user && @uri.password
|
12
|
+
end
|
13
|
+
|
14
|
+
include Request
|
15
|
+
include Indexing
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def connection_options
|
20
|
+
@connection_options ||= {
|
21
|
+
:headers => {
|
22
|
+
:accept => 'application/json',
|
23
|
+
:content_type => 'application/json; charset=UTF-8',
|
24
|
+
:x_stream => 'true',
|
25
|
+
:user_agent => ['Neoon', Neoon::VERSION].join(' ')
|
26
|
+
},
|
27
|
+
:request => {
|
28
|
+
:open_timeout => 5,
|
29
|
+
:timeout => 10,
|
30
|
+
},
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def middleware
|
35
|
+
@middleware ||= Faraday::Builder.new do |builder|
|
36
|
+
builder.use FaradayMiddleware::EncodeJson
|
37
|
+
builder.use FaradayMiddleware::Mashify
|
38
|
+
builder.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
|
39
|
+
|
40
|
+
builder.adapter Faraday.default_adapter
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Neoon
|
2
|
+
module Client
|
3
|
+
module Indexing
|
4
|
+
|
5
|
+
def list(label)
|
6
|
+
Neoon.db.get("/schema/index/#{label}")
|
7
|
+
.map{|f| f.send("property-keys")}.flatten.map(&:to_s).sort
|
8
|
+
end
|
9
|
+
|
10
|
+
def create(label, keys = [])
|
11
|
+
keys.each do |key|
|
12
|
+
Neoon.db.cypher("CREATE INDEX ON :#{label}(#{key.to_s.downcase})")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def drop(label, keys = [])
|
17
|
+
keys.each do |key|
|
18
|
+
Neoon.db.cypher("DROP INDEX ON :#{label}(#{key.to_s.downcase})")
|
19
|
+
end
|
20
|
+
neo_index_list
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'faraday_middleware'
|
2
|
+
|
3
|
+
module Neoon
|
4
|
+
module Client
|
5
|
+
module Request
|
6
|
+
|
7
|
+
def cypher(query, parameters = {})
|
8
|
+
options = { :query => query, :params => parameters }
|
9
|
+
post('/cypher', options)
|
10
|
+
end
|
11
|
+
alias_method :q, :cypher
|
12
|
+
|
13
|
+
def get(path, options={})
|
14
|
+
make_request(:get, '/db/data' + path, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
def post(path, options={})
|
18
|
+
make_request(:post, '/db/data' + path, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def put(path, options={})
|
22
|
+
make_request(:put, '/db/data' + path, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def delete(path, options={})
|
26
|
+
make_request(:delete, '/db/data' + path, options)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def make_request(method, path, options)
|
32
|
+
response = connection.send(method) do |request|
|
33
|
+
case method
|
34
|
+
when :get, :delete
|
35
|
+
request.url(path, options)
|
36
|
+
when :post, :put
|
37
|
+
request.path = path
|
38
|
+
request.body = options unless options.empty?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
response.body
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/neoon/config.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
module Neoon
|
2
|
+
module Model
|
3
|
+
class Config
|
4
|
+
|
5
|
+
def initialize(klass)
|
6
|
+
@klass = klass
|
7
|
+
end
|
8
|
+
|
9
|
+
def properties
|
10
|
+
@properties ||= {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def property(name, *opts, &block)
|
14
|
+
self.properties[name] = {:block => block}.merge(opts.first || {}).reject { |k, v| v.nil? }
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Neoon
|
2
|
+
module Model
|
3
|
+
module Schema
|
4
|
+
|
5
|
+
def neo_index_list
|
6
|
+
Neoon.db.list self.name
|
7
|
+
end
|
8
|
+
|
9
|
+
def neo_index_create keys = []
|
10
|
+
Neoon.db.create self.name, keys
|
11
|
+
end
|
12
|
+
|
13
|
+
def neo_index_drop keys = []
|
14
|
+
Neoon.db.drop self.name, keys
|
15
|
+
end
|
16
|
+
|
17
|
+
def neo_index_update
|
18
|
+
cl = neo_index_list
|
19
|
+
ck = neo_node_keys_to_index
|
20
|
+
return cl if (cl) == (ck)
|
21
|
+
|
22
|
+
neo_index_create(ck - cl) unless (ck - cl).empty?
|
23
|
+
neo_index_drop(cl - ck) unless (cl - ck).empty?
|
24
|
+
neo_index_list
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def neo_model_props
|
30
|
+
self.neo_model_config.properties
|
31
|
+
end
|
32
|
+
|
33
|
+
def neo_node_keys_to_index
|
34
|
+
neo_model_props.select{ |k, v| v[:index]==true }.keys.map(&:to_s).sort
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Neoon
|
2
|
+
module Model
|
3
|
+
module Service
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
attr_reader :neo_model_config
|
7
|
+
|
8
|
+
def neo_model_config
|
9
|
+
@neo_model_config ||= Neoon::Model::Config.new(self)
|
10
|
+
end
|
11
|
+
|
12
|
+
def neoon(opts = {})
|
13
|
+
yield(neo_model_config) if block_given?
|
14
|
+
|
15
|
+
opts.each do |key, value|
|
16
|
+
raise "No such option #{key} for #{self.name} model" unless neo_model_config.respond_to?("#{key}=")
|
17
|
+
neo_model_config.send("#{key}=", value)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module InstanceMethods
|
23
|
+
def neo_node_props
|
24
|
+
neo_node.merge({ :db_id => self.id })
|
25
|
+
end
|
26
|
+
|
27
|
+
def neo_save
|
28
|
+
cypher_query = <<-CYPHER
|
29
|
+
MERGE (node:#{self.class.name} { db_id: #{self.id} })
|
30
|
+
ON CREATE node SET node = {props}
|
31
|
+
ON MATCH node SET node = {props}
|
32
|
+
RETURN node
|
33
|
+
CYPHER
|
34
|
+
Neoon.db.q(cypher_query, { :props => neo_node_props })
|
35
|
+
end
|
36
|
+
|
37
|
+
def neo_destroy
|
38
|
+
cypher_query = <<-CYPHER
|
39
|
+
CYPHER
|
40
|
+
Neoon.db.q(cypher_query)
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def neo_node
|
46
|
+
return {} unless self.class.neo_model_props
|
47
|
+
hash = self.class.neo_model_props.inject({}) do |all, (field, block)|
|
48
|
+
all[field] = if block[:block]
|
49
|
+
instance_eval(&block[:block])
|
50
|
+
else
|
51
|
+
self.send(field) rescue (raise "No field #{field} for #{self.class.name}")
|
52
|
+
end
|
53
|
+
all
|
54
|
+
end
|
55
|
+
hash.reject { |k, v| v.nil? }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.included(receiver)
|
60
|
+
receiver.extend ClassMethods
|
61
|
+
receiver.extend Schema
|
62
|
+
receiver.send :include, InstanceMethods
|
63
|
+
|
64
|
+
receiver.after_save :neo_save
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/neoon/node.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Neoon
|
2
|
+
module Node
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module InstanceMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.included(receiver)
|
11
|
+
receiver.send :include, Model::Service
|
12
|
+
receiver.extend ClassMethods
|
13
|
+
receiver.send :include, InstanceMethods
|
14
|
+
Neoon.config.models << receiver
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'rails/neoon'
|
3
|
+
|
4
|
+
module Rails
|
5
|
+
module Neoon
|
6
|
+
class Railtie < ::Rails::Railtie
|
7
|
+
|
8
|
+
rake_tasks do
|
9
|
+
load "neoon/railties/database.rake"
|
10
|
+
end
|
11
|
+
|
12
|
+
initializer "neoon.neo_index_update" do
|
13
|
+
config.after_initialize do
|
14
|
+
::Neoon.config.models.each(&:neo_index_update)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer "neoon.preload_models" do |app|
|
19
|
+
config.to_prepare do
|
20
|
+
Rails::Neoon.preload_models(app)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/neoon.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
|
3
|
+
require 'neoon/version'
|
4
|
+
require 'neoon/config'
|
5
|
+
require 'neoon/client/request'
|
6
|
+
require 'neoon/client/indexing'
|
7
|
+
require 'neoon/client/connection'
|
8
|
+
|
9
|
+
require 'neoon/model/config'
|
10
|
+
require 'neoon/model/schema'
|
11
|
+
require 'neoon/model/service'
|
12
|
+
require 'neoon/node'
|
13
|
+
|
14
|
+
if defined?(Rails)
|
15
|
+
require 'neoon/railtie'
|
16
|
+
end
|
17
|
+
|
18
|
+
module Neoon
|
19
|
+
|
20
|
+
class << self
|
21
|
+
attr_reader :db
|
22
|
+
|
23
|
+
def client(url)
|
24
|
+
@db ||= Client::Connection.new url
|
25
|
+
end
|
26
|
+
|
27
|
+
def config
|
28
|
+
@config ||= begin
|
29
|
+
config = Neoon::Config.new
|
30
|
+
config.preload_models = false
|
31
|
+
config
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def configure
|
36
|
+
yield config
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/lib/rails/neoon.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Rails
|
2
|
+
module Neoon
|
3
|
+
extend self
|
4
|
+
|
5
|
+
def load_models(models)
|
6
|
+
models.each do |path|
|
7
|
+
files = Dir.glob("#{path}/**/*.rb")
|
8
|
+
files.sort.each do |file|
|
9
|
+
load_model(file.gsub("#{path}/" , "").gsub(".rb", ""))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def preload_models(app)
|
15
|
+
models = app.config.paths["app/models"]
|
16
|
+
load_models(models) if ::Neoon.config.preload_models
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def load_model(file)
|
22
|
+
begin
|
23
|
+
require_dependency(file)
|
24
|
+
rescue Exception => e
|
25
|
+
puts e.message
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
data/neoon.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'neoon/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'neoon'
|
9
|
+
spec.version = Neoon::VERSION
|
10
|
+
spec.authors = ['Amr Tamimi']
|
11
|
+
spec.email = ['amrnt0@gmail.com']
|
12
|
+
spec.description = 'A simple Ruby wrapper for Neo4j with focus on Cypher'
|
13
|
+
spec.summary = 'A simple Ruby wrapper for Neo4j with focus on Cypher'
|
14
|
+
spec.homepage = 'https://github.com/amrnt/neoon'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.required_ruby_version = ">= 1.9"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'faraday'
|
25
|
+
spec.add_runtime_dependency 'faraday_middleware'
|
26
|
+
spec.add_runtime_dependency 'multi_json'
|
27
|
+
spec.add_runtime_dependency 'hashie'
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
30
|
+
spec.add_development_dependency 'rake'
|
31
|
+
spec.add_development_dependency 'activerecord'
|
32
|
+
spec.add_development_dependency 'rspec'
|
33
|
+
end
|
data/spec/neoon_spec.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Neoon do
|
4
|
+
|
5
|
+
describe ".config" do
|
6
|
+
|
7
|
+
context "no block given" do
|
8
|
+
it "returns the config singleton" do
|
9
|
+
Neoon.config.should eq Neoon::config
|
10
|
+
end
|
11
|
+
|
12
|
+
it "returns config.preload_models false" do
|
13
|
+
Neoon.config.preload_models.should be_false
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have no model" do
|
17
|
+
Neoon.config.models.should be_empty
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with block given" do
|
22
|
+
before do
|
23
|
+
Neoon.configure do |c|
|
24
|
+
c.preload_models = true
|
25
|
+
end
|
26
|
+
require 'app/models/topic' # fake loading a model
|
27
|
+
end
|
28
|
+
|
29
|
+
after do
|
30
|
+
Neoon.configure do |c|
|
31
|
+
c.preload_models = false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns config.preload_models true" do
|
36
|
+
Neoon.config.preload_models.should be_true
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have models" do
|
40
|
+
Neoon.config.models.should_not be_empty
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'neoon'
|
2
|
+
require 'active_record'
|
3
|
+
|
4
|
+
ENV["NEO4J_URL"] ||= "http://localhost:7474"
|
5
|
+
$neo = Neoon.client(ENV["NEO4J_URL"])
|
6
|
+
|
7
|
+
ActiveRecord::Base.configurations = YAML::load(IO.read(File.join(File.dirname(__FILE__), 'support/database.yml')))
|
8
|
+
if defined?(JRUBY_VERSION)
|
9
|
+
ActiveRecord::Base.establish_connection('jruby')
|
10
|
+
else
|
11
|
+
ActiveRecord::Base.establish_connection('ruby')
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'support/schema'
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.mock_with :rspec
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: neoon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Amr Tamimi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: multi_json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: hashie
|
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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activerecord
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: A simple Ruby wrapper for Neo4j with focus on Cypher
|
126
|
+
email:
|
127
|
+
- amrnt0@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- .gitignore
|
133
|
+
- .rspec
|
134
|
+
- .travis.yml
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- lib/neoon.rb
|
140
|
+
- lib/neoon/client/connection.rb
|
141
|
+
- lib/neoon/client/indexing.rb
|
142
|
+
- lib/neoon/client/request.rb
|
143
|
+
- lib/neoon/config.rb
|
144
|
+
- lib/neoon/model/config.rb
|
145
|
+
- lib/neoon/model/schema.rb
|
146
|
+
- lib/neoon/model/service.rb
|
147
|
+
- lib/neoon/node.rb
|
148
|
+
- lib/neoon/railtie.rb
|
149
|
+
- lib/neoon/railties/database.rake
|
150
|
+
- lib/neoon/version.rb
|
151
|
+
- lib/rails/neoon.rb
|
152
|
+
- neoon.gemspec
|
153
|
+
- spec/app/models/topic.rb
|
154
|
+
- spec/neoon_spec.rb
|
155
|
+
- spec/spec_helper.rb
|
156
|
+
- spec/support/database.yml
|
157
|
+
- spec/support/schema.rb
|
158
|
+
homepage: https://github.com/amrnt/neoon
|
159
|
+
licenses:
|
160
|
+
- MIT
|
161
|
+
metadata: {}
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - '>='
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '1.9'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - '>='
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 2.0.3
|
179
|
+
signing_key:
|
180
|
+
specification_version: 4
|
181
|
+
summary: A simple Ruby wrapper for Neo4j with focus on Cypher
|
182
|
+
test_files:
|
183
|
+
- spec/app/models/topic.rb
|
184
|
+
- spec/neoon_spec.rb
|
185
|
+
- spec/spec_helper.rb
|
186
|
+
- spec/support/database.yml
|
187
|
+
- spec/support/schema.rb
|