rgeo-activerecord 1.3.0 → 2.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: 11ad920c01d1f944cd3d7f4f658b4138a1954284
4
- data.tar.gz: 184abfc52e1c1708726c344bc66842133381949d
3
+ metadata.gz: 83c247d03120c2d00d9fc30cd2af5c9e57c5da68
4
+ data.tar.gz: 9fbfb89f6fa017dac3bbba473665eba29868c629
5
5
  SHA512:
6
- metadata.gz: 6bffb41f789ef87f8557cbdbc786a3c2070c7d193e9fe819467397b556a613ac8a9b9e363def43a0f09afcfdfae8fdddeaf4b1584f5166901dbd59be2c6af1f8
7
- data.tar.gz: 7254fcac74eb52b88152d27f8f452045f376202462365822432e0cda43c35ffa6f0df65516ad85f63e9f6b9a2af5eabc8d60e25da28bc7f5136b1b28c59745b2
6
+ metadata.gz: e69081bdf3b855cc6c0c51ab63ae46441c39737bc3d221e3c8e25116f5f7d1837f93ada751f03e03216c9a403893a0d48966e05fca9a2a43c9a32505cea2100c
7
+ data.tar.gz: c5ba3ba814a4ffa59a130916cd0fdba7f8a1f77a3de8a6d5524ada43345e7ff2392be3b77f1d90450fc50fe76289142cff4030836e4f45c7bd058c9639d71e83
data/History.md CHANGED
@@ -1,8 +1,3 @@
1
- ### 1.3.0 / 2017-07-02
2
-
3
- * Fix indexes in schema dump #25
4
- * Dump schema using new hash syntax #18
5
-
6
1
  ### 1.2.0 / 2014-08-21
7
2
 
8
3
  * Support ActiveRecord 4.2
@@ -21,28 +21,28 @@ module RGeo
21
21
  # mapping for the database, and it also uses the type information
22
22
  # in the node to determine when to cast string arguments to WKT,
23
23
 
24
- def visit_RGeo_ActiveRecord_SpatialNamedFunction(node, *args)
25
- name_ = st_func(node.name)
24
+ def visit_RGeo_ActiveRecord_SpatialNamedFunction(node, collector)
25
+ name = st_func(node.name)
26
26
  exprs = []
27
27
  node.expressions.each_with_index do |expr, index|
28
- exprs << (node.spatial_argument?(index) ? visit_in_spatial_context(expr, *args) : visit(expr, *args))
28
+ exprs << (node.spatial_argument?(index) ? visit_in_spatial_context(expr, collector) : visit(expr, collector))
29
29
  end
30
- "#{name_}(#{node.distinct ? 'DISTINCT ' : ''}#{exprs.join(', ')})#{node.alias ? " AS #{visit(node.alias, *args)}" : ''}"
30
+ collector << "#{name}(#{node.distinct ? 'DISTINCT ' : ''}#{exprs.join(', ')})#{node.alias ? " AS #{visit(node.alias, *args)}" : ''}"
31
31
  end
32
32
 
33
33
  # Generates SQL for a spatial node.
34
34
  # The node must be a string (in which case it is treated as WKT),
35
35
  # an RGeo feature, or a spatial attribute.
36
- def visit_in_spatial_context(node, *args)
36
+ def visit_in_spatial_context(node, collector)
37
37
  case node
38
38
  when ::String
39
- "#{st_func('ST_WKTToSQL')}(#{quote(node)})"
39
+ collector << "#{st_func('ST_WKTToSQL')}(#{quote(node)})"
40
40
  when ::RGeo::Feature::Instance
41
- visit_RGeo_Feature_Instance(node, *args)
41
+ collector << visit_RGeo_Feature_Instance(node, *args)
42
42
  when ::RGeo::Cartesian::BoundingBox
43
- visit_RGeo_Cartesian_BoundingBox(node, *args)
43
+ collector << visit_RGeo_Cartesian_BoundingBox(node, *args)
44
44
  else
45
- visit(node, *args)
45
+ visit(node, collector)
46
46
  end
47
47
  end
48
48
  end
@@ -65,11 +65,11 @@ module RGeo
65
65
  # Make sure the standard Arel visitors can handle RGeo feature objects by default.
66
66
 
67
67
  ::Arel::Visitors::Visitor.class_eval do
68
- def visit_RGeo_ActiveRecord_SpatialConstantNode(node, *args)
68
+ def visit_RGeo_ActiveRecord_SpatialConstantNode(node, collector)
69
69
  if respond_to?(:visit_in_spatial_context)
70
- visit_in_spatial_context(node.delegate, *args)
70
+ visit_in_spatial_context(node.delegate, collector)
71
71
  else
72
- visit(node.delegate, *args)
72
+ visit(node.delegate, collector)
73
73
  end
74
74
  end
75
75
  end
@@ -6,7 +6,7 @@ module RGeo
6
6
  # Some default column constructors specifications for most spatial
7
7
  # databases. Individual adapters may add to or override this list.
8
8
  DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS = {
9
- spatial: { type: 'geometry' }.freeze,
9
+ spatial: { :type => 'geometry' }.freeze,
10
10
  geometry: {}.freeze,
11
11
  point: {}.freeze,
12
12
  line_string: {}.freeze,
@@ -19,7 +19,7 @@ module RGeo
19
19
 
20
20
  # Index definition struct with a spatial flag field.
21
21
 
22
- class SpatialIndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths, :orders, :where, :using, :type, :spatial)
22
+ class SpatialIndexDefinition < Struct.new(:table, :name, :unique, :columns, :lengths, :orders, :where, :spatial)
23
23
  end
24
24
 
25
25
  # Returns a feature type module given a string type.
@@ -108,21 +108,14 @@ module RGeo
108
108
  if indexes.any?
109
109
  add_index_statements = indexes.map do |index|
110
110
  statement = [
111
- ("add_index #{index.table.inspect}"),
111
+ "add_index #{index.table.inspect}",
112
112
  index.columns.inspect,
113
- ("name: #{index.name.inspect}"),
113
+ "name: #{index.name.inspect}",
114
114
  ]
115
115
  statement << 'unique: true' if index.unique
116
116
  statement << 'spatial: true' if index.respond_to?(:spatial) && index.spatial
117
117
  index_lengths = (index.lengths || []).compact
118
118
  statement << ("length: #{::Hash[*index.columns.zip(index.lengths).flatten].inspect}") if index_lengths.any?
119
-
120
- index_orders = index.orders || {}
121
- statement << "order: #{index.orders.inspect}" if index_orders.any?
122
- statement << "where: #{index.where.inspect}" if index.where
123
- statement << "using: #{index.using.inspect}" if index.using
124
- statement << "type: #{index.type.inspect}" if index.type
125
-
126
119
  " #{statement.join(', ')}"
127
120
  end
128
121
  stream.puts add_index_statements.sort.join("\n")
@@ -133,15 +126,6 @@ module RGeo
133
126
 
134
127
  ::ActiveRecord::SchemaDumper.send :include, GeoSchemaDumper
135
128
 
136
-
137
- # attribute_types_cached_by_default was removed in ActiveRecord 4.2
138
- # :cache_attributes does not work since the connection may not yet be established
139
-
140
- if ::ActiveRecord.version < Gem::Version.new("4.2.0.a")
141
- # cache spatial attribute values so they don't get re-parsed on every access.
142
- ::ActiveRecord::Base.attribute_types_cached_by_default << :spatial
143
- end
144
-
145
129
  # :startdoc:
146
130
  end
147
131
  end
@@ -1,9 +1,7 @@
1
1
  module RGeo
2
2
  module ActiveRecord
3
3
  # Returns true if spatial expressions (i.e. the methods in the
4
- # SpatialExpressions module) are supported. Generally, this is true
5
- # if Arel is at version 2.1 or later.
6
-
4
+ # SpatialExpressions module) are supported.
7
5
  def self.spatial_expressions_supported?
8
6
  defined?(::Arel::Nodes::NamedFunction)
9
7
  end
@@ -11,8 +9,6 @@ module RGeo
11
9
  # A set of spatial expression builders.
12
10
  # These methods can be chained off other spatial expressions to form
13
11
  # complex expressions.
14
- #
15
- # These functions require Arel 2.1 or later.
16
12
  module SpatialExpressions
17
13
  #--
18
14
  # Generic functions
@@ -260,9 +256,6 @@ module Arel
260
256
  # This node wraps a spatial value (such as an RGeo feature or a text
261
257
  # string in WKT format). It supports chaining with the functions
262
258
  # defined by RGeo::ActiveRecord::SpatialExpressions.
263
- #
264
- # Requires Arel 2.1 or later.
265
-
266
259
  def self.spatial(arg)
267
260
  ::RGeo::ActiveRecord::SpatialConstantNode.new(arg)
268
261
  end
@@ -1,5 +1,5 @@
1
1
  module RGeo
2
2
  module ActiveRecord
3
- VERSION = '1.3.0'.freeze
3
+ VERSION = '2.0.0'.freeze
4
4
  end
5
5
  end
@@ -1,6 +1,6 @@
1
1
  require 'test_helper'
2
2
 
3
- class BasicTest < MINITEST_CLASS # :nodoc:
3
+ class BasicTest < Minitest::Test # :nodoc:
4
4
  class MyTable < ::ActiveRecord::Base
5
5
  end
6
6
 
@@ -54,16 +54,8 @@ class BasicTest < MINITEST_CLASS # :nodoc:
54
54
 
55
55
  def test_arel_visit_spatial_constant_node
56
56
  visitor = arel_visitor
57
-
58
- # :accept API changed in Arel 6.0:
59
- # https://github.com/rails/arel/commit/fcd11dcb99d69d
60
- sql = if Arel::VERSION > "6.0.0"
61
- visitor.accept(Arel.spatial('POINT (1.0 2.0)'), Arel::Collectors::PlainString.new)
62
- else
63
- visitor.accept(Arel.spatial('POINT (1.0 2.0)'))
64
- end
65
-
66
- assert_equal("ST_WKTToSQL('POINT (1.0 2.0)')", sql)
57
+ sql = visitor.accept(Arel.spatial('POINT (1.0 2.0)'), Arel::Collectors::PlainString.new)
58
+ assert_equal("ST_WKTToSQL('POINT (1.0 2.0)')", sql.value)
67
59
  end
68
60
 
69
61
  private
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class CommonAdapterElementsTest < Minitest::Test # :nodoc:
4
+ def test_geo_schema_dumper
5
+
6
+ end
7
+ end
@@ -2,11 +2,11 @@ require 'minitest/autorun'
2
2
  require 'rgeo/active_record'
3
3
  require 'support/fake_record'
4
4
 
5
- MINITEST_CLASS = if defined?(::Minitest::Test)
6
- ::Minitest::Test
7
- else
8
- ::Minitest::Unit::TestCase
9
- end
10
-
11
5
  Arel::Visitors::PostgreSQL.send(:include, ::RGeo::ActiveRecord::SpatialToSql)
12
6
  Arel::Table.engine = FakeRecord::Base.new
7
+
8
+ begin
9
+ require 'byebug'
10
+ rescue LoadError
11
+ # ignore
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgeo-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Daniel Azuma
7
+ - Daniel Azuma, Tee Parham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-03 00:00:00.000000000 Z
11
+ date: 2014-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgeo
@@ -30,46 +30,60 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '4.0'
33
+ version: '4.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '4.0'
40
+ version: '4.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '5.4'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '5.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.2'
61
+ version: '10.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.1'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '10.2'
82
+ version: '1.1'
69
83
  description: RGeo is a geospatial data library for Ruby. RGeo::ActiveRecord is an
70
84
  optional RGeo module providing some spatial extensions to ActiveRecord, as well
71
85
  as common tools used by RGeo-based spatial adapters.
72
- email: dazuma@gmail.com
86
+ email: dazuma@gmail.com, parhameter@gmail.com
73
87
  executables: []
74
88
  extensions: []
75
89
  extra_rdoc_files: []
@@ -87,6 +101,7 @@ files:
87
101
  - lib/rgeo/active_record/spatial_expressions.rb
88
102
  - lib/rgeo/active_record/version.rb
89
103
  - test/basic_test.rb
104
+ - test/common_adapter_elements_test.rb
90
105
  - test/support/fake_record.rb
91
106
  - test/test_helper.rb
92
107
  homepage: http://github.com/rgeo/rgeo-activerecord
@@ -108,12 +123,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
123
  version: '0'
109
124
  requirements: []
110
125
  rubyforge_project:
111
- rubygems_version: 2.6.12
126
+ rubygems_version: 2.4.4
112
127
  signing_key:
113
128
  specification_version: 4
114
129
  summary: An RGeo module providing spatial extensions to ActiveRecord.
115
130
  test_files:
116
131
  - test/basic_test.rb
132
+ - test/common_adapter_elements_test.rb
117
133
  - test/support/fake_record.rb
118
134
  - test/test_helper.rb
119
135
  has_rdoc: