neo4j 3.0.0.alpha.2 → 3.0.0.alpha.3

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: 3106c4da4e5d9b64e6532db51a5c8f9952ac5021
4
- data.tar.gz: 90d7e176d183c6a4cbcb0599af69da46b828610c
3
+ metadata.gz: 7f3c1c35ef38235d2f240757530f1fec08473cc8
4
+ data.tar.gz: a0e24982bc743984f10a702d8933be694c9c2adf
5
5
  SHA512:
6
- metadata.gz: 1dcb5b39e8e3d4298224c6cb2a7915724bf3844e52dba70796429394525abdffde42fcf0331ebadddb27154293640ee570cc3c85e8adef0b9f6cd20f11dda28c
7
- data.tar.gz: ff3c1edf2057a71eadcfa0ada92dd38de54a07c7d66d6bfa62453cb25afae551da6faec8c52a6c24d4c3923a821013dd6d28afb323a6ac159a6650c8e888c785
6
+ metadata.gz: ee0818fd0db7f265ab529f0bf8792c862cec09daa137aa340f3b0f009d419e664c53c21541775be7c883dc66e29b016a360949a45eadffefce7966d54a9153d0
7
+ data.tar.gz: f37ed9996c2d068663e574887bf29828a29d9b9250144006701d14e4bc17b64259be36bf96c0ec4ca6046a52ed81d577b2300bdfc7f46629e73825bfec28af1b
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ == 3.0.0.alpha.3
2
+ * Support for rails scaffolds
3
+ * Support for created_at and updated_at (#305)
4
+ * Support for ability to select a session to use per model (#299)
5
+ * BugFix: updating a model should not clear out old properties (#296)
6
+
1
7
  == 3.0.0.alpha.2
2
8
  * Support for both embedded (only JRuby) and server API (runs on MRI Ruby !)
3
9
  * Simple Rails app now work
data/Gemfile CHANGED
@@ -4,6 +4,8 @@ gemspec
4
4
 
5
5
  # gem 'neo4j-core', :path => '../neo4j-core'
6
6
 
7
+ gem 'coveralls', require: false
8
+
7
9
  group 'development' do
8
10
  gem 'os' # for neo4j-server rake task
9
11
  gem 'rake'
@@ -12,4 +14,5 @@ end
12
14
 
13
15
  group 'test' do
14
16
  gem "rspec"
17
+ gem "its"
15
18
  end
data/README.md CHANGED
@@ -1,12 +1,17 @@
1
- # Welcome to Neo4j.rb [![Build Status](https://secure.travis-ci.org/andreasronge/neo4j.png?branch=master)](http://travis-ci.org/andreasronge/neo4j) [![Dependency Status](https://gemnasium.com/andreasronge/neo4j.png)](https://gemnasium.com/andreasronge/neo4j)
2
- /Users/andreasronge/projects/neo4j-core/lib/neo4j-wrapper/delegates.rb
1
+ # Welcome to Neo4j.rb [![Build Status](https://secure.travis-ci.org/andreasronge/neo4j.png?branch=master)](http://travis-ci.org/andreasronge/neo4j) [![Coverage Status](https://coveralls.io/repos/andreasronge/neo4j/badge.png)](https://coveralls.io/r/andreasronge/neo4j) [![Code Climate](https://codeclimate.com/github/andreasronge/neo4j.png)](https://codeclimate.com/github/andreasronge/neo4j)
2
+
3
3
  Neo4j.rb is a graph database for Ruby (and JRuby)
4
4
 
5
5
  ## Version 3.0
6
6
 
7
+ Unstable !
8
+
7
9
  * Wiki: https://github.com/andreasronge/neo4j/wiki/Neo4j-v3
8
10
  * Example: https://github.com/andreasronge/neo4j/tree/3.0/example/blog
9
11
 
12
+ ## Version 2.x
13
+
14
+ This is the stable version, see https://github.com/andreasronge/neo4j/tree/2.x
10
15
 
11
16
  ## Contributing
12
17
 
@@ -16,6 +16,7 @@ require 'active_support/core_ext/class/attribute.rb'
16
16
 
17
17
  require 'active_attr'
18
18
  require 'neo4j/wrapper'
19
+ require 'neo4j/type_converters'
19
20
  require "neo4j/active_node/labels"
20
21
  require 'neo4j/active_node/identity'
21
22
  require 'neo4j/active_node/callbacks'
@@ -28,3 +29,10 @@ require 'neo4j/active_node/has_n'
28
29
  require 'neo4j/active_node/has_n/decl_rel'
29
30
  require 'neo4j/active_node/has_n/nodes'
30
31
  require 'neo4j/active_node'
32
+
33
+ if defined? Rails::Generators
34
+ # TODO, not sure this is the correct way of adding rails generators
35
+ # See https://github.com/andreasronge/neo4j/blob/gh-pages/neo4j.rb
36
+ # It is required from the rails config/application file
37
+ require 'rails/generators/neo4j_generator'
38
+ end
@@ -46,6 +46,19 @@ module Neo4j
46
46
  _persisted_node || raise("Tried to access native neo4j object on a none persisted object")
47
47
  end
48
48
 
49
+ module ClassMethods
50
+ def neo4j_session_name (name)
51
+ @neo4j_session_name = name
52
+ end
53
+
54
+ def neo4j_session
55
+ if @neo4j_session_name
56
+ Neo4j::Session.named(@neo4j_session_name) || raise("#{self.name} is configured to use a neo4j session named #{@neo4j_session_name}, but no such session is registered with Neo4j::Session")
57
+ else
58
+ Neo4j::Session.current
59
+ end
60
+ end
61
+ end
49
62
 
50
63
  included do
51
64
  def self.inherited(other)
@@ -57,4 +70,4 @@ module Neo4j
57
70
  end
58
71
  end
59
72
  end
60
- end
73
+ end
@@ -201,8 +201,7 @@ module Neo4j
201
201
  end
202
202
 
203
203
  def all_relationships(node)
204
- # TODO fix ruby warning - warning: Enumerator.new without a block is deprecated; use Object#to_enum
205
- Enumerator.new(self, :each_rel, node)
204
+ to_enum(:each_rel, node)
206
205
  end
207
206
 
208
207
  def each_rel(node, &block) #:nodoc:
@@ -218,16 +217,9 @@ module Neo4j
218
217
  end
219
218
 
220
219
  # @private
221
- def _each_node(node, &block) #:nodoc:
222
- node._rels(dir: dir, type: rel_type).each do |rel|
223
- block.call rel._other_node(node)
224
- end
225
- end
226
-
227
- # @private
228
- def create_relationship_to(node, other) # :nodoc:
220
+ def create_relationship_to(node, other, relationship_props={}) # :nodoc:
229
221
  from, to = incoming? ? [other, node] : [node, other]
230
- from.create_rel(@rel_type, to)
222
+ from.create_rel(@rel_type, to, relationship_props)
231
223
  end
232
224
 
233
225
  end
@@ -55,8 +55,8 @@ module Neo4j
55
55
 
56
56
  # Creates a relationship instance between this and the other node.
57
57
  # Returns the relationship object
58
- def create(other)
59
- @decl_rel.create_relationship_to(@node, other)
58
+ def create(other, relationship_props)
59
+ @decl_rel.create_relationship_to(@node, other, relationship_props)
60
60
  end
61
61
 
62
62
 
@@ -1,15 +1,17 @@
1
1
  module Neo4j::ActiveNode::Initialize
2
2
  extend ActiveSupport::Concern
3
+ include Neo4j::TypeConverters
3
4
 
4
5
  attr_reader :_persisted_node
5
6
 
6
7
  # called when loading the node from the database
7
8
  # @param [Neo4j::Node] persisted_node the node this class wraps
8
- # @param [Hash] properties properties of the persisted node.
9
+ # @param [Hash] properties of the persisted node.
9
10
  def init_on_load(persisted_node, properties)
10
11
  @_persisted_node = persisted_node
11
12
  @changed_attributes && @changed_attributes.clear
12
13
  @attributes = attributes.merge(properties.stringify_keys)
14
+ @attributes = convert_properties_to :ruby, @attributes
13
15
  end
14
16
 
15
17
  # Implements the Neo4j::Node#wrapper and Neo4j::Relationship#wrapper method
@@ -46,8 +46,8 @@ module Neo4j
46
46
 
47
47
  # Find all nodes/objects of this class, with given search criteria
48
48
  # @param [Hash, nil] args the search critera or nil if finding all
49
- # @param [Neo4j::Session] session defaults to the current
50
- def all(args = nil, session = Neo4j::Session.current)
49
+ # @param [Neo4j::Session] session defaults to the model's session
50
+ def all(args = nil, session = self.neo4j_session)
51
51
  if (args)
52
52
  find_by_hash(args, session)
53
53
  else
@@ -56,7 +56,7 @@ module Neo4j
56
56
  end
57
57
 
58
58
  # @return [Fixnum] number of nodes of this class
59
- def count(session = Neo4j::Session.current)
59
+ def count(session = self.neo4j_session)
60
60
  q = session.query("MATCH (n:`#{mapped_label_name}`) RETURN count(n) AS count")
61
61
  q.to_a[0][:count]
62
62
  end
@@ -64,7 +64,7 @@ module Neo4j
64
64
  # Same as #all but return only one object
65
65
  # If given a String or Fixnum it will return the object with that neo4j id.
66
66
  # @param [Hash,String,Fixnum] args search criteria
67
- def find(args, session = Neo4j::Session.current)
67
+ def find(args, session = self.neo4j_session)
68
68
  case args
69
69
  when Hash
70
70
  find_by_hash(args, session).first
@@ -78,14 +78,14 @@ module Neo4j
78
78
 
79
79
  # Destroy all nodes an connected relationships
80
80
  def destroy_all
81
- Neo4j::Session.current._query("MATCH (n:`#{mapped_label_name}`)-[r]-() DELETE n,r")
82
- Neo4j::Session.current._query("MATCH (n:`#{mapped_label_name}`) DELETE n")
81
+ self.neo4j_session._query("MATCH (n:`#{mapped_label_name}`)-[r]-() DELETE n,r")
82
+ self.neo4j_session._query("MATCH (n:`#{mapped_label_name}`) DELETE n")
83
83
  end
84
84
 
85
85
  # Creates a Neo4j index on given property
86
86
  # @param [Symbol] property the property we want a Neo4j index on
87
87
  def index(property)
88
- if Neo4j::Session.current
88
+ if self.neo4j_session
89
89
  _index(property)
90
90
  else
91
91
  Neo4j::Session.add_listener do |event, _|
@@ -134,9 +134,10 @@ module Neo4j
134
134
  def set_mapped_label_name(name)
135
135
  @_label_name = name.to_sym
136
136
  end
137
+
137
138
  end
138
139
 
139
140
  end
140
141
 
141
142
  end
142
- end
143
+ end
@@ -10,6 +10,7 @@ module Neo4j::ActiveNode
10
10
  end
11
11
 
12
12
  extend ActiveSupport::Concern
13
+ include Neo4j::TypeConverters
13
14
 
14
15
  # Saves the model.
15
16
  #
@@ -18,14 +19,22 @@ module Neo4j::ActiveNode
18
19
  # If any of them fail the action is cancelled and save returns false. If the flag is false validations are bypassed altogether. See ActiveRecord::Validations for more information.
19
20
  # There’s a series of callbacks associated with save. If any of the before_* callbacks return false the action is cancelled and save returns false.
20
21
  def save(*)
22
+ # Update magic properties
23
+ update_magic_properties
21
24
  create_or_update
22
25
  end
23
26
 
27
+ def update_magic_properties
28
+ self.updated_at = DateTime.now if respond_to?(:updated_at=)
29
+ end
30
+
24
31
  # Creates a model with values matching those of the instance attributes and returns its id.
25
32
  # @private
26
33
  # @return true
27
34
  def create_model(*)
28
- node = _create_node(props)
35
+ self.created_at = DateTime.now if respond_to?(:created_at=)
36
+ properties = convert_properties_to :db, props
37
+ node = _create_node(properties)
29
38
  init_on_load(node, node.props)
30
39
  # Neo4j::IdentityMap.add(node, self)
31
40
  # write_changed_relationships
@@ -94,13 +103,14 @@ module Neo4j::ActiveNode
94
103
  def update_model
95
104
  if @changed_attributes && !@changed_attributes.empty?
96
105
  changed_props = attributes.select{|k,v| @changed_attributes.include?(k)}
97
- _persisted_node.props = changed_props
106
+ changed_props = convert_properties_to :db, changed_props
107
+ _persisted_node.update_props(changed_props)
98
108
  @changed_attributes.clear
99
109
  end
100
110
  end
101
111
 
102
112
  def _create_node(*args)
103
- session = Neo4j::Session.current
113
+ session = self.class.neo4j_session
104
114
  props = args[0] if args[0].is_a?(Hash)
105
115
  labels = self.class.mapped_label_names
106
116
  session.create_node(props, labels)
@@ -190,4 +200,4 @@ module Neo4j::ActiveNode
190
200
 
191
201
  end
192
202
 
193
- end
203
+ end
@@ -23,6 +23,8 @@ module Neo4j::ActiveNode
23
23
  module ClassMethods
24
24
 
25
25
  def property(name, options={})
26
+ # Magic properties
27
+ options[:type] = DateTime if name.to_sym == :created_at || name.to_sym == :updated_at
26
28
  attribute(name, options)
27
29
  end
28
30
 
@@ -15,22 +15,34 @@ module Neo4j
15
15
 
16
16
  cfg.session_type ||= :server_db
17
17
  cfg.session_path ||= "http://localhost:7474"
18
+ cfg.sessions ||= []
18
19
 
19
- if !(RUBY_PLATFORM =~ /java/) && cfg.session_type == :embedded_db
20
- raise "Tried to start embedded Neo4j db without using JRuby (got #{RUBY_PLATFORM}), please run `rvm jruby`"
20
+ if cfg.sessions.empty?
21
+ cfg.sessions << {type: cfg.session_type, path: cfg.session_path}
21
22
  end
22
23
 
23
- puts "Create Neo4j Session #{cfg.session_type}, path: #{cfg.session_path}"
24
- session = Neo4j::Session.open(cfg.session_type, cfg.session_path)
25
- if cfg.session_type == :embedded_db
24
+ cfg.sessions.each do |session_opts|
25
+ if !(RUBY_PLATFORM =~ /java/) && session_opts[:type] == :embedded_db
26
+ raise "Tried to start embedded Neo4j db without using JRuby (got #{RUBY_PLATFORM}), please run `rvm jruby`"
27
+ end
26
28
 
27
- # See https://github.com/jruby/jruby/wiki/UnlimitedStrengthCrypto
28
- security_class = java.lang.Class.for_name('javax.crypto.JceSecurity')
29
- restricted_field = security_class.get_declared_field('isRestricted')
30
- restricted_field.accessible = true
31
- restricted_field.set nil, false
29
+ puts "Create Neo4j Session #{session_opts[:type]}, path: #{session_opts[:path]}"
30
+ if (session_opts.key? :name)
31
+ session = Neo4j::Session.open_named(session_opts[:type], session_opts[:name], session_opts[:default], session_opts[:path])
32
+ else
33
+ session = Neo4j::Session.open(session_opts[:type], session_opts[:path])
34
+ end
32
35
 
33
- session.start
36
+ if session_opts[:type] == :embedded_db
37
+
38
+ # See https://github.com/jruby/jruby/wiki/UnlimitedStrengthCrypto
39
+ security_class = java.lang.Class.for_name('javax.crypto.JceSecurity')
40
+ restricted_field = security_class.get_declared_field('isRestricted')
41
+ restricted_field.accessible = true
42
+ restricted_field.set nil, false
43
+
44
+ session.start
45
+ end
34
46
  end
35
47
 
36
48
  #cfg.storage_path = "#{app.config.root}/db/neo4j-#{::Rails.env}" unless cfg.storage_path
@@ -0,0 +1,124 @@
1
+ module Neo4j
2
+
3
+ module TypeConverters
4
+
5
+
6
+ # Converts Date objects to Java long types. Must be timezone UTC.
7
+ class DateConverter
8
+ class << self
9
+
10
+ def convert_type
11
+ Date
12
+ end
13
+
14
+ def to_db(value)
15
+ return nil if value.nil?
16
+ Time.utc(value.year, value.month, value.day).to_i
17
+ end
18
+
19
+ def to_ruby(value)
20
+ return nil if value.nil?
21
+ Time.at(value).utc.to_date
22
+ end
23
+
24
+ end
25
+ end
26
+
27
+ # Converts DateTime objects to and from Java long types. Must be timezone UTC.
28
+ class DateTimeConverter
29
+ class << self
30
+
31
+ def convert_type
32
+ DateTime
33
+ end
34
+
35
+ # Converts the given DateTime (UTC) value to an Fixnum.
36
+ # DateTime values are automatically converted to UTC.
37
+ def to_db(value)
38
+ return nil if value.nil?
39
+ value = value.new_offset(0) if value.respond_to?(:new_offset)
40
+ if value.class == Date
41
+ Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i
42
+ else
43
+ Time.utc(value.year, value.month, value.day, value.hour, value.min, value.sec).to_i
44
+ end
45
+ end
46
+
47
+ def to_ruby(value)
48
+ return nil if value.nil?
49
+ t = Time.at(value).utc
50
+ DateTime.civil(t.year, t.month, t.day, t.hour, t.min, t.sec)
51
+ end
52
+
53
+ end
54
+ end
55
+
56
+ class TimeConverter
57
+ class << self
58
+
59
+ def convert_type
60
+ Time
61
+ end
62
+
63
+ # Converts the given DateTime (UTC) value to an Fixnum.
64
+ # Only utc times are supported !
65
+ def to_db(value)
66
+ return nil if value.nil?
67
+ if value.class == Date
68
+ Time.utc(value.year, value.month, value.day, 0, 0, 0).to_i
69
+ else
70
+ value.utc.to_i
71
+ end
72
+ end
73
+
74
+ def to_ruby(value)
75
+ return nil if value.nil?
76
+ Time.at(value).utc
77
+ end
78
+
79
+ end
80
+ end
81
+
82
+ def convert_properties_to(medium, properties)
83
+ # Perform type conversion
84
+ properties = properties.inject({}) do |new_attributes, key_value_pair|
85
+ attr, value = key_value_pair
86
+ type = self.class._attribute_type(attr)
87
+ new_attributes[attr] = if TypeConverters.converters[type].nil?
88
+ value
89
+ else
90
+ TypeConverters.send "to_#{medium}", value, type
91
+ end
92
+ new_attributes
93
+ end
94
+ end
95
+
96
+ class << self
97
+
98
+ # Converts the value to ruby from a Neo4j database value if there is a converter for given type
99
+ def to_ruby(value, type = nil)
100
+ found_converter = converters[type]
101
+ found_converter ? found_converter.to_ruby(value) : value
102
+ end
103
+
104
+ # Converts the value to a Neo4j database value from ruby if there is a converter for given type
105
+ def to_db(value, type = nil)
106
+ found_converter = converters[type]
107
+ found_converter ? found_converter.to_db(value) : value
108
+ end
109
+
110
+ def converters
111
+ @converters ||= begin
112
+ Neo4j::TypeConverters.constants.find_all do |c|
113
+ Neo4j::TypeConverters.const_get(c).respond_to?(:convert_type)
114
+ end.map do |c|
115
+ Neo4j::TypeConverters.const_get(c)
116
+ end.inject({}) do |ack, t|
117
+ ack[t.convert_type] = t
118
+ ack
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = "3.0.0.alpha.2"
2
+ VERSION = "3.0.0.alpha.3"
3
3
  end
@@ -0,0 +1,79 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', '..', '..','neo4j.rb')
2
+
3
+ class Neo4j::Generators::ModelGenerator < Neo4j::Generators::Base #:nodoc:
4
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
5
+
6
+ check_class_collision
7
+
8
+ class_option :timestamps, :type => :boolean
9
+ class_option :parent, :type => :string, :desc => "The parent class for the generated model"
10
+ class_option :indices, :type => :array, :desc => "The properties which should be indexed"
11
+ class_option :has_one, :type => :array, :desc => "A list of has_one relationships"
12
+ class_option :has_n, :type => :array, :desc => "A list of has_n relationships"
13
+
14
+ def create_model_file
15
+ template "model.erb", File.join('app/models', "#{singular_name}.rb")
16
+ end
17
+
18
+ protected
19
+ def migration?
20
+ false
21
+ end
22
+
23
+ def timestamps?
24
+ options[:timestamps]
25
+ end
26
+
27
+ def has_n?
28
+ options[:has_n]
29
+ end
30
+
31
+ def has_n_statements
32
+ txt = ""
33
+ options[:has_n].each do |key|
34
+ to, from = key.split(':')
35
+ txt << (from ? "\n has_n(:#{to}).from(:#{from})\n" : "\n has_n :#{to}")
36
+ end
37
+ txt
38
+ end
39
+
40
+ def has_one?
41
+ options[:has_one]
42
+ end
43
+
44
+ def has_one_statements
45
+ txt = ""
46
+ options[:has_one].each do |key|
47
+ to, from = key.split(':')
48
+ txt << (from ? "\n has_one(:#{to}).from(:#{from})\n" : "\n has_one :#{to}")
49
+ end
50
+ txt
51
+ end
52
+
53
+ def indices?
54
+ options[:indices]
55
+ end
56
+
57
+
58
+ def index_fragment(property)
59
+ if options[:indices] && options[:indices].include?(property)
60
+ "index :#{property}"
61
+ end
62
+ end
63
+
64
+ def parent?
65
+ options[:parent]
66
+ end
67
+
68
+ def timestamp_statements
69
+ %q{
70
+ property :created_at, :type => DateTime
71
+ # property :created_on, :type => Date
72
+
73
+ property :updated_at, :type => DateTime
74
+ # property :updated_on, :type => Date
75
+ }
76
+ end
77
+
78
+ hook_for :test_framework
79
+ end
@@ -0,0 +1,11 @@
1
+ class <%= class_name %> <%= parent? ? "#{options[:parent].classify}" : "" %>
2
+ include Neo4j::ActiveNode
3
+ <% attributes.each do |attribute| -%>
4
+ property :<%= attribute.name %><%= ", :type => #{attribute.type_class}" unless attribute.type_class == 'any' %>
5
+ <%= index_fragment(attribute.name) %>
6
+ <% end -%>
7
+ <%= has_n_statements if has_n? -%>
8
+ <%= has_one_statements if has_one? -%>
9
+
10
+ <%= timestamp_statements if timestamps? -%>
11
+ end
@@ -0,0 +1,74 @@
1
+ require 'rails/generators/named_base'
2
+ require 'rails/generators/active_model'
3
+
4
+
5
+ module Neo4j
6
+ module Generators #:nodoc:
7
+ end
8
+ end
9
+
10
+ class Neo4j::Generators::Base < ::Rails::Generators::NamedBase #:nodoc:
11
+ def self.source_root
12
+ @_neo4j_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
13
+ 'neo4j', generator_name, 'templates'))
14
+ end
15
+ end
16
+
17
+ class Neo4j::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
18
+ def self.all(klass)
19
+ "#{klass}.all"
20
+ end
21
+
22
+ def self.find(klass, params=nil)
23
+ "#{klass}.find(#{params})"
24
+ end
25
+
26
+ def self.build(klass, params=nil)
27
+ if params
28
+ "#{klass}.new(#{params})"
29
+ else
30
+ "#{klass}.new"
31
+ end
32
+ end
33
+
34
+ def save
35
+ "#{name}.save"
36
+ end
37
+
38
+ def update_attributes(params=nil)
39
+ "#{name}.update_attributes(#{params})"
40
+ end
41
+
42
+ def errors
43
+ "#{name}.errors"
44
+ end
45
+
46
+ def destroy
47
+ "#{name}.destroy"
48
+ end
49
+ end
50
+
51
+ module Rails
52
+ module Generators
53
+ class GeneratedAttribute #:nodoc:
54
+ def type_class
55
+ case type.to_s.downcase
56
+ when 'any' then
57
+ 'any'
58
+ when 'datetime' then
59
+ 'DateTime'
60
+ when 'date' then
61
+ 'Date'
62
+ when 'text' then
63
+ 'String'
64
+ when 'integer', 'number', 'fixnum' then
65
+ 'Fixnum'
66
+ when 'float' then
67
+ 'Float'
68
+ else
69
+ 'String'
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,16 @@
1
+ require 'neo4j'
2
+
3
+ class Person
4
+ include Neo4j::ActiveNode
5
+ property :born, type: Date
6
+ property :since
7
+
8
+ end
9
+
10
+ #Neo4j::Session.open(:server_db, 'http://localhost:7474')
11
+
12
+ puts "Type #{Person._attribute_type(:born)}, class #{Person._attribute_type(:born).class}"
13
+ puts "Type since #{Person._attribute_type(:since)}"
14
+ p = Person.new(born: Date.today)
15
+ #p.save
16
+ puts "BORN #{p.born} type: #{p.born.class}"
@@ -32,7 +32,7 @@ It comes included with the Apache Lucene document database.
32
32
  s.add_dependency("activemodel", "~> 4.0.0")
33
33
  s.add_dependency("railties", "~> 4.0.0")
34
34
  s.add_dependency('active_attr', "~> 0.8")
35
- s.add_dependency("neo4j-core", "= 3.0.0.alpha.6")
35
+ s.add_dependency("neo4j-core", "= 3.0.0.alpha.8")
36
36
 
37
37
  if RUBY_PLATFORM =~ /java/
38
38
  s.add_dependency("neo4j-community", '~> 2.0.0')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha.2
4
+ version: 3.0.0.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-09 00:00:00.000000000 Z
11
+ date: 2014-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orm_adapter
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 3.0.0.alpha.6
75
+ version: 3.0.0.alpha.8
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 3.0.0.alpha.6
82
+ version: 3.0.0.alpha.8
83
83
  description: "You can think of Neo4j as a high-performance graph engine with all the
84
84
  features of a mature and robust database.\nThe programmer works with an object-oriented,
85
85
  flexible network structure rather than with strict and static tables \nyet enjoys
@@ -106,9 +106,14 @@ files:
106
106
  - lib/neo4j/active_node/validations.rb
107
107
  - lib/neo4j/active_node.rb
108
108
  - lib/neo4j/railtie.rb
109
+ - lib/neo4j/type_converters.rb
109
110
  - lib/neo4j/version.rb
110
111
  - lib/neo4j/wrapper.rb
111
112
  - lib/neo4j.rb
113
+ - lib/rails/generators/neo4j/model/model_generator.rb
114
+ - lib/rails/generators/neo4j/model/templates/model.erb
115
+ - lib/rails/generators/neo4j_generator.rb
116
+ - lib/test.rb
112
117
  - config/locales/en.yml
113
118
  - config/neo4j/config.yml
114
119
  - README.md