activegraph 11.5.0.alpha.1 → 11.5.0.beta.1

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
  SHA256:
3
- metadata.gz: '0101891bd10ab15f40fe0b95d8f9801addbad38e6a9a620d6ed3172538f13b81'
4
- data.tar.gz: 29cd3cdd821bdd01723767210820b441d175c20722d086791e3b6f96c60e7860
3
+ metadata.gz: c217d68abf8f640ef01f10e2d7a5b96c6fe7b6f3c4499d24da58718a90646acc
4
+ data.tar.gz: d8bcda3316fd7cdc1422eb47b186f6eb7d853752d138f014e53a0e425c2f3e4f
5
5
  SHA512:
6
- metadata.gz: 236ae57612400438f2ea424600e5b4013790d9fe77840421727f83e5158ca4c8622cc8b2bda502d19c8f212956c86111f25b38fe5d3a68e2ef4819620432aa53
7
- data.tar.gz: e699e3c4788af542fec9c1b74552b08309a8bd3611a25232445c0bf8a7a4f292067ee3cb86db5c7ed7a34dc134eff8a1fea59c772b778a58de2b1c3d1ec47bb1
6
+ metadata.gz: fa79ae2d367a183fb0a5a26363f352d15767540288ae080558fc876854100ecf01815fb76be5460d1f638c3c1a8799a5b44f09e7ce5d0efc8faa8a74baf9c187
7
+ data.tar.gz: e39a318db8e56067cffbd7ba216d3951184124cb36b48da420334475472d63d17bff7d70027d4d7a9e495d7cb4cb7d4dd8b27b9a4c3bf44e265b24503802b2fd
data/CHANGELOG.md CHANGED
@@ -3,10 +3,21 @@ 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
- ## [11.4.0] 2023-02-12
6
+ ## [11.5.0.beta.1] 2023-12-29
7
+
8
+ ## Added
9
+
10
+ - migrated to zeitwerk
11
+ - rails 7.1 support
7
12
 
8
13
  ## Fixed
9
14
 
15
+ - caching of has one relationships
16
+
17
+ ## [11.4.0] 2023-12-02
18
+
19
+ ## Added
20
+
10
21
  - Added support for cypher UNION
11
22
 
12
23
  ## [11.3.1] 2023-02-12
data/Gemfile CHANGED
@@ -2,10 +2,6 @@ source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- # gem 'neo4j-ruby-driver', path: '../neo4j-ruby-driver'
6
-
7
- # gem 'listen', '< 3.1'
8
-
9
5
  active_model_version = ENV['ACTIVE_MODEL_VERSION']
10
6
  gem 'activemodel', "~> #{active_model_version}" if active_model_version&.length&.positive?
11
7
 
data/activegraph.gemspec CHANGED
@@ -30,8 +30,7 @@ DESCRIPTION
30
30
  'bug_tracker_uri' => 'https://github.com/neo4jrb/activegraph/issues'
31
31
  }
32
32
 
33
- s.add_dependency('activemodel', '>= 4.0')
34
- s.add_dependency('activesupport', '>= 4.0')
33
+ s.add_dependency('activemodel', '>= 7')
35
34
  s.add_dependency('i18n', '!= 1.8.8') # https://github.com/jruby/jruby/issues/6547
36
35
  s.add_dependency('neo4j-ruby-driver', '>= 4.4.1', '< 5')
37
36
  s.add_dependency('orm_adapter', '>= 0.5.0')
@@ -42,7 +41,7 @@ DESCRIPTION
42
41
  s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
43
42
  s.add_development_dependency('os')
44
43
  s.add_development_dependency('pry')
45
- s.add_development_dependency('railties', '>= 4.0')
44
+ s.add_development_dependency('railties', '>= 7')
46
45
  s.add_development_dependency('rake')
47
46
  s.add_development_dependency('rubocop', '>= 0.56.0')
48
47
  s.add_development_dependency('yard')
@@ -111,13 +111,17 @@ module ActiveGraph::Node
111
111
 
112
112
  def add_to_cache(object, rel = nil)
113
113
  (@cached_rels ||= []) << rel if rel
114
- (@cached_result ||= []).tap { |results| results << object if object && !results.include?(object) }
114
+ (@cached_result ||= []).tap { |results| results << object if !results.include?(object) } if object
115
115
  end
116
116
 
117
117
  def rels
118
118
  @cached_rels || super.tap { |rels| rels.each { |rel| add_to_cache(nil, rel) } }
119
119
  end
120
120
 
121
+ def rel
122
+ rels.first
123
+ end
124
+
121
125
  def cache_query_proxy_result
122
126
  (result_cache_proc_cache || @query_proxy).to_a.tap { |result| cache_result(result) }
123
127
  end
@@ -51,6 +51,7 @@ module ActiveGraph
51
51
  def replace_with(node_or_nodes)
52
52
  node_or_nodes = Array(node_or_nodes).map { |arg| arg.is_a?(ActiveGraph::Node) ? arg : @model.find(arg) }
53
53
  original_ids = self.pluck(:id)
54
+ ActiveGraph::Base.lock_node(start_object) unless start_object.new_record?
54
55
  delete_rels_for_nodes(original_ids, node_or_nodes.collect(&:id))
55
56
  add_rels(node_or_nodes, original_ids)
56
57
  end
@@ -1,3 +1,16 @@
1
+ require 'active_graph'
2
+
3
+ if defined?(Rails)
4
+ # Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
5
+ require 'action_dispatch/railtie'
6
+ require 'rails/generators'
7
+ require 'rails/generators/active_model'
8
+ require 'rails/generators/named_base'
9
+ require 'rails/railtie'
10
+ require File.expand_path('../rails/generators/migration_helper.rb', __dir__)
11
+ Rails::Generators::GeneratedAttribute.include ActiveGraph::Generators::GeneratedAttribute
12
+ end
13
+
1
14
  module ActiveGraph
2
15
  class Railtie < ::Rails::Railtie
3
16
  def empty_config
@@ -28,6 +28,10 @@ module ActiveGraph
28
28
 
29
29
  alias transaction write_transaction
30
30
 
31
+ def lock_node(node)
32
+ node.as(:n).query.remove('n._AGLOCK_').exec if tx&.open?
33
+ end
34
+
31
35
  private
32
36
 
33
37
  def send_transaction(method, **config, &block)
@@ -1,3 +1,3 @@
1
1
  module ActiveGraph
2
- VERSION = '11.5.0.alpha.1'
2
+ VERSION = '11.5.0.beta.1'
3
3
  end
data/lib/active_graph.rb CHANGED
@@ -22,20 +22,9 @@ require 'set'
22
22
  require 'sorted_set'
23
23
  require 'yaml'
24
24
 
25
- if defined?(Rails)
26
- # Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
27
- require 'action_dispatch/railtie'
28
- require 'rails/generators'
29
- require 'rails/generators/active_model'
30
- require 'rails/generators/named_base'
31
- require 'rails/railtie'
32
- end
33
-
34
25
  loader = Zeitwerk::Loader.for_gem
35
- unless defined?(Rails)
36
- loader.ignore(File.expand_path('active_graph/generators', __dir__))
37
- loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
38
- end
26
+ loader.ignore(File.expand_path('rails', __dir__))
27
+ loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
39
28
  loader.inflector.inflect("ansi" => "ANSI")
40
29
  loader.setup
41
30
  # loader.eager_load
@@ -49,6 +38,5 @@ Neo4j::Driver::Types::Node.prepend ActiveGraph::Core::Node
49
38
  Neo4j::Driver::Types::Node.wrapper_callback(&ActiveGraph::Node::Wrapping.method(:wrapper))
50
39
  Neo4j::Driver::Types::Relationship.wrapper_callback(&ActiveGraph::Relationship::Wrapping.method(:wrapper))
51
40
  SecureRandom.singleton_class.prepend ActiveGraph::SecureRandomExt
52
- Rails::Generators::GeneratedAttribute.include ActiveGraph::Generators::GeneratedAttribute if defined?(Rails)
53
41
 
54
42
  load 'active_graph/tasks/migration.rake'
@@ -1,8 +1,11 @@
1
+ require_relative '../../migration_helper'
2
+ require_relative '../../source_path_helper'
3
+
1
4
  module ActiveGraph
2
5
  module Generators
3
6
  class MigrationGenerator < ::Rails::Generators::NamedBase
4
- include ::ActiveGraph::Generators::SourcePathHelper
5
- include ::ActiveGraph::Generators::MigrationHelper
7
+ include ActiveGraph::Generators::SourcePathHelper
8
+ include ActiveGraph::Generators::MigrationHelper
6
9
 
7
10
  def create_migration_file
8
11
  migration_template 'migration.erb'
@@ -1,6 +1,9 @@
1
+ require_relative '../../migration_helper'
2
+ require_relative '../../source_path_helper'
3
+
1
4
  class ActiveGraph::Generators::ModelGenerator < Rails::Generators::NamedBase #:nodoc:
2
- include ::ActiveGraph::Generators::SourcePathHelper
3
- include ::ActiveGraph::Generators::MigrationHelper
5
+ include ActiveGraph::Generators::SourcePathHelper
6
+ include ActiveGraph::Generators::MigrationHelper
4
7
 
5
8
  argument :attributes, type: :array, default: [], banner: 'field:type field:type'
6
9
 
@@ -1,8 +1,11 @@
1
+ require_relative '../../migration_helper'
2
+ require_relative '../../source_path_helper'
3
+
1
4
  module ActiveGraph
2
5
  module Generators
3
6
  class UpgradeV8Generator < ::Rails::Generators::Base
4
- include ::ActiveGraph::Generators::SourcePathHelper
5
- include ::ActiveGraph::Generators::MigrationHelper
7
+ include ActiveGraph::Generators::SourcePathHelper
8
+ include ActiveGraph::Generators::MigrationHelper
6
9
 
7
10
  def create_upgrade_v8_file
8
11
  @schema = load_all_models_schema!
@@ -1,3 +1,8 @@
1
+ module ActiveGraph
2
+ module Generators #:nodoc:
3
+ end
4
+ end
5
+
1
6
  module ActiveGraph::Generators::MigrationHelper
2
7
  extend ActiveSupport::Concern
3
8
 
@@ -44,3 +49,55 @@ module ActiveGraph::Generators::MigrationHelper
44
49
  FileUtils.rm(real_file_name) if @behavior == :revoke
45
50
  end
46
51
  end
52
+
53
+ class ActiveGraph::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
54
+ def self.all(klass)
55
+ "#{klass}.all"
56
+ end
57
+
58
+ def self.find(klass, params = nil)
59
+ "#{klass}.find(#{params})"
60
+ end
61
+
62
+ def self.build(klass, params = nil)
63
+ if params
64
+ "#{klass}.new(#{params})"
65
+ else
66
+ "#{klass}.new"
67
+ end
68
+ end
69
+
70
+ def save
71
+ "#{name}.save"
72
+ end
73
+
74
+ def update_attributes(params = nil)
75
+ "#{name}.update_attributes(#{params})"
76
+ end
77
+
78
+ def errors
79
+ "#{name}.errors"
80
+ end
81
+
82
+ def destroy
83
+ "#{name}.destroy"
84
+ end
85
+ end
86
+
87
+ module ActiveGraph
88
+ module Generators
89
+ module GeneratedAttribute #:nodoc:
90
+ def type_class
91
+ case type.to_s.downcase
92
+ when 'any' then 'any'
93
+ when 'datetime' then 'DateTime'
94
+ when 'date' then 'Date'
95
+ when 'integer', 'number', 'fixnum' then 'Integer'
96
+ when 'float' then 'Float'
97
+ else
98
+ 'String'
99
+ end
100
+ end
101
+ end
102
+ end
103
+ end
@@ -4,7 +4,7 @@ module ActiveGraph::Generators::SourcePathHelper
4
4
  module ClassMethods
5
5
  def source_root
6
6
  @_neo4j_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
7
- generator_name, 'templates'))
7
+ 'active_graph', generator_name, 'templates'))
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.5.0.alpha.1
4
+ version: 11.5.0.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-19 00:00:00.000000000 Z
11
+ date: 2023-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.0'
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '4.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '4.0'
26
+ version: '7'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: i18n
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -190,14 +176,14 @@ dependencies:
190
176
  requirements:
191
177
  - - ">="
192
178
  - !ruby/object:Gem::Version
193
- version: '4.0'
179
+ version: '7'
194
180
  type: :development
195
181
  prerelease: false
196
182
  version_requirements: !ruby/object:Gem::Requirement
197
183
  requirements:
198
184
  - - ">="
199
185
  - !ruby/object:Gem::Version
200
- version: '4.0'
186
+ version: '7'
201
187
  - !ruby/object:Gem::Dependency
202
188
  name: rake
203
189
  requirement: !ruby/object:Gem::Requirement
@@ -311,17 +297,6 @@ files:
311
297
  - lib/active_graph/core/schema_errors.rb
312
298
  - lib/active_graph/core/wrappable.rb
313
299
  - lib/active_graph/error.rb
314
- - lib/active_graph/generators/active_model.rb
315
- - lib/active_graph/generators/generated_attribute.rb
316
- - lib/active_graph/generators/migration/templates/migration.erb
317
- - lib/active_graph/generators/migration_generator.rb
318
- - lib/active_graph/generators/migration_helper.rb
319
- - lib/active_graph/generators/model/templates/migration.erb
320
- - lib/active_graph/generators/model/templates/model.erb
321
- - lib/active_graph/generators/model_generator.rb
322
- - lib/active_graph/generators/source_path_helper.rb
323
- - lib/active_graph/generators/upgrade_v8/templates/migration.erb
324
- - lib/active_graph/generators/upgrade_v8_generator.rb
325
300
  - lib/active_graph/lazy_attribute_hash.rb
326
301
  - lib/active_graph/migration.rb
327
302
  - lib/active_graph/migrations.rb
@@ -423,6 +398,15 @@ files:
423
398
  - lib/active_graph/type_converters.rb
424
399
  - lib/active_graph/undeclared_properties.rb
425
400
  - lib/active_graph/version.rb
401
+ - lib/rails/generators/active_graph/migration/migration_generator.rb
402
+ - lib/rails/generators/active_graph/migration/templates/migration.erb
403
+ - lib/rails/generators/active_graph/model/model_generator.rb
404
+ - lib/rails/generators/active_graph/model/templates/migration.erb
405
+ - lib/rails/generators/active_graph/model/templates/model.erb
406
+ - lib/rails/generators/active_graph/upgrade_v8/templates/migration.erb
407
+ - lib/rails/generators/active_graph/upgrade_v8/upgrade_v8_generator.rb
408
+ - lib/rails/generators/migration_helper.rb
409
+ - lib/rails/generators/source_path_helper.rb
426
410
  homepage: https://github.com/neo4jrb/activegraph/
427
411
  licenses:
428
412
  - MIT
@@ -1,33 +0,0 @@
1
- class ActiveGraph::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
2
- def self.all(klass)
3
- "#{klass}.all"
4
- end
5
-
6
- def self.find(klass, params = nil)
7
- "#{klass}.find(#{params})"
8
- end
9
-
10
- def self.build(klass, params = nil)
11
- if params
12
- "#{klass}.new(#{params})"
13
- else
14
- "#{klass}.new"
15
- end
16
- end
17
-
18
- def save
19
- "#{name}.save"
20
- end
21
-
22
- def update_attributes(params = nil)
23
- "#{name}.update_attributes(#{params})"
24
- end
25
-
26
- def errors
27
- "#{name}.errors"
28
- end
29
-
30
- def destroy
31
- "#{name}.destroy"
32
- end
33
- end
@@ -1,17 +0,0 @@
1
- module ActiveGraph
2
- module Generators
3
- module GeneratedAttribute #:nodoc:
4
- def type_class
5
- case type.to_s.downcase
6
- when 'any' then 'any'
7
- when 'datetime' then 'DateTime'
8
- when 'date' then 'Date'
9
- when 'integer', 'number', 'fixnum' then 'Integer'
10
- when 'float' then 'Float'
11
- else
12
- 'String'
13
- end
14
- end
15
- end
16
- end
17
- end