rails_age 0.5.3 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -13
  3. data/README.md +246 -10
  4. data/config/initializers/types.rb +5 -5
  5. data/lib/apache_age/cypher.rb +95 -0
  6. data/lib/apache_age/entities/class_methods.rb +68 -38
  7. data/lib/apache_age/entities/edge.rb +2 -0
  8. data/lib/apache_age/entities/node.rb +3 -1
  9. data/lib/apache_age/entities/path.rb +27 -0
  10. data/lib/apache_age/entities/query_builder.rb +159 -0
  11. data/lib/apache_age/entities/vertex.rb +47 -47
  12. data/lib/apache_age/path.rb +4 -0
  13. data/lib/apache_age/types/{age_type_factory.rb → factory.rb} +3 -3
  14. data/lib/apache_age/validators/{vertex_type_validator copy.rb → node_type_validator.rb} +1 -1
  15. data/lib/apache_age/validators/unique_vertex.rb +27 -27
  16. data/lib/apache_age/validators/vertex_type_validator.rb +15 -0
  17. data/lib/generators/apache_age/edge/USAGE +7 -7
  18. data/lib/generators/apache_age/edge/edge_generator.rb +1 -0
  19. data/lib/generators/apache_age/generator_entity_helpers.rb +1 -9
  20. data/lib/generators/apache_age/node/USAGE +4 -4
  21. data/lib/generators/apache_age/node/node_generator.rb +1 -1
  22. data/lib/generators/apache_age/node/templates/node.rb.tt +2 -2
  23. data/lib/generators/apache_age/scaffold_edge/scaffold_edge_generator.rb +1 -2
  24. data/lib/generators/apache_age/scaffold_node/scaffold_node_generator.rb +1 -2
  25. data/lib/rails_age/version.rb +1 -1
  26. data/lib/rails_age.rb +5 -4
  27. data/lib/tasks/config_types.rake +6 -6
  28. metadata +25 -8
  29. data/lib/apache_age/types/age_type_generator.rb +0 -46
  30. data/lib/generators/apache_age/scaffold_edge/scaffold_node_generator.rb +0 -67
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_age
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bill Tihen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-23 00:00:00.000000000 Z
11
+ date: 2024-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '9.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: ostruct
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: rspec-rails
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -96,21 +110,25 @@ files:
96
110
  - config/routes.rb
97
111
  - db/migrate/20240521062349_add_apache_age.rb
98
112
  - db/schema.rb
113
+ - lib/apache_age/cypher.rb
99
114
  - lib/apache_age/edge.rb
100
115
  - lib/apache_age/entities/class_methods.rb
101
116
  - lib/apache_age/entities/common_methods.rb
102
117
  - lib/apache_age/entities/edge.rb
103
118
  - lib/apache_age/entities/entity.rb
104
119
  - lib/apache_age/entities/node.rb
120
+ - lib/apache_age/entities/path.rb
121
+ - lib/apache_age/entities/query_builder.rb
105
122
  - lib/apache_age/entities/vertex.rb
106
123
  - lib/apache_age/node.rb
107
- - lib/apache_age/types/age_type_factory.rb
108
- - lib/apache_age/types/age_type_generator.rb
124
+ - lib/apache_age/path.rb
125
+ - lib/apache_age/types/factory.rb
109
126
  - lib/apache_age/validators/expected_node_type.rb
127
+ - lib/apache_age/validators/node_type_validator.rb
110
128
  - lib/apache_age/validators/unique_edge.rb
111
129
  - lib/apache_age/validators/unique_node.rb
112
130
  - lib/apache_age/validators/unique_vertex.rb
113
- - lib/apache_age/validators/vertex_type_validator copy.rb
131
+ - lib/apache_age/validators/vertex_type_validator.rb
114
132
  - lib/generators/apache_age/edge/USAGE
115
133
  - lib/generators/apache_age/edge/edge_generator.rb
116
134
  - lib/generators/apache_age/edge/templates/edge.rb.tt
@@ -121,7 +139,6 @@ files:
121
139
  - lib/generators/apache_age/node/templates/node.rb.tt
122
140
  - lib/generators/apache_age/scaffold_edge/USAGE
123
141
  - lib/generators/apache_age/scaffold_edge/scaffold_edge_generator.rb
124
- - lib/generators/apache_age/scaffold_edge/scaffold_node_generator.rb
125
142
  - lib/generators/apache_age/scaffold_edge/templates/controller.rb.tt
126
143
  - lib/generators/apache_age/scaffold_edge/templates/views/_form.html.erb.tt
127
144
  - lib/generators/apache_age/scaffold_edge/templates/views/edit.html.erb.tt
@@ -163,14 +180,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
163
180
  requirements:
164
181
  - - ">="
165
182
  - !ruby/object:Gem::Version
166
- version: '3.0'
183
+ version: '3.2'
167
184
  required_rubygems_version: !ruby/object:Gem::Requirement
168
185
  requirements:
169
186
  - - ">="
170
187
  - !ruby/object:Gem::Version
171
188
  version: '0'
172
189
  requirements: []
173
- rubygems_version: 3.5.10
190
+ rubygems_version: 3.5.18
174
191
  signing_key:
175
192
  specification_version: 4
176
193
  summary: Apache AGE plugin for Rails 7.x
@@ -1,46 +0,0 @@
1
- # lib/apache_age/types/age_type_generator.rb
2
- # Automatically generates ActiveModel::Type classes
3
- # Dynamically builds this (as a concrete example):
4
- # module ApacheAge
5
- # module Types
6
- # class CompanyType < ActiveModel::Type::Value
7
- # def cast(value)
8
- # case value
9
- # when Nodes::Company
10
- # value
11
- # when Hash
12
- # Nodes::Company.new(value)
13
- # else
14
- # nil
15
- # end
16
- # end
17
- # def serialize(value)
18
- # value.is_a?(Nodes::Company) ? value.attributes : nil
19
- # end
20
- # end
21
- # end
22
- # end
23
- module ApacheAge
24
- module Types
25
- class AgeTypeGenerator
26
- def self.create_type_for(klass)
27
- Class.new(ActiveModel::Type::Value) do
28
- define_method(:cast) do |value|
29
- case value
30
- when klass
31
- value
32
- when Hash
33
- klass.new(value)
34
- else
35
- nil
36
- end
37
- end
38
-
39
- define_method(:serialize) do |value|
40
- value.is_a?(klass) ? value.attributes : nil
41
- end
42
- end
43
- end
44
- end
45
- end
46
- end
@@ -1,67 +0,0 @@
1
- # lib/generators/apache_age/scaffold_node/scaffold_node_generator.rb
2
-
3
- require 'rails/generators'
4
- require 'rails/generators/named_base'
5
- require 'rails/generators/resource_helpers'
6
-
7
- module ApacheAge
8
- class ScaffoldNodeGenerator < Rails::Generators::NamedBase
9
- include Rails::Generators::ResourceHelpers
10
-
11
- desc "Generates a node, and its controller and views with the given attributes."
12
-
13
- source_root File.expand_path("templates", __dir__)
14
-
15
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
16
-
17
- def create_model_file
18
- invoke 'apache_age:edge', [name] + attributes.collect { |attr| "#{attr.name}:#{attr.type}" }
19
- end
20
-
21
- def create_controller_files
22
- template(
23
- "controller.rb.tt",
24
- File.join(Rails.root, "app/controllers", controller_class_path, "#{controller_file_name}_controller.rb")
25
- )
26
- end
27
-
28
- def create_route
29
- route_content = route_text(class_path, file_name)
30
- inject_into_file(
31
- File.join(Rails.root, 'config', 'routes.rb'), "\n#{route_content}",
32
- after: "Rails.application.routes.draw do"
33
- )
34
- end
35
-
36
- def copy_view_files
37
- available_views.each do |view|
38
- view_name = view == 'partial' ? "_#{singular_table_name}" : view
39
- filename = filename_with_extensions(view_name)
40
- template(
41
- "views/#{view}.html.erb.tt",
42
- File.join(Rails.root, "app/views", controller_file_path, filename)
43
- )
44
- end
45
- end
46
-
47
- private
48
-
49
- def available_views
50
- %w[index edit show new partial _form]
51
- end
52
-
53
- def filename_with_extensions(view)
54
- [view, :html, :erb].compact.join('.')
55
- end
56
-
57
- def route_text(class_path, file_name)
58
- return " resources :#{file_name.pluralize}" if class_path.empty?
59
-
60
- <<-RUBY
61
- namespace :#{class_path.join(':')} do
62
- resources :#{file_name.pluralize}
63
- end
64
- RUBY
65
- end
66
- end
67
- end