Code Monkey home page Code Monkey logo

architect4r's Introduction

Architect4r

Architect4r is intended as an easy ruby wrapper for the neo4j graph db REST API. There are other solutions such as neo4j.rb if you are working in a java environment or neography which provides another working wrapper for the REST API. Both solutions are far more feature complete and allow you to do pretty advanced queries on the graph.

Architect4r is trying to go another route. Instead of using the native graph traversal engine it requires you to write your queries in recently implemented cypher query language. The language is well documented at the official neo4j documentation (http://docs.neo4j.org/chunked/milestone/). Just that you know what you are dealing with… a little example:

start s=node(1) match s-[:friends]-d return d order by d.name skip 0 limit 20

But please read the docs for more info.

Requirements

You need a running neo4j installation.

Installation

In oder to work with architect4r you have to install the gem by using gem install architect4r or in case that you are using bundler, you can add the following line to your Gemfile: gem "architect4r".

Quick Start

# Class definition
class Instrument < Architect4r::Model::Node
  # Properties
  property :name, :cast_to => String, :localize => true
  property :name, :cast_to => String, :localize => :de
  timestamps!
  
  # Validations
  validates :name, :presence => true
end

# Interfacing with the I18n class
I18n.locale = :en

# Working with a record
instrument = Instrument.new
instrument.name = "Piano"
instrument.name(:de) = "Klavier"
instrument.valid?
instrument.save

# Updating attributes
instrument.update_attributes(params[:instrument])

# Finding records
Instrument.find_by_id(123)

class Fanship < Architect4r::Model::Relationship
  # Properties
  property :created_at, :cast_to => DateTime
  property :reason, :cast_to => String
end

# Init a class based relationship
Fanship.new(@user, @instrument, { :reason => 'Because I like you' })

Logging

In order to log the debug output from architect4r to a logfile, just override the default logger instance. If you are using rails, you might wanna add this to an initializer:

# Create a logger instance
file = File.open('log/output.log', File::WRONLY | File::APPEND)
logger = Logger.new(file, 'daily')
logger.level = Logger::DEBUG

# Set architect4r logger
Architect4r.logger = logger

Development

# Clone the repo and cd into it, then:
bundle install
bundle exec rake server:install
bundle exec rspec spec/

You can also use guard to run the specs continuously during development: bundle exec guard.

License

Architect4r is copyright (c) 2011 Maximilian Schulz. It is free software, and may be redistributed under the terms of the MIT License.

architect4r's People

Contributors

namxam avatar dnagir avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.