neo4j 8.3.4 → 9.0.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: 4cfd5a1f6cea64cb3a8b231afff48bf1329a87ba
4
- data.tar.gz: 42fda6bc83fd3dfa0074395ea71f54af16e99a38
3
+ metadata.gz: c78f6fb58c6a6a78a3fb7e270ffd739ae12e308b
4
+ data.tar.gz: 7594112b8478cca3a2a8be8c8466a3857e1f26d3
5
5
  SHA512:
6
- metadata.gz: 672186434970764c8d1b58ce6a6e97697ca6fbdbfa003f1f9d733975fca77e8493804c6af4c36a0363efb5f7158a2a498ea3c939f821f9b6673ed25e6802eb91
7
- data.tar.gz: 4fdd315602b202e5f1d29a2300dc218c76ac4d40c6d5b7401611aac8dbe457b72ee4a42557c61e6e68224b2e95ad474d6f34b0cfa2dc15e226b8b69618427c0e
6
+ metadata.gz: 41a2702fbfba425b8f56a68ad6cf3eb6c2caafa65b7b59274df602b0db61c75ea2d66ba6be7d08a68464f7f5b69685fc803445a6720c12559cab71e386050d49
7
+ data.tar.gz: ccd313d1f0c9ded6b4ed0512e5f7c6aeefca38450f9b69500d9551440f7aebab9e13cc9c861e872538a18243ba2fe796a617802f47066ebf4265adbd77a9ef96
data/CHANGELOG.md CHANGED
@@ -3,27 +3,15 @@ All notable changes to this project will be documented in this file.
3
3
  This file should follow the standards specified on [http://keepachangelog.com/]
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
- ## [8.3.4] 2017-10-16
6
+ ## [9.0.0] 2017-09-26
7
7
 
8
- ## Fixes
9
-
10
- - Ensure `branch` and `with_association` methods propagate `distinct` (thanks @klobuczek / see #1438)
11
-
12
- ## [8.3.3] 2017-10-15
13
-
14
- ## Fixes
15
-
16
- - Change YAML.safe_load call in `neo4j:schema:load` rake task to allow Symbols (thanks @evanob / see #1439)
17
-
18
- ## [8.3.2] 2017-10-12
19
-
20
- ## Fixes
8
+ ### Changed
21
9
 
22
- - Ensure branch method propagates with_association_tree context (thanks @klobuczek / see #1437)
10
+ - `enum` values are now case-insensitive when being set by default (with a `_case_sensitive` option) (thanks @thefliik / see #1419)
23
11
 
24
- ## [8.3.1] 2017-10-08
12
+ ### Fixed
25
13
 
26
- - Accidental release
14
+ - Properties defined on a superclass after the subclass has been defined will now take effect on the subclass (thanks @thefliik / see #1428)
27
15
 
28
16
  ## [8.3.0] 2017-09-25
29
17
 
@@ -187,9 +187,7 @@ module Neo4j
187
187
  # `as(identity)` is here to make sure we get the right variable
188
188
  # There might be a deeper problem of the variable changing when we
189
189
  # traverse an association
190
- as(identity).instance_eval(&block).query.proxy_as(self.model, identity).tap do |new_query_proxy|
191
- propagate_context(new_query_proxy)
192
- end
190
+ as(identity).instance_eval(&block).query.proxy_as(self.model, identity)
193
191
  end
194
192
 
195
193
  def [](index)
@@ -73,11 +73,6 @@ module Neo4j
73
73
  end
74
74
  end
75
75
 
76
- def propagate_context(query_proxy)
77
- super
78
- query_proxy.instance_variable_set('@with_associations_tree', @with_associations_tree)
79
- end
80
-
81
76
  def with_associations_tree
82
77
  @with_associations_tree ||= AssociationTree.new(model)
83
78
  end
@@ -143,7 +138,7 @@ module Neo4j
143
138
 
144
139
  def query_from_association_tree
145
140
  previous_with_variables = []
146
- with_associations_tree.paths.inject(query_as(identity).with(ensure_distinct(identity))) do |query, path|
141
+ with_associations_tree.paths.inject(query_as(identity).with(identity)) do |query, path|
147
142
  with_association_query_part(query, path, previous_with_variables).tap do
148
143
  previous_with_variables << path_name(path)
149
144
  end
@@ -47,10 +47,6 @@ module Neo4j
47
47
  end
48
48
  end
49
49
 
50
- def propagate_context(query_proxy)
51
- query_proxy.instance_variable_set(:@distinct, @distinct)
52
- end
53
-
54
50
  # @return [Integer] number of nodes of this class
55
51
  def count(distinct = nil, target = nil)
56
52
  return 0 if unpersisted_start_object?
data/lib/neo4j/config.rb CHANGED
@@ -122,6 +122,10 @@ module Neo4j
122
122
  return nil if namespace.nil?
123
123
  "::#{namespace}"
124
124
  end
125
+
126
+ def enums_case_sensitive
127
+ Neo4j::Config[:enums_case_sensitive] || false
128
+ end
125
129
  end
126
130
  end
127
131
  end
@@ -3,6 +3,7 @@ module Neo4j::Shared
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  class ConflictingEnumMethodError < Neo4j::Error; end
6
+ class InvalidEnumValueError < Neo4j::InvalidParameterError; end
6
7
 
7
8
  module ClassMethods
8
9
  attr_reader :neo4j_enum_data
@@ -43,7 +44,7 @@ module Neo4j::Shared
43
44
  def enum(parameters = {})
44
45
  options, parameters = *split_options_and_parameters(parameters)
45
46
  parameters.each do |property_name, enum_keys|
46
- enum_keys = normalize_key_list enum_keys
47
+ enum_keys = normalize_key_list enum_keys, options
47
48
  @neo4j_enum_data ||= {}
48
49
  @neo4j_enum_data[property_name] = enum_keys
49
50
  define_property(property_name, enum_keys, options)
@@ -53,18 +54,28 @@ module Neo4j::Shared
53
54
 
54
55
  protected
55
56
 
56
- def normalize_key_list(enum_keys)
57
+ def normalize_key_list(enum_keys, options)
58
+ case_sensitive = options.fetch(:_case_sensitive, Neo4j::Config.enums_case_sensitive)
59
+
57
60
  case enum_keys
58
61
  when Hash
59
62
  enum_keys
60
63
  when Array
61
- Hash[enum_keys.each_with_index.to_a]
64
+ enum_keys = Hash[enum_keys.each_with_index.to_a]
62
65
  else
63
66
  fail ArgumentError, 'Invalid parameter for enum. Please provide an Array or an Hash.'
64
67
  end
68
+
69
+ unless case_sensitive
70
+ enum_keys.keys.each do |key|
71
+ fail ArgumentError, 'Enum keys must be lowercase unless _case_sensitive = true' unless key.downcase == key
72
+ end
73
+ end
74
+
75
+ enum_keys
65
76
  end
66
77
 
67
- VALID_OPTIONS_FOR_ENUMS = [:_index, :_prefix, :_suffix, :_default]
78
+ VALID_OPTIONS_FOR_ENUMS = [:_index, :_prefix, :_suffix, :_default, :_case_sensitive]
68
79
 
69
80
  def split_options_and_parameters(parameters)
70
81
  options = {}
@@ -80,9 +91,8 @@ module Neo4j::Shared
80
91
  end
81
92
 
82
93
  def define_property(property_name, enum_keys, options)
83
- property_options = build_property_options(enum_keys, options)
84
- property property_name, property_options
85
- serialize property_name, Neo4j::Shared::TypeConverters::EnumConverter.new(enum_keys, property_options)
94
+ property property_name, build_property_options(enum_keys, options)
95
+ serialize property_name, Neo4j::Shared::TypeConverters::EnumConverter.new(enum_keys, build_enum_options(enum_keys, options))
86
96
  end
87
97
 
88
98
  def build_property_options(_enum_keys, options = {})
@@ -91,6 +101,16 @@ module Neo4j::Shared
91
101
  }
92
102
  end
93
103
 
104
+ def build_enum_options(enum_keys, options = {})
105
+ if options[:_default] && not(enum_keys.include?(options[:_default]))
106
+ fail ArgumentError, 'Enum default value must match an enum key'
107
+ end
108
+
109
+ build_property_options(enum_keys, options).tap do |enum_options|
110
+ enum_options[:case_sensitive] = options[:_case_sensitive]
111
+ end
112
+ end
113
+
94
114
  def define_enum_methods(property_name, enum_keys, options)
95
115
  define_enum_methods_?(property_name, enum_keys, options)
96
116
  define_enum_methods_!(property_name, enum_keys, options)
@@ -271,6 +271,10 @@ module Neo4j::Shared
271
271
  def initialize(enum_keys, options)
272
272
  @enum_keys = enum_keys
273
273
  @options = options
274
+
275
+ return unless @options[:case_sensitive].nil?
276
+
277
+ @options[:case_sensitive] = Neo4j::Config.enums_case_sensitive
274
278
  end
275
279
 
276
280
  def converted?(value)
@@ -298,8 +302,12 @@ module Neo4j::Shared
298
302
  def to_db(value)
299
303
  if value.is_a?(Array)
300
304
  value.map(&method(:to_db))
305
+ elsif @options[:case_sensitive]
306
+ @enum_keys[value.to_s.to_sym] ||
307
+ fail(Neo4j::Shared::Enum::InvalidEnumValueError, 'Value passed to an enum property must match one of the enum keys')
301
308
  else
302
- @enum_keys[value.to_s.to_sym] || 0
309
+ @enum_keys[value.to_s.downcase.to_sym] ||
310
+ fail(Neo4j::Shared::Enum::InvalidEnumValueError, 'Case-insensitive (downcased) value passed to an enum property must match one of the enum keys')
303
311
  end
304
312
  end
305
313
  end
@@ -95,7 +95,7 @@ COMMENT
95
95
 
96
96
  args.with_defaults(remove_missing: false)
97
97
 
98
- schema_data = YAML.safe_load(File.read(SCHEMA_YAML_PATH), [Symbol])
98
+ schema_data = YAML.safe_load(File.read(SCHEMA_YAML_PATH))
99
99
 
100
100
  Neo4j::Core::CypherSession::Adaptors::Base.subscribe_to_query(&method(:puts))
101
101
 
data/lib/neo4j/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Neo4j
2
- VERSION = '8.3.4'
2
+ VERSION = '9.0.0'
3
3
  end
data/neo4j.gemspec CHANGED
@@ -41,5 +41,4 @@ A Neo4j OGM (Object-Graph-Mapper) for Ruby heavily inspired by ActiveRecord.
41
41
  s.add_development_dependency('guard-rubocop')
42
42
  s.add_development_dependency('guard-rspec')
43
43
  s.add_development_dependency('rubocop', '~> 0.49.1')
44
- s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
45
44
  end
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: 8.3.4
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-16 00:00:00.000000000 Z
11
+ date: 2017-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: orm_adapter
@@ -192,20 +192,6 @@ dependencies:
192
192
  - - "~>"
193
193
  - !ruby/object:Gem::Version
194
194
  version: 0.49.1
195
- - !ruby/object:Gem::Dependency
196
- name: neo4j-rake_tasks
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: 0.3.0
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: 0.3.0
209
195
  description: 'A Neo4j OGM (Object-Graph-Mapper) for Ruby heavily inspired by ActiveRecord.
210
196
 
211
197
  '