activegraph 11.0.0.beta.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +2016 -0
  3. data/CONTRIBUTORS +12 -0
  4. data/Gemfile +24 -0
  5. data/README.md +111 -0
  6. data/activegraph.gemspec +52 -0
  7. data/bin/rake +17 -0
  8. data/config/locales/en.yml +5 -0
  9. data/config/neo4j/add_classnames.yml +1 -0
  10. data/config/neo4j/config.yml +35 -0
  11. data/lib/active_graph.rb +123 -0
  12. data/lib/active_graph/ansi.rb +14 -0
  13. data/lib/active_graph/attribute_set.rb +32 -0
  14. data/lib/active_graph/base.rb +77 -0
  15. data/lib/active_graph/class_arguments.rb +39 -0
  16. data/lib/active_graph/config.rb +135 -0
  17. data/lib/active_graph/core.rb +14 -0
  18. data/lib/active_graph/core/connection_failed_error.rb +6 -0
  19. data/lib/active_graph/core/cypher_error.rb +37 -0
  20. data/lib/active_graph/core/entity.rb +11 -0
  21. data/lib/active_graph/core/instrumentable.rb +37 -0
  22. data/lib/active_graph/core/label.rb +135 -0
  23. data/lib/active_graph/core/logging.rb +44 -0
  24. data/lib/active_graph/core/node.rb +15 -0
  25. data/lib/active_graph/core/querable.rb +41 -0
  26. data/lib/active_graph/core/query.rb +485 -0
  27. data/lib/active_graph/core/query_builder.rb +18 -0
  28. data/lib/active_graph/core/query_clauses.rb +727 -0
  29. data/lib/active_graph/core/query_ext.rb +24 -0
  30. data/lib/active_graph/core/query_find_in_batches.rb +46 -0
  31. data/lib/active_graph/core/record.rb +51 -0
  32. data/lib/active_graph/core/result.rb +31 -0
  33. data/lib/active_graph/core/schema.rb +65 -0
  34. data/lib/active_graph/core/schema_errors.rb +12 -0
  35. data/lib/active_graph/core/wrappable.rb +30 -0
  36. data/lib/active_graph/errors.rb +59 -0
  37. data/lib/active_graph/lazy_attribute_hash.rb +38 -0
  38. data/lib/active_graph/migration.rb +148 -0
  39. data/lib/active_graph/migrations.rb +27 -0
  40. data/lib/active_graph/migrations/base.rb +77 -0
  41. data/lib/active_graph/migrations/check_pending.rb +20 -0
  42. data/lib/active_graph/migrations/helpers.rb +105 -0
  43. data/lib/active_graph/migrations/helpers/id_property.rb +72 -0
  44. data/lib/active_graph/migrations/helpers/relationships.rb +66 -0
  45. data/lib/active_graph/migrations/helpers/schema.rb +63 -0
  46. data/lib/active_graph/migrations/migration_file.rb +24 -0
  47. data/lib/active_graph/migrations/runner.rb +195 -0
  48. data/lib/active_graph/migrations/schema.rb +64 -0
  49. data/lib/active_graph/migrations/schema_migration.rb +14 -0
  50. data/lib/active_graph/model_schema.rb +139 -0
  51. data/lib/active_graph/node.rb +110 -0
  52. data/lib/active_graph/node/callbacks.rb +8 -0
  53. data/lib/active_graph/node/dependent.rb +11 -0
  54. data/lib/active_graph/node/dependent/association_methods.rb +49 -0
  55. data/lib/active_graph/node/dependent/query_proxy_methods.rb +52 -0
  56. data/lib/active_graph/node/dependent_callbacks.rb +31 -0
  57. data/lib/active_graph/node/enum.rb +26 -0
  58. data/lib/active_graph/node/has_n.rb +602 -0
  59. data/lib/active_graph/node/has_n/association.rb +278 -0
  60. data/lib/active_graph/node/has_n/association/rel_factory.rb +61 -0
  61. data/lib/active_graph/node/has_n/association/rel_wrapper.rb +23 -0
  62. data/lib/active_graph/node/has_n/association_cypher_methods.rb +108 -0
  63. data/lib/active_graph/node/id_property.rb +224 -0
  64. data/lib/active_graph/node/id_property/accessor.rb +62 -0
  65. data/lib/active_graph/node/initialize.rb +21 -0
  66. data/lib/active_graph/node/labels.rb +207 -0
  67. data/lib/active_graph/node/labels/index.rb +37 -0
  68. data/lib/active_graph/node/labels/reloading.rb +21 -0
  69. data/lib/active_graph/node/node_list_formatter.rb +13 -0
  70. data/lib/active_graph/node/node_wrapper.rb +54 -0
  71. data/lib/active_graph/node/orm_adapter.rb +82 -0
  72. data/lib/active_graph/node/persistence.rb +186 -0
  73. data/lib/active_graph/node/property.rb +60 -0
  74. data/lib/active_graph/node/query.rb +76 -0
  75. data/lib/active_graph/node/query/query_proxy.rb +367 -0
  76. data/lib/active_graph/node/query/query_proxy_eager_loading.rb +177 -0
  77. data/lib/active_graph/node/query/query_proxy_eager_loading/association_tree.rb +75 -0
  78. data/lib/active_graph/node/query/query_proxy_enumerable.rb +110 -0
  79. data/lib/active_graph/node/query/query_proxy_find_in_batches.rb +19 -0
  80. data/lib/active_graph/node/query/query_proxy_link.rb +139 -0
  81. data/lib/active_graph/node/query/query_proxy_methods.rb +303 -0
  82. data/lib/active_graph/node/query/query_proxy_methods_of_mass_updating.rb +99 -0
  83. data/lib/active_graph/node/query_methods.rb +68 -0
  84. data/lib/active_graph/node/reflection.rb +86 -0
  85. data/lib/active_graph/node/rels.rb +11 -0
  86. data/lib/active_graph/node/scope.rb +166 -0
  87. data/lib/active_graph/node/unpersisted.rb +48 -0
  88. data/lib/active_graph/node/validations.rb +59 -0
  89. data/lib/active_graph/paginated.rb +27 -0
  90. data/lib/active_graph/railtie.rb +108 -0
  91. data/lib/active_graph/relationship.rb +68 -0
  92. data/lib/active_graph/relationship/callbacks.rb +21 -0
  93. data/lib/active_graph/relationship/initialize.rb +28 -0
  94. data/lib/active_graph/relationship/persistence.rb +133 -0
  95. data/lib/active_graph/relationship/persistence/query_factory.rb +95 -0
  96. data/lib/active_graph/relationship/property.rb +92 -0
  97. data/lib/active_graph/relationship/query.rb +99 -0
  98. data/lib/active_graph/relationship/rel_wrapper.rb +31 -0
  99. data/lib/active_graph/relationship/related_node.rb +87 -0
  100. data/lib/active_graph/relationship/types.rb +80 -0
  101. data/lib/active_graph/relationship/validations.rb +8 -0
  102. data/lib/active_graph/schema/operation.rb +102 -0
  103. data/lib/active_graph/shared.rb +48 -0
  104. data/lib/active_graph/shared/attributes.rb +217 -0
  105. data/lib/active_graph/shared/callbacks.rb +66 -0
  106. data/lib/active_graph/shared/cypher.rb +37 -0
  107. data/lib/active_graph/shared/declared_properties.rb +204 -0
  108. data/lib/active_graph/shared/declared_property.rb +109 -0
  109. data/lib/active_graph/shared/declared_property/index.rb +37 -0
  110. data/lib/active_graph/shared/enum.rb +167 -0
  111. data/lib/active_graph/shared/filtered_hash.rb +79 -0
  112. data/lib/active_graph/shared/identity.rb +34 -0
  113. data/lib/active_graph/shared/initialize.rb +65 -0
  114. data/lib/active_graph/shared/marshal.rb +23 -0
  115. data/lib/active_graph/shared/mass_assignment.rb +63 -0
  116. data/lib/active_graph/shared/permitted_attributes.rb +28 -0
  117. data/lib/active_graph/shared/persistence.rb +272 -0
  118. data/lib/active_graph/shared/property.rb +249 -0
  119. data/lib/active_graph/shared/query_factory.rb +122 -0
  120. data/lib/active_graph/shared/rel_type_converters.rb +43 -0
  121. data/lib/active_graph/shared/serialized_properties.rb +30 -0
  122. data/lib/active_graph/shared/type_converters.rb +439 -0
  123. data/lib/active_graph/shared/typecasted_attributes.rb +99 -0
  124. data/lib/active_graph/shared/typecaster.rb +53 -0
  125. data/lib/active_graph/shared/validations.rb +44 -0
  126. data/lib/active_graph/tasks/migration.rake +204 -0
  127. data/lib/active_graph/timestamps.rb +11 -0
  128. data/lib/active_graph/timestamps/created.rb +9 -0
  129. data/lib/active_graph/timestamps/updated.rb +9 -0
  130. data/lib/active_graph/transaction.rb +22 -0
  131. data/lib/active_graph/transactions.rb +57 -0
  132. data/lib/active_graph/type_converters.rb +7 -0
  133. data/lib/active_graph/undeclared_properties.rb +53 -0
  134. data/lib/active_graph/version.rb +3 -0
  135. data/lib/active_graph/wrapper.rb +4 -0
  136. data/lib/rails/generators/active_graph/migration/migration_generator.rb +16 -0
  137. data/lib/rails/generators/active_graph/migration/templates/migration.erb +9 -0
  138. data/lib/rails/generators/active_graph/model/model_generator.rb +89 -0
  139. data/lib/rails/generators/active_graph/model/templates/migration.erb +11 -0
  140. data/lib/rails/generators/active_graph/model/templates/model.erb +15 -0
  141. data/lib/rails/generators/active_graph/upgrade_v8/templates/migration.erb +17 -0
  142. data/lib/rails/generators/active_graph/upgrade_v8/upgrade_v8_generator.rb +34 -0
  143. data/lib/rails/generators/active_graph_generator.rb +121 -0
  144. metadata +423 -0
@@ -0,0 +1,12 @@
1
+ Maintainers:
2
+ Heinrich Klobuczek <klobuczek @ GitHub>
3
+ Amit Suryanvanshi <amitsuryavanshi @ GitHub>
4
+
5
+ Previous Maintainers:
6
+ Chris Grigg <subvertallchris @ GitHub>
7
+ Brian Underwood <cheerfulstoic @ GitHub>
8
+
9
+ Creator:
10
+ Andreas Ronge <andreasronge @ GitHub>
11
+
12
+ See: https://github.com/neo4jrb/neo4j/graphs/contributors
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ # gem "neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", path: '../neo4j-ruby-driver'
6
+
7
+ gem 'listen', '< 3.1'
8
+
9
+ active_model_version = ENV['ACTIVE_MODEL_VERSION']
10
+ gem 'activemodel', "~> #{active_model_version}" if active_model_version
11
+
12
+ group 'test' do
13
+ gem 'coveralls', require: false
14
+ gem 'overcommit'
15
+ gem 'codecov', require: false
16
+ gem 'simplecov', require: false
17
+ gem 'simplecov-html', require: false
18
+ gem 'rspec', '~> 3.4'
19
+ gem 'its'
20
+ gem 'test-unit'
21
+ gem 'colored'
22
+ gem 'dotenv'
23
+ gem 'timecop'
24
+ end
@@ -0,0 +1,111 @@
1
+ # Welcome to Active Graph (f.k.a. Neo4j.rb)
2
+
3
+ ## Code Status
4
+
5
+ [![Actively Maintained](https://img.shields.io/badge/Maintenance%20Level-Actively%20Maintained-green.svg)](https://gist.github.com/cheerfulstoic/d107229326a01ff0f333a1d3476e068d)
6
+ [![Build Status](https://secure.travis-ci.org/neo4jrb/neo4j.svg?branch=master)](http://travis-ci.org/neo4jrb/neo4j)
7
+ [![Coverage Status](https://coveralls.io/repos/neo4jrb/neo4j/badge.svg?branch=master)](https://coveralls.io/r/neo4jrb/neo4j?branch=master)
8
+ [![Code Climate](https://codeclimate.com/github/neo4jrb/neo4j.svg)](https://codeclimate.com/github/neo4jrb/neo4j)
9
+
10
+ ## Get Support
11
+
12
+ ### Documentation
13
+
14
+ All new documentation will be done via our [readthedocs](http://neo4jrb.readthedocs.org) site, though some old documentation has yet to be moved from our [wiki](https://github.com/neo4jrb/neo4j/wiki)
15
+
16
+ ### Contact Us
17
+
18
+ [![StackOverflow](https://img.shields.io/badge/StackOverflow-Ask%20a%20question!-blue.svg)](http://stackoverflow.com/questions/ask?tags=neo4j.rb+neo4j+ruby) [![Gitter](https://img.shields.io/badge/Gitter-Join%20our%20chat!-blue.svg)](https://gitter.im/neo4jrb/neo4j?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Twitter](https://img.shields.io/badge/Twitter-Tweet%20with%20us!-blue.svg)](https://twitter.com/neo4jrb)
19
+
20
+
21
+
22
+ # Introduction
23
+
24
+ Neo4j.rb is an Active Model compliant Ruby/JRuby wrapper for [the Neo4j graph database](http://www.neo4j.org/). It uses the [neo4j-ruby-driver](https://github.com/neo4jrb/neo4j-ruby-driver) and [active_attr](https://github.com/cgriego/active_attr) gems.
25
+
26
+ Neo4j is a transactional, open-source graph database. A graph database manages data in a connected data structure, capable of representing any kind of data in a very accessible way. Information is stored in nodes and relationships connecting them, both of which can have arbitrary properties. To learn more visit [What is a Graph Database?](http://neo4j.com/developer/graph-database/)
27
+
28
+ With this gem you not only do you get a convenient higher level wrapper around Neo4j, but you have access to a powerful high-level query building interface which lets you take advantage of the power of Neo4j like this:
29
+
30
+ ```ruby
31
+ # Break down the top countries where friends' favorite beers come from
32
+ person.friends.favorite_beers.country_of_origin(:country).
33
+ order('count(country) DESC').
34
+ pluck(:country, count: 'count(country)')
35
+ ```
36
+
37
+ It can be installed in your `Gemfile` with a simple `gem 'neo4j'`
38
+
39
+ For a general overview see our website: http://neo4jrb.io/
40
+
41
+ Winner of a 2014 Graphie for "Best Community Contribution" at Neo4j's [Graph Connect](http://graphconnect.com) conference!
42
+ ![2014 Graphie](http://i.imgur.com/CkOoTTYm.jpg)
43
+
44
+ Neo4j.rb v4.1.0 was released in January of 2015. Its changes are outlined [here](https://github.com/neo4jrb/neo4j/wiki/Neo4j.rb-v4-Introduction) and in the [announcement message](http://neo4jrb.io/blog/2015/01/09/neo4j-rb_v4-1_released.html). It will take a little time before all documentation is updated to reflect the new release but unless otherwise noted, all 3.X documentation is totally valid for v4.
45
+
46
+ ## Neo4j version support
47
+
48
+ | **Neo4j Version** | v2.x | v3.x | >= v4.x | >= 7.0.3 | activegraph 10.0 |
49
+ |-------------------|------|-------|---------|----------|------------------|
50
+ | 1.9.x | Yes | No | No | No | No |
51
+ | 2.0.x | No | Yes | No | No | No |
52
+ | 2.1.x | No | Yes | Yes * | Yes | No |
53
+ | 2.2.x | No | No | Yes | Yes | No |
54
+ | 2.3.x | No | No | Yes | Yes | No |
55
+ | 3.0, 3.1, 3.3 | No | No | No | Yes | No |
56
+ | 3.4, 3.5 | No | No | No | Yes | Yes |
57
+ | 4.0 | No | No | No | No | Yes |
58
+ | 4.1 | No | No | No | No | No |
59
+
60
+ `*` Neo4j.rb >= 4.x doesn't support Neo4j versions before 2.1.5. To use 2.1.x you should upgrade to a version >= 2.1.5
61
+
62
+ ## Neo4j feature support
63
+
64
+ | **Neo4j Feature** | v2.x | v3.x | >= v4.x | >= 8.x | activegraph 10.0 |
65
+ |----------------------------|--------|------|---------|--------|------------------|
66
+ | Bolt Protocol | No | No | No | Yes | Yes |
67
+ | Auth | No | No | Yes | Yes | Yes |
68
+ | Remote Cypher | Yes | Yes | Yes | Yes | No |
69
+ | Transactions | Yes | Yes | Yes | Yes | Yes |
70
+ | High Availability | No | Yes | Yes | Yes | Yes |
71
+ | Causal Cluster | No | No | No | No | Yes |
72
+ | Embedded JVM support | Yes | Yes | Yes | Yes | via bolt only |
73
+
74
+ ## Documentation
75
+
76
+ * [Website](http://neo4jrb.io/) (for an introduction)
77
+ * [readthedocs](http://neo4jrb.readthedocs.io/)
78
+ * **Note:** Our GitHub Wiki pages have outdated information. We are in the process of moving all documentation to [readthedocs](http://neo4jrb.readthedocs.io/)
79
+
80
+ ## Legacy (<= 2.x) Documentation
81
+
82
+ * [README](https://github.com/neo4jrb/neo4j/tree/2.x)
83
+ * [Wiki](https://github.com/neo4jrb/neo4j/wiki/Neo4j%3A%3ARails-Introduction)
84
+
85
+ ## Developers
86
+
87
+ ### Original Author
88
+
89
+ * [Andreas Ronge](https://github.com/andreasronge)
90
+
91
+ ### Previous Maintainers
92
+
93
+ * [Brian Underwood](https://github.com/cheerfulstoic)
94
+ * [Chris Grigg](https://github.com/subvertallchris)
95
+
96
+ ### Current Maintainers
97
+
98
+ * [Heinrich Klobuczek](https://github.com/klobuczek)
99
+ * [Amit Suryavanshi](https://github.com/amitsuryavanshi)
100
+
101
+ ## Contributing
102
+
103
+ Always welcome! Please review the [guidelines for contributing](CONTRIBUTING.md) to this repository.
104
+
105
+ ## License
106
+
107
+ * Neo4j.rb - MIT, see the [LICENSE](http://github.com/andreasronge/neo4j/tree/master/LICENSE).
108
+ * Neo4j - Dual free software/commercial license, see [Licensing Guide](http://www.neo4j.org/learn/licensing).
109
+
110
+ **Notice:** There are different licenses for the `neo4j-community`, `neo4j-advanced`, and `neo4j-enterprise` jar gems. Only the `neo4j-community` gem is required by default.
111
+
@@ -0,0 +1,52 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
3
+
4
+ require 'active_graph/version'
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = 'activegraph'
8
+ s.version = ActiveGraph::VERSION
9
+
10
+ s.required_ruby_version = '>= 2.5'
11
+
12
+ s.authors = 'Andreas Ronge, Brian Underwood, Chris Grigg, Heinrich Klobuczek'
13
+ s.email = 'andreas.ronge@gmail.com, public@brian-underwood.codes, chris@subvertallmedia.com, heinrich@mail.com'
14
+ s.homepage = 'https://github.com/neo4jrb/activegraph/'
15
+ s.summary = 'A graph database for Ruby'
16
+ s.license = 'MIT'
17
+ s.description = <<-DESCRIPTION
18
+ A Neo4j OGM (Object-Graph-Mapper) for Ruby heavily inspired by ActiveRecord.
19
+ DESCRIPTION
20
+
21
+ s.require_path = 'lib'
22
+ s.files = Dir.glob('{bin,lib,config}/**/*') + %w(README.md CHANGELOG.md CONTRIBUTORS Gemfile activegraph.gemspec)
23
+ s.executables = []
24
+ s.extra_rdoc_files = %w( README.md )
25
+ s.rdoc_options = ['--quiet', '--title', 'Neo4j.rb', '--line-numbers', '--main', 'README.rdoc', '--inline-source']
26
+ s.metadata = {
27
+ 'homepage_uri' => 'http://neo4jrb.io/',
28
+ 'changelog_uri' => 'https://github.com/neo4jrb/activegraph/blob/master/CHANGELOG.md',
29
+ 'source_code_uri' => 'https://github.com/neo4jrb/activegraph/',
30
+ 'bug_tracker_uri' => 'https://github.com/neo4jrb/activegraph/issues'
31
+ }
32
+
33
+ s.platform = 'java'
34
+
35
+ s.add_dependency('activemodel', '>= 4.0')
36
+ s.add_dependency('activesupport', '>= 4.0')
37
+ s.add_dependency('i18n', '!= 1.3.0') # version 1.3.0 introduced a bug with `symbolize_key`
38
+ s.add_dependency('orm_adapter', '~> 0.5.0')
39
+ s.add_dependency("neo4j-java-driver", '~> 4.1.0.beta.1')
40
+ s.add_development_dependency('guard')
41
+ s.add_development_dependency('guard-rspec')
42
+ s.add_development_dependency('guard-rubocop')
43
+ s.add_development_dependency('neo4j-rake_tasks', '>= 0.3.0')
44
+ # s.add_development_dependency("neo4j-#{ENV['driver'] == 'java' ? 'java' : 'ruby'}-driver", '~> 4.1.0.beta.1')
45
+ s.add_development_dependency('os')
46
+ s.add_development_dependency('pry')
47
+ s.add_development_dependency('railties', '>= 4.0')
48
+ s.add_development_dependency('rake')
49
+ s.add_development_dependency('rubocop', '>= 0.56.0')
50
+ s.add_development_dependency('yard')
51
+ s.add_development_dependency('dryspec')
52
+ end
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+ #
4
+ # This file was generated by Bundler.
5
+ #
6
+ # The application 'rake' is installed as part of a gem, and
7
+ # this file is here to facilitate running it.
8
+ #
9
+
10
+ require 'pathname'
11
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
12
+ Pathname.new(__FILE__).realpath)
13
+
14
+ require 'rubygems'
15
+ require 'bundler/setup'
16
+
17
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,5 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ nil: "can't be nil"
5
+ taken: "has already been taken"
@@ -0,0 +1 @@
1
+ # This file is used as the source for adding _classname properties to nodes and relationships.
@@ -0,0 +1,35 @@
1
+ #=== Neo4j.rb configuration settings
2
+
3
+
4
+ # Examples of not using the Neo4j id (neo_id)
5
+
6
+ # Generated UUID stored as a neo4j property on my_id
7
+ #id_property: my_id
8
+ #id_property_type: :auto
9
+ #id_property_type_value: :uuid
10
+
11
+ # Example, (probably more useful directly on ActiveGraph::Node classes instead as a global configuration)
12
+ #id_property: title_id
13
+ #id_property_type: :on
14
+ #id_property_type_value: :some_method
15
+
16
+ # TODO
17
+ # if identity map should be on or not
18
+ # It may impact the performance. Using the identity map will keep all loaded wrapper node/relationship
19
+ # object in memory for each thread and transaction - which may speed up or slow down operations.
20
+ identity_map: false
21
+
22
+ # TODO
23
+ # When using the ActiveGraph::Model you can let neo4j automatically set timestamps when updating/creating nodes.
24
+ # If set to true neo4j.rb automatically timestamps create and update operations if the model has properties named created_at/created_on or updated_at/updated_on
25
+ # (similar to ActiveRecord).
26
+ timestamps: true
27
+
28
+ # Store a property on objects to cache their Node/Relationship class. It prevents each object load from requiring two database queries.
29
+ # Strings shorter than 44 characters are classified, so this will have almost no impact on disk footprint. See http://docs.neo4j.org/chunked/stable/short-strings.html.
30
+ # Alternatively, call class method ActiveGraph::Node:cache_class to set this on specific models.
31
+ # By default, this property is called _classname, set as symbol to override.
32
+ cache_class_names: true
33
+ # class_name_property: :_classname
34
+
35
+ transform_rel_type: :upcase
@@ -0,0 +1,123 @@
1
+ require 'forwardable'
2
+ require 'active_graph/version'
3
+
4
+ require 'active_graph/core'
5
+ require 'active_graph/core/query_ext' # From this gem
6
+
7
+ require 'active_support/core_ext/module/attribute_accessors_per_thread'
8
+ require 'active_graph/transactions'
9
+ require 'active_graph/base'
10
+ require 'active_graph/model_schema'
11
+
12
+ require 'active_model'
13
+ require 'active_support/concern'
14
+ require 'active_support/core_ext/class/attribute.rb'
15
+ require 'active_support/core_ext/class/subclasses.rb'
16
+ require 'active_support/core_ext/module/attribute_accessors'
17
+ require 'json'
18
+
19
+ require 'active_graph/lazy_attribute_hash'
20
+ require 'active_graph/attribute_set'
21
+ require 'active_graph/errors'
22
+ require 'active_graph/config'
23
+ require 'active_graph/wrapper'
24
+ require 'active_graph/relationship/rel_wrapper'
25
+ require 'active_graph/node/node_wrapper'
26
+ require 'active_graph/shared/type_converters'
27
+ require 'active_graph/shared/rel_type_converters'
28
+ require 'active_graph/shared/marshal'
29
+ require 'active_graph/type_converters'
30
+ require 'active_graph/paginated'
31
+ require 'active_graph/schema/operation'
32
+
33
+ require 'active_graph/timestamps'
34
+ require 'active_graph/undeclared_properties'
35
+
36
+ require 'active_graph/shared/callbacks'
37
+ require 'active_graph/shared/filtered_hash'
38
+ require 'active_graph/shared/declared_property/index'
39
+ require 'active_graph/shared/declared_property'
40
+ require 'active_graph/shared/declared_properties'
41
+ require 'active_graph/shared/enum'
42
+ require 'active_graph/shared/mass_assignment'
43
+ require 'active_graph/shared/attributes'
44
+ require 'active_graph/shared/typecasted_attributes'
45
+ require 'active_graph/shared/property'
46
+ require 'active_graph/shared/persistence'
47
+ require 'active_graph/shared/validations'
48
+ require 'active_graph/shared/identity'
49
+ require 'active_graph/shared/serialized_properties'
50
+ require 'active_graph/shared/typecaster'
51
+ require 'active_graph/shared/initialize'
52
+ require 'active_graph/shared/query_factory'
53
+ require 'active_graph/shared/cypher'
54
+ require 'active_graph/shared/permitted_attributes'
55
+ require 'active_graph/shared'
56
+
57
+ require 'active_graph/relationship/callbacks'
58
+ require 'active_graph/relationship/initialize'
59
+ require 'active_graph/relationship/property'
60
+ require 'active_graph/relationship/persistence/query_factory'
61
+ require 'active_graph/relationship/persistence'
62
+ require 'active_graph/relationship/validations'
63
+ require 'active_graph/relationship/query'
64
+ require 'active_graph/relationship/related_node'
65
+ require 'active_graph/relationship/types'
66
+ require 'active_graph/relationship'
67
+
68
+ require 'active_graph/node/dependent_callbacks'
69
+ require 'active_graph/node/node_list_formatter'
70
+ require 'active_graph/node/dependent'
71
+ require 'active_graph/node/dependent/query_proxy_methods'
72
+ require 'active_graph/node/dependent/association_methods'
73
+ require 'active_graph/node/enum'
74
+ require 'active_graph/node/query_methods'
75
+ require 'active_graph/node/query/query_proxy_methods'
76
+ require 'active_graph/node/query/query_proxy_methods_of_mass_updating'
77
+ require 'active_graph/node/query/query_proxy_enumerable'
78
+ require 'active_graph/node/query/query_proxy_find_in_batches'
79
+ require 'active_graph/node/query/query_proxy_eager_loading'
80
+ require 'active_graph/node/query/query_proxy_eager_loading/association_tree'
81
+ require 'active_graph/node/query/query_proxy_link'
82
+ require 'active_graph/node/labels/index'
83
+ require 'active_graph/node/labels/reloading'
84
+ require 'active_graph/node/labels'
85
+ require 'active_graph/node/id_property/accessor'
86
+ require 'active_graph/node/id_property'
87
+ require 'active_graph/node/callbacks'
88
+ require 'active_graph/node/initialize'
89
+ require 'active_graph/node/property'
90
+ require 'active_graph/node/persistence'
91
+ require 'active_graph/node/validations'
92
+ require 'active_graph/node/rels'
93
+ require 'active_graph/node/reflection'
94
+ require 'active_graph/node/unpersisted'
95
+ require 'active_graph/node/has_n'
96
+ require 'active_graph/node/has_n/association_cypher_methods'
97
+ require 'active_graph/node/has_n/association/rel_wrapper'
98
+ require 'active_graph/node/has_n/association/rel_factory'
99
+ require 'active_graph/node/has_n/association'
100
+ require 'active_graph/node/query/query_proxy'
101
+ require 'active_graph/node/query'
102
+ require 'active_graph/node/scope'
103
+ require 'active_graph/node'
104
+
105
+ require 'active_support/concern'
106
+ require 'active_graph/core/cypher_error'
107
+ require 'active_graph/core/schema_errors'
108
+
109
+ module ActiveGraph
110
+ extend ActiveSupport::Autoload
111
+ autoload :Migrations
112
+ autoload :Migration
113
+ end
114
+
115
+ load 'active_graph/tasks/migration.rake'
116
+
117
+ require 'active_graph/node/orm_adapter'
118
+ if defined?(Rails)
119
+ require 'rails/generators'
120
+ require 'rails/generators/active_graph_generator'
121
+ end
122
+
123
+ Neo4j::Driver::Transaction.prepend ActiveGraph::Transaction
@@ -0,0 +1,14 @@
1
+ module ActiveGraph
2
+ module ANSI
3
+ CLEAR = "\e[0m"
4
+ BOLD = "\e[1m"
5
+
6
+ RED = "\e[31m"
7
+ GREEN = "\e[32m"
8
+ YELLOW = "\e[33m"
9
+ BLUE = "\e[34m"
10
+ MAGENTA = "\e[35m"
11
+ CYAN = "\e[36m"
12
+ WHITE = "\e[37m"
13
+ end
14
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_model/attribute_set'
4
+
5
+ module ActiveGraph
6
+ class AttributeSet < ActiveModel::AttributeSet
7
+ def initialize(attr_hash, attr_list)
8
+ hashmap = ActiveGraph::LazyAttributeHash.new(attr_hash, attr_list)
9
+ super(hashmap)
10
+ end
11
+
12
+ def method_missing(name, *args, **kwargs, &block)
13
+ if defined?(name)
14
+ attributes.send(:materialize).send(name, *args, **kwargs, &block)
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def respond_to_missing?(method, *)
21
+ attributes.send(:materialize).respond_to?(method) || super
22
+ end
23
+
24
+ def keys
25
+ attributes.send(:materialize).keys
26
+ end
27
+
28
+ def ==(other)
29
+ other.is_a?(ActiveGraph::AttributeSet) ? super : to_hash == other
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,77 @@
1
+ require 'active_graph/core/querable'
2
+ require 'active_graph/core/schema'
3
+
4
+ module ActiveGraph
5
+ # To contain any base login for Node/Relationship which
6
+ # is external to the main classes
7
+ module Base
8
+ include ActiveGraph::Transactions
9
+ include ActiveGraph::Core::Querable
10
+ extend ActiveGraph::Core::Schema
11
+
12
+ at_exit do
13
+ @driver&.close
14
+ end
15
+
16
+ class << self
17
+ # private?
18
+ def driver
19
+ (@driver ||= establish_driver).tap do |driver|
20
+ fail 'No driver defined!' if driver.nil?
21
+ end
22
+ end
23
+
24
+ def on_establish_driver(&block)
25
+ @establish_driver_block = block
26
+ end
27
+
28
+ def establish_driver
29
+ @establish_driver_block.call if @establish_driver_block
30
+ end
31
+
32
+ def query(*args)
33
+ transaction(implicit: true) do
34
+ super(*args)
35
+ end
36
+ end
37
+
38
+ # Should support setting driver via config options
39
+ def driver=(driver)
40
+ @driver&.close
41
+ @driver = driver
42
+ end
43
+
44
+ def validating_transaction(&block)
45
+ validate_model_schema!
46
+ transaction(&block)
47
+ end
48
+
49
+ def new_query(options = {})
50
+ validate_model_schema!
51
+ ActiveGraph::Core::Query.new(options)
52
+ end
53
+
54
+ def magic_query(*args)
55
+ if args.empty? || args.map(&:class) == [Hash]
56
+ new_query(*args)
57
+ else
58
+ query(*args)
59
+ end
60
+ end
61
+
62
+ def label_object(label_name)
63
+ ActiveGraph::Core::Label.new(label_name)
64
+ end
65
+
66
+ def logger
67
+ @logger ||= (ActiveGraph::Config[:logger] || ActiveSupport::Logger.new(STDOUT))
68
+ end
69
+
70
+ private
71
+
72
+ def validate_model_schema!
73
+ ActiveGraph::ModelSchema.validate_model_schema! unless ActiveGraph::Migrations.currently_running_migrations
74
+ end
75
+ end
76
+ end
77
+ end