activerecord-spatial 2.0.0 → 3.0.0

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 (49) hide show
  1. checksums.yaml +5 -5
  2. data/.rubocop.yml +3314 -1052
  3. data/.travis.yml +17 -0
  4. data/Gemfile +1 -0
  5. data/MIT-LICENSE +1 -1
  6. data/README.rdoc +6 -12
  7. data/activerecord-spatial.gemspec +1 -1
  8. data/lib/activerecord-spatial.rb +1 -0
  9. data/lib/activerecord-spatial/active_record.rb +1 -0
  10. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions.rb +1 -0
  11. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions/active_record.rb +4 -3
  12. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/postgis.rb +1 -0
  13. data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/unknown_srid.rb +2 -1
  14. data/lib/activerecord-spatial/active_record/models/geography_column.rb +1 -0
  15. data/lib/activerecord-spatial/active_record/models/geometry_column.rb +1 -0
  16. data/lib/activerecord-spatial/active_record/models/spatial_column.rb +1 -0
  17. data/lib/activerecord-spatial/active_record/models/spatial_ref_sys.rb +1 -0
  18. data/lib/activerecord-spatial/associations.rb +4 -12
  19. data/lib/activerecord-spatial/associations/active_record.rb +96 -54
  20. data/lib/activerecord-spatial/associations/base.rb +2 -19
  21. data/lib/activerecord-spatial/associations/reflection/spatial_reflection.rb +1 -0
  22. data/lib/activerecord-spatial/associations/spatial_association.rb +41 -0
  23. data/lib/activerecord-spatial/spatial_columns.rb +1 -0
  24. data/lib/activerecord-spatial/spatial_function.rb +2 -1
  25. data/lib/activerecord-spatial/spatial_scope_constants.rb +1 -0
  26. data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_0.rb +1 -0
  27. data/lib/activerecord-spatial/spatial_scope_constants/postgis_2_2.rb +1 -0
  28. data/lib/activerecord-spatial/spatial_scope_constants/postgis_legacy.rb +1 -0
  29. data/lib/activerecord-spatial/spatial_scopes.rb +14 -13
  30. data/lib/activerecord-spatial/version.rb +2 -1
  31. data/test/accessors_geographies_tests.rb +2 -1
  32. data/test/accessors_geometries_tests.rb +2 -1
  33. data/test/adapter_tests.rb +5 -4
  34. data/test/associations_tests.rb +40 -25
  35. data/test/geography_column_tests.rb +2 -1
  36. data/test/geometry_column_tests.rb +2 -1
  37. data/test/models/bar.rb +1 -9
  38. data/test/models/blort.rb +1 -7
  39. data/test/models/foo.rb +3 -9
  40. data/test/models/foo3d.rb +1 -9
  41. data/test/models/foo_geography.rb +1 -8
  42. data/test/models/zortable.rb +1 -9
  43. data/test/schema.rb +54 -0
  44. data/test/spatial_function_tests.rb +2 -1
  45. data/test/spatial_scopes_geographies_tests.rb +2 -1
  46. data/test/spatial_scopes_tests.rb +2 -1
  47. data/test/test_helper.rb +57 -91
  48. metadata +9 -7
  49. data/lib/activerecord-spatial/associations/preloader/spatial_association.rb +0 -57
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-spatial
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-24 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: '6.0'
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: '5.0'
26
+ version: '6.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: geos-extensions
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -47,6 +47,7 @@ extra_rdoc_files:
47
47
  files:
48
48
  - ".gitignore"
49
49
  - ".rubocop.yml"
50
+ - ".travis.yml"
50
51
  - Gemfile
51
52
  - Guardfile
52
53
  - MIT-LICENSE
@@ -66,8 +67,8 @@ files:
66
67
  - lib/activerecord-spatial/associations.rb
67
68
  - lib/activerecord-spatial/associations/active_record.rb
68
69
  - lib/activerecord-spatial/associations/base.rb
69
- - lib/activerecord-spatial/associations/preloader/spatial_association.rb
70
70
  - lib/activerecord-spatial/associations/reflection/spatial_reflection.rb
71
+ - lib/activerecord-spatial/associations/spatial_association.rb
71
72
  - lib/activerecord-spatial/spatial_columns.rb
72
73
  - lib/activerecord-spatial/spatial_function.rb
73
74
  - lib/activerecord-spatial/spatial_scope_constants.rb
@@ -97,6 +98,7 @@ files:
97
98
  - test/models/foo3d.rb
98
99
  - test/models/foo_geography.rb
99
100
  - test/models/zortable.rb
101
+ - test/schema.rb
100
102
  - test/spatial_function_tests.rb
101
103
  - test/spatial_scopes_geographies_tests.rb
102
104
  - test/spatial_scopes_tests.rb
@@ -120,8 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
122
  - !ruby/object:Gem::Version
121
123
  version: '0'
122
124
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.6.11
125
+ rubygems_version: 3.0.3
125
126
  signing_key:
126
127
  specification_version: 4
127
128
  summary: ActiveRecord Spatial gives AR the ability to work with PostGIS columns.
@@ -146,6 +147,7 @@ test_files:
146
147
  - test/models/foo3d.rb
147
148
  - test/models/foo_geography.rb
148
149
  - test/models/zortable.rb
150
+ - test/schema.rb
149
151
  - test/spatial_function_tests.rb
150
152
  - test/spatial_scopes_geographies_tests.rb
151
153
  - test/spatial_scopes_tests.rb
@@ -1,57 +0,0 @@
1
-
2
- module ActiveRecord
3
- module Associations
4
- class Preloader #:nodoc:
5
- class SpatialAssociation < HasMany #:nodoc:
6
- if method_defined?(:query_scope)
7
- def query_scope(ids)
8
- spatial_query_scope(ids)
9
- end
10
- else
11
- def records_for(ids)
12
- spatial_query_scope(ids)
13
- end
14
- end
15
-
16
- private
17
-
18
- def association_key_name
19
- SPATIAL_FIELD_ALIAS
20
- end
21
-
22
- def spatial_query_scope(ids)
23
- join_name = model.quoted_table_name
24
- column = %{#{SPATIAL_JOIN_QUOTED_NAME}.#{model.quoted_primary_key}}
25
- geom = {
26
- class: model,
27
- table_alias: SPATIAL_JOIN_NAME
28
- }
29
-
30
- if reflection.options[:geom].is_a?(Hash)
31
- geom.merge!(reflection.options[:geom])
32
- else
33
- geom[:column] = reflection.options[:geom]
34
- end
35
-
36
- where_function = klass.send(
37
- "st_#{reflection.options[:relationship]}",
38
- geom,
39
- (reflection.options[:scope_options] || {}).merge(
40
- column: reflection.options[:foreign_geom]
41
- )
42
- )
43
-
44
- scope.
45
- select(%{#{klass.quoted_table_name}.*, array_to_string(array_agg(#{column}), ',') AS "#{SPATIAL_FIELD_ALIAS}"}).
46
- joins(
47
- "INNER JOIN #{join_name} AS #{SPATIAL_JOIN_QUOTED_NAME} ON (" <<
48
- where_function.where_clause.send(:predicates).join(' AND ') <<
49
- ')'
50
- ).
51
- where(model.arel_table.alias(SPATIAL_JOIN_NAME)[model.primary_key].in(ids)).
52
- group(table[klass.primary_key])
53
- end
54
- end
55
- end
56
- end
57
- end