architect4r 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +53 -0
- data/Guardfile +10 -0
- data/License +20 -0
- data/README.md +62 -0
- data/Rakefile +40 -0
- data/ReleaseNotes.md +33 -0
- data/Roadmap.md +31 -0
- data/Specs.md +21 -0
- data/architect4r.gemspec +31 -0
- data/lib/architect4r.rb +66 -0
- data/lib/architect4r/adapters/carrier_wave.rb +64 -0
- data/lib/architect4r/core/configuration.rb +148 -0
- data/lib/architect4r/core/cypher_methods.rb +47 -0
- data/lib/architect4r/core/management_methods.rb +129 -0
- data/lib/architect4r/core/node_methods.rb +73 -0
- data/lib/architect4r/core/relationship_methods.rb +82 -0
- data/lib/architect4r/generic_node.rb +7 -0
- data/lib/architect4r/has_node.rb +80 -0
- data/lib/architect4r/instance_manager.rb +47 -0
- data/lib/architect4r/model/callbacks.rb +19 -0
- data/lib/architect4r/model/connection.rb +29 -0
- data/lib/architect4r/model/links_query_interface.rb +23 -0
- data/lib/architect4r/model/node.rb +117 -0
- data/lib/architect4r/model/persistency.rb +95 -0
- data/lib/architect4r/model/properties.rb +166 -0
- data/lib/architect4r/model/queries.rb +38 -0
- data/lib/architect4r/model/relationship.rb +105 -0
- data/lib/architect4r/model/relationships.rb +16 -0
- data/lib/architect4r/model/validations.rb +11 -0
- data/lib/architect4r/server.rb +96 -0
- data/lib/architect4r/version.rb +3 -0
- data/spec/architect4r_spec.rb +9 -0
- data/spec/core/configuration_spec.rb +54 -0
- data/spec/core/cypher_methods_spec.rb +29 -0
- data/spec/core/node_methods_spec.rb +47 -0
- data/spec/core/relationship_methods_spec.rb +92 -0
- data/spec/fixtures/architect4r.yml +21 -0
- data/spec/fixtures/graph.db.default/active_tx_log +1 -0
- data/spec/fixtures/graph.db.default/index/lucene-store.db +0 -0
- data/spec/fixtures/graph.db.default/index/lucene.log.1 +0 -0
- data/spec/fixtures/graph.db.default/index/lucene.log.active +0 -0
- data/spec/fixtures/graph.db.default/index/lucene.log.v0 +0 -0
- data/spec/fixtures/graph.db.default/index/lucene.log.v1 +0 -0
- data/spec/fixtures/graph.db.default/index/lucene.log.v2 +0 -0
- data/spec/fixtures/graph.db.default/lock +0 -0
- data/spec/fixtures/graph.db.default/messages.log +183 -0
- data/spec/fixtures/graph.db.default/neostore +0 -0
- data/spec/fixtures/graph.db.default/neostore.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.nodestore.db +0 -0
- data/spec/fixtures/graph.db.default/neostore.nodestore.db.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.arrays +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.arrays.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.index +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.index.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.index.keys +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.index.keys.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.strings +0 -0
- data/spec/fixtures/graph.db.default/neostore.propertystore.db.strings.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.relationshipstore.db +0 -0
- data/spec/fixtures/graph.db.default/neostore.relationshipstore.db.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.relationshiptypestore.db +0 -0
- data/spec/fixtures/graph.db.default/neostore.relationshiptypestore.db.id +0 -0
- data/spec/fixtures/graph.db.default/neostore.relationshiptypestore.db.names +0 -0
- data/spec/fixtures/graph.db.default/neostore.relationshiptypestore.db.names.id +0 -0
- data/spec/fixtures/graph.db.default/nioneo_logical.log.1 +0 -0
- data/spec/fixtures/graph.db.default/nioneo_logical.log.active +0 -0
- data/spec/fixtures/graph.db.default/tm_tx_log.1 +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/active_tx_log +1 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/messages.log +142 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.nodestore.db +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.nodestore.db.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.arrays +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.arrays.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.index +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.index.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.index.keys +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.index.keys.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.strings +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.propertystore.db.strings.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.relationshipstore.db +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.relationshipstore.db.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.relationshiptypestore.db +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.relationshiptypestore.db.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.relationshiptypestore.db.names +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/neostore.relationshiptypestore.db.names.id +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/nioneo_logical.log.active +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/nioneo_logical.log.v0 +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/nioneo_logical.log.v1 +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/nioneo_logical.log.v2 +0 -0
- data/spec/fixtures/graph.db.default/upgrade_backup/tm_tx_log.1 +0 -0
- data/spec/has_node_spec.rb +87 -0
- data/spec/model/links_query_interface_spec.rb +22 -0
- data/spec/model/links_spec.rb +26 -0
- data/spec/model/node_spec.rb +48 -0
- data/spec/model/persistency_spec.rb +98 -0
- data/spec/model/properties_spec.rb +165 -0
- data/spec/model/queries_spec.rb +50 -0
- data/spec/model/relationship_spec.rb +63 -0
- data/spec/model/validations_spec.rb +31 -0
- data/spec/server_spec.rb +33 -0
- data/spec/spec_helper.rb +115 -0
- metadata +377 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
architect4r (0.3.2)
|
5
|
+
activemodel (~> 3.0)
|
6
|
+
json (~> 1.5)
|
7
|
+
typhoeus (~> 0.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activemodel (3.1.1)
|
13
|
+
activesupport (= 3.1.1)
|
14
|
+
builder (~> 3.0.0)
|
15
|
+
i18n (~> 0.6)
|
16
|
+
activesupport (3.1.1)
|
17
|
+
multi_json (~> 1.0)
|
18
|
+
builder (3.0.0)
|
19
|
+
diff-lcs (1.1.3)
|
20
|
+
growl (1.0.3)
|
21
|
+
guard (0.8.7)
|
22
|
+
thor (~> 0.14.6)
|
23
|
+
guard-rspec (0.5.0)
|
24
|
+
guard (>= 0.8.4)
|
25
|
+
i18n (0.6.0)
|
26
|
+
json (1.6.1)
|
27
|
+
mime-types (1.17.1)
|
28
|
+
multi_json (1.0.3)
|
29
|
+
rake (0.9.2)
|
30
|
+
rb-fsevent (0.4.3.1)
|
31
|
+
rspec (2.7.0)
|
32
|
+
rspec-core (~> 2.7.0)
|
33
|
+
rspec-expectations (~> 2.7.0)
|
34
|
+
rspec-mocks (~> 2.7.0)
|
35
|
+
rspec-core (2.7.1)
|
36
|
+
rspec-expectations (2.7.0)
|
37
|
+
diff-lcs (~> 1.1.2)
|
38
|
+
rspec-mocks (2.7.0)
|
39
|
+
thor (0.14.6)
|
40
|
+
typhoeus (0.3.2)
|
41
|
+
mime-types
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
architect4r!
|
48
|
+
growl
|
49
|
+
guard
|
50
|
+
guard-rspec
|
51
|
+
rake
|
52
|
+
rb-fsevent
|
53
|
+
rspec
|
data/Guardfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
guard 'rspec' do
|
2
|
+
# Check for changes in classes
|
3
|
+
watch(%r{^lib/architect4r/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
4
|
+
|
5
|
+
# Check for changes in specs
|
6
|
+
watch(%r{^spec/.+_spec\.rb$})
|
7
|
+
|
8
|
+
# Check for changes in the spec helper
|
9
|
+
watch('spec/spec_helper.rb') { "spec" }
|
10
|
+
end
|
data/License
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Maximilian Schulz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Architect4r
|
2
|
+
|
3
|
+
Architect4r is intended as an easy ruby wrapper for the neo4j graph db
|
4
|
+
REST API. There are other solutions such as neo4j.rb if you are working
|
5
|
+
in a java environment or neography which provides another working wrapper
|
6
|
+
for the REST API.
|
7
|
+
|
8
|
+
Requirements
|
9
|
+
------------
|
10
|
+
|
11
|
+
You need a running neo4j installation.
|
12
|
+
|
13
|
+
Installation
|
14
|
+
------------
|
15
|
+
|
16
|
+
In oder to work with architect4r you have to install the gem by using
|
17
|
+
`gem install architect4r` or in case that you are using bundler, you can
|
18
|
+
add the following line to your _Gemfile_: `gem "architect4r"`.
|
19
|
+
|
20
|
+
Quick Start
|
21
|
+
-----------
|
22
|
+
|
23
|
+
# Class definition
|
24
|
+
class Instrument < Architect4r::Model::Node
|
25
|
+
# Properties
|
26
|
+
property :name, :cast_to => String, :localize => true
|
27
|
+
property :name, :cast_to => String, :localize => :de
|
28
|
+
|
29
|
+
# Validations
|
30
|
+
validates :name, :presence => true
|
31
|
+
end
|
32
|
+
|
33
|
+
# Interfacing with the I18n class
|
34
|
+
I18n.locale = :en
|
35
|
+
|
36
|
+
# Working with a record
|
37
|
+
instrument = Instrument.new
|
38
|
+
instrument.name = "Piano"
|
39
|
+
instrument.name(:de) = "Klavier"
|
40
|
+
instrument.valid?
|
41
|
+
instrument.save
|
42
|
+
|
43
|
+
# Updating attributes
|
44
|
+
instrument.update_attributes(params[:instrument])
|
45
|
+
|
46
|
+
# Finding records
|
47
|
+
Instrument.find_by_id(123)
|
48
|
+
|
49
|
+
class Fanship < Architect4r::Model::Relationship
|
50
|
+
# Properties
|
51
|
+
property :created_at, :cast_to => DateTime
|
52
|
+
property :reason, :cast_to => String
|
53
|
+
end
|
54
|
+
|
55
|
+
# Init a class based relationship
|
56
|
+
Fanship.new(@user, @instrument, { :reason => 'Because I like you' })
|
57
|
+
|
58
|
+
License
|
59
|
+
-------
|
60
|
+
|
61
|
+
Architect4r is copyright (c) 2011 Maximilian Schulz. It is free software,
|
62
|
+
and may be redistributed under the terms of the MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
# Add rspec tasks for testing
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new('spec')
|
6
|
+
|
7
|
+
# Load instance manager
|
8
|
+
require 'lib/architect4r/instance_manager'
|
9
|
+
|
10
|
+
# Setting up default tasks
|
11
|
+
desc "Run specs"
|
12
|
+
task :default => :spec
|
13
|
+
|
14
|
+
namespace :server do
|
15
|
+
|
16
|
+
current_path = File.dirname(__FILE__)
|
17
|
+
server_path = File.join(current_path, 'neo4j_server')
|
18
|
+
neo_manager = Architect4r::InstanceManager.new(server_path)
|
19
|
+
|
20
|
+
desc "Install test server"
|
21
|
+
task :install do
|
22
|
+
puts '--- not implemented'
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Stop the neo4j server"
|
26
|
+
task :start do
|
27
|
+
neo_manager.start
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Stop the neo4j server"
|
31
|
+
task :stop do
|
32
|
+
neo_manager.stop
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "Reset the test server"
|
36
|
+
task :reset do
|
37
|
+
neo_manager.reset_to_sample_data("#{current_path}/spec/fixtures/graph.db.default/")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
data/ReleaseNotes.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Release Notes
|
2
|
+
|
3
|
+
## v0.3.2
|
4
|
+
|
5
|
+
* Support for carrierwave file upload mechanism
|
6
|
+
|
7
|
+
## v0.3.1
|
8
|
+
|
9
|
+
* Sync with ActiveModel records
|
10
|
+
|
11
|
+
In order to use neo4j in combination with other databases, we provide a
|
12
|
+
small extension which allows you to keep a node in sync with another's
|
13
|
+
datastore record.
|
14
|
+
|
15
|
+
## v0.3
|
16
|
+
|
17
|
+
This release marks the first public release. So I wont get into length
|
18
|
+
with its changes and new features. Let's just say it allows you to create
|
19
|
+
nodes and relationships between nodes. That's it!
|
20
|
+
|
21
|
+
* Nodes (create, update, destroy)
|
22
|
+
* Relationships (create, update, destroy)
|
23
|
+
* Querying neo4j by using cypher query language
|
24
|
+
* Callbacks and validations for nodes and relationships
|
25
|
+
|
26
|
+
## v0.2
|
27
|
+
|
28
|
+
Another internal release which was not ready for development or production.
|
29
|
+
_Please do not use it or try working with it!_ ;)
|
30
|
+
|
31
|
+
## v0.1
|
32
|
+
|
33
|
+
Some initial internal release which was very buggy and limited on the features.
|
data/Roadmap.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Roadmap
|
2
|
+
|
3
|
+
_Check the release notes for info on previous versions_
|
4
|
+
|
5
|
+
|
6
|
+
There is no real roadmap for architect4r, as this project is only used in
|
7
|
+
a single project so far. If there is anything you miss, either fork the
|
8
|
+
project, implement the feature and send a pull request, or submit an issue.
|
9
|
+
|
10
|
+
The following items are kinda planned to be integrated in the future:
|
11
|
+
|
12
|
+
* Give the cypher plugin some more love
|
13
|
+
* Add more default queries
|
14
|
+
* Add tracking of dirty attributes
|
15
|
+
* Make it compatible to file uploaders such as paperclip and carrierwave
|
16
|
+
* Make it compatible to search engines such as sunspot, elastic search, sphinx, …
|
17
|
+
* Rake tasks for installing neo4j
|
18
|
+
* Rake tasks for test setup
|
19
|
+
* Versioning of nodes (update node but create a linked node with the old properties)
|
20
|
+
* Improve documentation
|
21
|
+
* Improve test cases
|
22
|
+
|
23
|
+
And there are a few features which might be integrated, but are not yet really planned:
|
24
|
+
|
25
|
+
* Accessible relationships as you know it from active record
|
26
|
+
* Support for indexes (nodes and relations)
|
27
|
+
* Add more finders by using indexes
|
28
|
+
* Add auto indexing of node properties / nodes (not neo4j auto indexing)
|
29
|
+
* Add basic authentication
|
30
|
+
* Add digest authentication
|
31
|
+
* Facilitate hydra's concurrency model
|
data/Specs.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Specs
|
2
|
+
|
3
|
+
Some code which might define the future interface of the gem.
|
4
|
+
|
5
|
+
# Finding records
|
6
|
+
Instrument.all
|
7
|
+
Instrument.find_by_name("Piano")
|
8
|
+
Instrument.find_by_name("Klavier", :de)
|
9
|
+
Instrument.find_by_cypher("start cat=(123) match (cat)--(x) return x limit 2")
|
10
|
+
|
11
|
+
# Filter associations by relationship type (:incoming, :outgoing, :all)
|
12
|
+
instrument.links(:outgoing)
|
13
|
+
|
14
|
+
# Query by model or type
|
15
|
+
@user.links(:all, Fanship, 'studies')
|
16
|
+
|
17
|
+
# Create a custom relationship
|
18
|
+
relationship = Architect4r::Model::Relationship.create(start_node, end_note, 'CustomType', { :active => true })
|
19
|
+
# or
|
20
|
+
instrument.links(:incoming).create(:category, @other_node, { :created_at => DateTime.new, :active => true })
|
21
|
+
instrument.links(:incoming).create(CategoryRelation, @other_node, { :created_at => DateTime.new, :active => true })
|
data/architect4r.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "architect4r/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "architect4r"
|
7
|
+
s.version = Architect4r::VERSION
|
8
|
+
s.authors = ["Maximilian Schulz"]
|
9
|
+
s.email = ["m.schulz@kulturfluss.de"]
|
10
|
+
s.homepage = "http://www.kulturfluss.de/"
|
11
|
+
s.summary = %q{A gem for working with the neo4j REST interface.}
|
12
|
+
s.description = %q{This gem is intended for making a neo4j graph db accessible by providing a ruby wrapper for the REST API.}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# Production dependencies
|
20
|
+
s.add_runtime_dependency %q<activemodel>, "~> 3.0"
|
21
|
+
s.add_runtime_dependency %q<json>, "~> 1.5"
|
22
|
+
s.add_runtime_dependency %q<typhoeus>, "~> 0.2"
|
23
|
+
|
24
|
+
# Development dependencies
|
25
|
+
s.add_development_dependency "rake"
|
26
|
+
s.add_development_dependency "rspec"
|
27
|
+
s.add_development_dependency "guard"
|
28
|
+
s.add_development_dependency "guard-rspec"
|
29
|
+
s.add_development_dependency "rb-fsevent"
|
30
|
+
s.add_development_dependency "growl"
|
31
|
+
end
|
data/lib/architect4r.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
#
|
2
|
+
# Gem management
|
3
|
+
#
|
4
|
+
require 'architect4r/version'
|
5
|
+
|
6
|
+
#
|
7
|
+
# Extensions
|
8
|
+
#
|
9
|
+
require 'active_model'
|
10
|
+
require 'active_support'
|
11
|
+
require 'active_support/core_ext'
|
12
|
+
#require 'architect4r/extensions/object'
|
13
|
+
|
14
|
+
#
|
15
|
+
# Core modules
|
16
|
+
#
|
17
|
+
require 'architect4r/core/configuration'
|
18
|
+
require 'architect4r/core/cypher_methods'
|
19
|
+
require 'architect4r/core/node_methods'
|
20
|
+
require 'architect4r/core/relationship_methods'
|
21
|
+
|
22
|
+
#
|
23
|
+
# Basic server interaction
|
24
|
+
#
|
25
|
+
require 'architect4r/server'
|
26
|
+
|
27
|
+
#
|
28
|
+
# Model features
|
29
|
+
#
|
30
|
+
require 'architect4r/model/connection'
|
31
|
+
require 'architect4r/model/properties'
|
32
|
+
require 'architect4r/model/persistency'
|
33
|
+
require 'architect4r/model/queries'
|
34
|
+
require 'architect4r/model/validations'
|
35
|
+
require 'architect4r/model/callbacks'
|
36
|
+
require 'architect4r/model/links_query_interface'
|
37
|
+
require 'architect4r/model/relationships'
|
38
|
+
require 'architect4r/model/node'
|
39
|
+
require 'architect4r/model/relationship'
|
40
|
+
|
41
|
+
#
|
42
|
+
# Generic items
|
43
|
+
#
|
44
|
+
require 'architect4r/generic_node'
|
45
|
+
|
46
|
+
#
|
47
|
+
# Support for multi database environments
|
48
|
+
#
|
49
|
+
require 'architect4r/has_node'
|
50
|
+
# Auto load the extension when active record is used
|
51
|
+
if defined?(ActiveRecord::Base)
|
52
|
+
ActiveRecord::Base.send(:include, Architect4r::HasNode)
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# The namespace
|
57
|
+
#
|
58
|
+
module Architect4r
|
59
|
+
|
60
|
+
def self.version
|
61
|
+
"Architect4r version #{Architect4r::VERSION}"
|
62
|
+
end
|
63
|
+
|
64
|
+
class InvalidCypherQuery < SyntaxError; end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require "architect4r"
|
2
|
+
require "carrierwave"
|
3
|
+
require "carrierwave/validations/active_model"
|
4
|
+
|
5
|
+
# In order to use this class include this file in your project
|
6
|
+
# require 'architect4r/adapters/carrier_wave'
|
7
|
+
#
|
8
|
+
module Architect4r
|
9
|
+
module Adapters
|
10
|
+
module CarrierWave
|
11
|
+
# Import default implementation
|
12
|
+
include ::CarrierWave::Mount
|
13
|
+
|
14
|
+
def mount_uploader(column, uploader = nil, options = {}, &block)
|
15
|
+
property "#{column}_data", :cast_to => String
|
16
|
+
|
17
|
+
# Init by calling default initializer
|
18
|
+
super
|
19
|
+
|
20
|
+
# Enable validations
|
21
|
+
include ::CarrierWave::Validations::ActiveModel
|
22
|
+
validates_integrity_of column if uploader_option(column.to_sym, :validate_integrity)
|
23
|
+
validates_processing_of column if uploader_option(column.to_sym, :validate_processing)
|
24
|
+
|
25
|
+
# Add hooks
|
26
|
+
after_save :"store_#{column}!"
|
27
|
+
before_save :"write_#{column}_identifier"
|
28
|
+
after_destroy :"remove_#{column}!"
|
29
|
+
|
30
|
+
# These hooks cannot be used until dirty tracking is implemented
|
31
|
+
#before_update :"store_previous_model_for_#{column}"
|
32
|
+
#after_save :"remove_previously_stored_#{column}"
|
33
|
+
|
34
|
+
class_eval <<-RUBY, __FILE__, __LINE__+1
|
35
|
+
|
36
|
+
public
|
37
|
+
|
38
|
+
def read_uploader(column)
|
39
|
+
self.send("#{column}_data")
|
40
|
+
end
|
41
|
+
|
42
|
+
def write_uploader(column, identifier)
|
43
|
+
self.send("#{column}_data=", identifier)
|
44
|
+
end
|
45
|
+
|
46
|
+
RUBY
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Add this to all nodes and relationships (funky isn't it?)
|
54
|
+
module Architect4r
|
55
|
+
module Model
|
56
|
+
class Node
|
57
|
+
extend Architect4r::Adapters::CarrierWave
|
58
|
+
end
|
59
|
+
|
60
|
+
class Relationship
|
61
|
+
extend Architect4r::Adapters::CarrierWave
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|