activerecord-mysql2spatial-adapter 0.5.1 → 0.5.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cb3f862d46c36a623e20fcaafc1057a2f638e20
4
- data.tar.gz: 8cfa1b9a643ec7fe194576612f85224376772188
3
+ metadata.gz: eddaee56fc0e1979c0d6d85a67a5650768a2a806
4
+ data.tar.gz: 4f3f4565621224e3cbcaa5b83ddb69b1e1c3c861
5
5
  SHA512:
6
- metadata.gz: 61ff68681870db9d9513d8cf2e7ea12f3b16e3515ef272fb5a73682b1f1393a3b6ff140f27335cb39e3616a4b70f75669165079cc4fb2fcc13f0d672dde0ff89
7
- data.tar.gz: b7b4716dd434ae38dc682324dfc809be29d6685517f397545e8b2a96dd9fb8f3b2bcb635c7295866a0962a14ec27cba721cb8f796129a9150ab4a24e6fcf1045
6
+ metadata.gz: e1240dff2216ddcd86e136f67e2971279862a5e809b2a7001f9cf9e8c3b2a600b52669085c619e6d6af6bf681e6048744d818cc554e4dbafc695b0f221b75f6d
7
+ data.tar.gz: 485b23c5e95811ba7632d046f265df5ed5c485d0a93e1b9240a8a22e44f3fa081a8e30113cf28bc4e8b30984a28bc8dccafb1d552b739d1c15bc8e48cc84ace7
@@ -1,3 +1,8 @@
1
+ === 0.5.2
2
+
3
+ * Code cleanup, whitespace, comments
4
+ * Use Ruby 1.9+ syntax for hashes
5
+
1
6
  === 0.5.1 / 2017-07-04
2
7
 
3
8
  * Move dependency on rgeo-activerecord from unreleased 1.0 branch to 1.3.0 release.
@@ -21,13 +21,13 @@ column may need to be NOT NULL.
21
21
 
22
22
  Examples (require update):
23
23
 
24
- create_table :my_spatial_table, :options => 'ENGINE=MyISAM' do |t|
25
- t.column :latlon, :point, :null => false
24
+ create_table :my_spatial_table, options: 'ENGINE=MyISAM' do |t|
25
+ t.column :latlon, :point, null: false
26
26
  t.line_string :path
27
27
  t.geometry :shape
28
28
  end
29
29
  change_table :my_spatial_table do |t|
30
- t.index :latlon, :spatial => true
30
+ t.index :latlon, spatial: true
31
31
  end
32
32
 
33
33
  === Spatial Attributes
@@ -80,11 +80,11 @@ Now you can interact with the data using the RGeo types:
80
80
  You can create simple queries based on objective equality in the same way
81
81
  you would on a scalar column:
82
82
 
83
- rec = MySpatialTable.where(:latlon => RGeo::Geos.factory.point(-122, 47)).first
83
+ rec = MySpatialTable.where(latlon: RGeo::Geos.factory.point(-122, 47)).first
84
84
 
85
85
  You can also use WKT:
86
86
 
87
- rec = MySpatialTable.where(:latlon => 'POINT(-122 47)').first
87
+ rec = MySpatialTable.where(latlon: 'POINT(-122 47)').first
88
88
 
89
89
  The adapter also provides experimental support for more complex queries
90
90
  such as radius searches. However, these extensions require Arel 2.1
data/Version CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -1,8 +1,6 @@
1
- # -----------------------------------------------------------------------------
2
1
  #
3
2
  # Mysql2Spatial adapter for ActiveRecord
4
3
  #
5
- # -----------------------------------------------------------------------------
6
4
  # Copyright 2010 Daniel Azuma
7
5
  #
8
6
  # All rights reserved.
@@ -30,26 +28,21 @@
30
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
30
  # POSSIBILITY OF SUCH DAMAGE.
33
- # -----------------------------------------------------------------------------
34
- ;
35
31
 
36
32
 
37
33
  require 'rgeo/active_record'
38
34
  require 'active_record/connection_adapters/mysql2_adapter'
39
35
 
40
-
41
36
  # The activerecord-mysql2spatial-adapter gem installs the *mysql2spatial*
42
37
  # connection adapter into ActiveRecord.
43
38
 
44
39
  module ActiveRecord
45
40
 
46
-
47
41
  # ActiveRecord looks for the mysql2spatial_connection factory method in
48
42
  # this class.
49
43
 
50
44
  class Base
51
45
 
52
-
53
46
  # Create a mysql2spatial connection adapter.
54
47
 
55
48
  def self.mysql2spatial_connection(config_)
@@ -62,10 +55,8 @@ module ActiveRecord
62
55
  ::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::MainAdapter.new(client_, logger, options_, config_)
63
56
  end
64
57
 
65
-
66
58
  end
67
59
 
68
-
69
60
  # All ActiveRecord adapters go in this namespace.
70
61
  module ConnectionAdapters
71
62
 
@@ -76,13 +67,9 @@ module ActiveRecord
76
67
  ADAPTER_NAME = 'Mysql2Spatial'.freeze
77
68
 
78
69
  end
79
-
80
70
  end
81
-
82
-
83
71
  end
84
72
 
85
-
86
73
  require 'active_record/connection_adapters/mysql2spatial_adapter/version.rb'
87
74
  require 'active_record/connection_adapters/mysql2spatial_adapter/column_methods.rb' # check if this works with Rails < 4.x
88
75
  require 'active_record/connection_adapters/mysql2spatial_adapter/main_adapter.rb'
@@ -1,8 +1,6 @@
1
- # -----------------------------------------------------------------------------
2
1
  #
3
2
  # Mysql2Spatial adapter for ActiveRecord
4
3
  #
5
- # -----------------------------------------------------------------------------
6
4
  # Copyright 2010 Daniel Azuma
7
5
  #
8
6
  # All rights reserved.
@@ -30,15 +28,12 @@
30
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
30
  # POSSIBILITY OF SUCH DAMAGE.
33
- # -----------------------------------------------------------------------------
34
- ;
35
31
 
36
32
 
37
33
  # :stopdoc:
38
34
 
39
35
  module Arel
40
36
  module Visitors
41
-
42
37
  class MySQL2Spatial < MySQL
43
38
 
44
39
  if ::Arel::Visitors.const_defined?(:BindVisitor)
@@ -1,8 +1,6 @@
1
- # -----------------------------------------------------------------------------
2
1
  #
3
2
  # Mysql2Spatial adapter for ActiveRecord
4
3
  #
5
- # -----------------------------------------------------------------------------
6
4
  # Copyright 2010 Daniel Azuma
7
5
  #
8
6
  # All rights reserved.
@@ -30,25 +28,17 @@
30
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
30
  # POSSIBILITY OF SUCH DAMAGE.
33
- # -----------------------------------------------------------------------------
34
- ;
35
31
 
36
32
 
37
33
  # :stopdoc:
38
34
 
39
35
  module ActiveRecord
40
-
41
36
  module ConnectionAdapters
42
-
43
37
  module Mysql2SpatialAdapter
44
-
45
-
46
38
  class MainAdapter < ConnectionAdapters::Mysql2Adapter
47
39
 
48
-
49
40
  NATIVE_DATABASE_TYPES = Mysql2Adapter::NATIVE_DATABASE_TYPES.merge(spatial: { name: 'geometry' })
50
41
 
51
-
52
42
  def initialize(*args_)
53
43
  super
54
44
  # Rails 3.2 way of defining the visitor: do so in the constructor
@@ -57,36 +47,30 @@ module ActiveRecord
57
47
  end
58
48
  end
59
49
 
60
-
61
50
  def set_rgeo_factory_settings(factory_settings_)
62
51
  @rgeo_factory_settings = factory_settings_
63
52
  end
64
53
 
65
-
66
54
  def adapter_name
67
55
  Mysql2SpatialAdapter::ADAPTER_NAME
68
56
  end
69
57
 
70
-
71
58
  def spatial_column_constructor(name_)
72
59
  ::RGeo::ActiveRecord::DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS[name_]
73
60
  end
74
61
 
75
-
76
62
  def native_database_types
77
63
  NATIVE_DATABASE_TYPES
78
64
  end
79
65
 
80
-
81
66
  def quote(value_, column_=nil)
82
67
  if ::RGeo::Feature::Geometry.check_type(value_)
83
- "GeomFromWKB(0x#{::RGeo::WKRep::WKBGenerator.new(:hex_format => true).generate(value_)},#{value_.srid})"
68
+ "GeomFromWKB(0x#{::RGeo::WKRep::WKBGenerator.new(hex_format: true).generate(value_)},#{value_.srid})"
84
69
  else
85
70
  super
86
71
  end
87
72
  end
88
73
 
89
-
90
74
  def type_to_sql(type_, limit_=nil, precision_=nil, scale_=nil)
91
75
  if (info_ = spatial_column_constructor(type_.to_sym))
92
76
  type_ = limit_[:type] || type_ if limit_.is_a?(::Hash)
@@ -96,10 +80,9 @@ module ActiveRecord
96
80
  super(type_, limit_, precision_, scale_)
97
81
  end
98
82
 
99
-
100
83
  def add_index(table_name_, column_name_, options_={})
101
84
  if options_[:spatial]
102
- index_name_ = index_name(table_name_, :column => Array(column_name_))
85
+ index_name_ = index_name(table_name_, column: Array(column_name_))
103
86
  if ::Hash === options_
104
87
  index_name_ = options_[:name] || index_name_
105
88
  end
@@ -109,11 +92,10 @@ module ActiveRecord
109
92
  end
110
93
  end
111
94
 
112
-
113
95
  def columns(table_name_, name_=nil)
114
96
  result_ = execute("SHOW FIELDS FROM #{quote_table_name(table_name_)}", :skip_logging)
115
97
  columns_ = []
116
- result_.each(:symbolize_keys => true, :as => :hash) do |field_|
98
+ result_.each(symbolize_keys: true, as: :hash) do |field_|
117
99
  columns_ << SpatialColumn.new(@rgeo_factory_settings, table_name_.to_s,
118
100
  field_[:Field], field_[:Default], field_[:Type], field_[:Null] == "YES")
119
101
  end
@@ -125,7 +107,7 @@ module ActiveRecord
125
107
  indexes_ = []
126
108
  current_index_ = nil
127
109
  result_ = execute("SHOW KEYS FROM #{quote_table_name(table_name_)}", name_)
128
- result_.each(:symbolize_keys => true, :as => :hash) do |row_|
110
+ result_.each(symbolize_keys: true, as: :hash) do |row_|
129
111
  if current_index_ != row_[:Key_name]
130
112
  next if row_[:Key_name] == 'PRIMARY' # skip the primary key
131
113
  current_index_ = row_[:Key_name]
@@ -146,15 +128,9 @@ module ActiveRecord
146
128
  end
147
129
  indexes_
148
130
  end
149
-
150
-
151
131
  end
152
-
153
-
154
132
  end
155
-
156
133
  end
157
-
158
134
  end
159
135
 
160
136
  # :startdoc:
@@ -1,8 +1,6 @@
1
- # -----------------------------------------------------------------------------
2
1
  #
3
2
  # Mysql2Spatial adapter for ActiveRecord
4
3
  #
5
- # -----------------------------------------------------------------------------
6
4
  # Copyright 2010 Daniel Azuma
7
5
  #
8
6
  # All rights reserved.
@@ -30,19 +28,14 @@
30
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
30
  # POSSIBILITY OF SUCH DAMAGE.
33
- # -----------------------------------------------------------------------------
34
- ;
35
31
 
36
32
 
37
33
  # :stopdoc:
38
34
 
39
35
  module ActiveRecord
40
-
41
36
  module ConnectionAdapters
42
-
43
37
  module Mysql2SpatialAdapter
44
38
 
45
-
46
39
  # ActiveRecord 3.2 uses ConnectionAdapters::Mysql2Adapter::Column
47
40
  # whereas 3.0 and 3.1 use ConnectionAdapters::Mysql2Column
48
41
  column_base_class_ = defined?(ConnectionAdapters::Mysql2Adapter::Column) ?
@@ -50,10 +43,8 @@ module ActiveRecord
50
43
 
51
44
  class SpatialColumn < column_base_class_
52
45
 
53
-
54
46
  FACTORY_SETTINGS_CACHE = {}
55
47
 
56
-
57
48
  def initialize(factory_settings_, table_name_, name_, default_, sql_type_=nil, null_=true)
58
49
  @factory_settings = factory_settings_
59
50
  @table_name = table_name_
@@ -65,20 +56,16 @@ module ActiveRecord
65
56
  FACTORY_SETTINGS_CACHE[factory_settings_.object_id] = factory_settings_
66
57
  end
67
58
 
68
-
69
59
  attr_reader :geometric_type
70
60
 
71
-
72
61
  def spatial?
73
62
  type == :spatial
74
63
  end
75
64
 
76
-
77
65
  def klass
78
66
  type == :spatial ? ::RGeo::Feature::Geometry : super
79
67
  end
80
68
 
81
-
82
69
  def type_cast(value_)
83
70
  if type == :spatial
84
71
  SpatialColumn.convert_to_geometry(value_, @factory_settings, @table_name, name)
@@ -87,7 +74,6 @@ module ActiveRecord
87
74
  end
88
75
  end
89
76
 
90
-
91
77
  def type_cast_code(var_name_)
92
78
  if type == :spatial
93
79
  "::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::SpatialColumn.convert_to_geometry("+
@@ -98,7 +84,6 @@ module ActiveRecord
98
84
  end
99
85
  end
100
86
 
101
-
102
87
  private
103
88
 
104
89
  def simplified_type(sql_type_)
@@ -109,24 +94,24 @@ module ActiveRecord
109
94
  def self.convert_to_geometry(input_, factory_settings_, table_name_, column_)
110
95
  case input_
111
96
  when ::RGeo::Feature::Geometry
112
- factory_ = factory_settings_.get_column_factory(table_name_, column_, :srid => input_.srid)
97
+ factory_ = factory_settings_.get_column_factory(table_name_, column_, srid: input_.srid)
113
98
  ::RGeo::Feature.cast(input_, factory_) rescue nil
114
99
  when ::String
115
100
  marker_ = input_[4,1]
116
101
  if marker_ == "\x00" || marker_ == "\x01"
117
102
  factory_ = factory_settings_.get_column_factory(table_name_, column_,
118
- :srid => input_[0,4].unpack(marker_ == "\x01" ? 'V' : 'N').first)
103
+ srid: input_[0, 4].unpack(marker_ == "\x01" ? 'V' : 'N').first)
119
104
  ::RGeo::WKRep::WKBParser.new(factory_).parse(input_[4..-1]) rescue nil
120
105
  elsif input_[0,10] =~ /[0-9a-fA-F]{8}0[01]/
121
106
  srid_ = input_[0,8].to_i(16)
122
107
  if input[9,1] == '1'
123
108
  srid_ = [srid_].pack('V').unpack('N').first
124
109
  end
125
- factory_ = factory_settings_.get_column_factory(table_name_, column_, :srid => srid_)
110
+ factory_ = factory_settings_.get_column_factory(table_name_, column_, srid: srid_)
126
111
  ::RGeo::WKRep::WKBParser.new(factory_).parse(input_[8..-1]) rescue nil
127
112
  else
128
113
  factory_ = factory_settings_.get_column_factory(table_name_, column_)
129
- ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true).parse(input_) rescue nil
114
+ ::RGeo::WKRep::WKTParser.new(factory_, support_ewkt: true).parse(input_) rescue nil
130
115
  end
131
116
  else
132
117
  nil
@@ -1,8 +1,6 @@
1
- # -----------------------------------------------------------------------------
2
1
  #
3
2
  # Mysql2Spatial adapter for ActiveRecord
4
3
  #
5
- # -----------------------------------------------------------------------------
6
4
  # Copyright 2010 Daniel Azuma
7
5
  #
8
6
  # All rights reserved.
@@ -30,8 +28,6 @@
30
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
30
  # POSSIBILITY OF SUCH DAMAGE.
33
- # -----------------------------------------------------------------------------
34
- ;
35
31
 
36
32
 
37
33
  begin
@@ -39,14 +35,10 @@ begin
39
35
  rescue ::LoadError
40
36
  end
41
37
 
42
-
43
38
  module ActiveRecord
44
-
45
39
  module ConnectionAdapters
46
-
47
40
  module Mysql2SpatialAdapter
48
41
 
49
-
50
42
  # Current version of Mysql2SpatialAdapter as a frozen string
51
43
  VERSION_STRING = ::File.read(::File.dirname(__FILE__)+'/../../../../Version').strip.freeze
52
44
 
@@ -54,9 +46,6 @@ module ActiveRecord
54
46
  # Versionomy gem is available; otherwise equal to VERSION_STRING.
55
47
  VERSION = defined?(::Versionomy) ? ::Versionomy.parse(VERSION_STRING) : VERSION_STRING
56
48
 
57
-
58
49
  end
59
-
60
50
  end
61
-
62
51
  end
@@ -1,8 +1,6 @@
1
- # -----------------------------------------------------------------------------
2
1
  #
3
2
  # Tests for the Mysql2Spatial ActiveRecord adapter
4
3
  #
5
- # -----------------------------------------------------------------------------
6
4
  # Copyright 2010 Daniel Azuma
7
5
  #
8
6
  # All rights reserved.
@@ -30,26 +28,20 @@
30
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
30
  # POSSIBILITY OF SUCH DAMAGE.
33
- # -----------------------------------------------------------------------------
34
- ;
35
31
 
36
32
  require 'minitest/autorun'
37
33
  require 'rgeo/active_record/adapter_test_helper'
38
34
 
39
-
40
35
  module RGeo
41
36
  module ActiveRecord # :nodoc:
42
37
  module Mysql2SpatialAdapter # :nodoc:
43
38
  module Tests # :nodoc:
44
-
45
39
  class TestBasic < ::Minitest::Test # :nodoc:
46
40
 
47
41
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
48
42
  include RGeo::ActiveRecord::AdapterTestHelper
49
43
 
50
44
  define_test_methods do
51
-
52
-
53
45
  def populate_ar_class(content_)
54
46
  klass_ = create_ar_class
55
47
  case content_
@@ -61,12 +53,10 @@ module RGeo
61
53
  klass_
62
54
  end
63
55
 
64
-
65
56
  def test_version
66
57
  refute_nil(::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::VERSION)
67
58
  end
68
59
 
69
-
70
60
  def test_create_simple_geometry
71
61
  klass_ = create_ar_class
72
62
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -76,7 +66,6 @@ module RGeo
76
66
  assert(klass_.cached_attributes.include?('latlon'))
77
67
  end
78
68
 
79
-
80
69
  def test_create_point_geometry
81
70
  klass_ = create_ar_class
82
71
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -86,19 +75,17 @@ module RGeo
86
75
  assert(klass_.cached_attributes.include?('latlon'))
87
76
  end
88
77
 
89
-
90
78
  def test_create_geometry_with_index
91
79
  klass_ = create_ar_class
92
- klass_.connection.create_table(:spatial_test, :options => 'ENGINE=MyISAM') do |t_|
93
- t_.column 'latlon', :geometry, :null => false
80
+ klass_.connection.create_table(:spatial_test, options: 'ENGINE=MyISAM') do |t_|
81
+ t_.column 'latlon', :geometry, null: false
94
82
  end
95
83
  klass_.connection.change_table(:spatial_test) do |t_|
96
- t_.index([:latlon], :spatial => true)
84
+ t_.index([:latlon], spatial: true)
97
85
  end
98
86
  assert(klass_.connection.indexes(:spatial_test).last.spatial)
99
87
  end
100
88
 
101
-
102
89
  def test_set_and_get_point
103
90
  klass_ = populate_ar_class(:latlon_point)
104
91
  obj_ = klass_.new
@@ -108,7 +95,6 @@ module RGeo
108
95
  assert_equal(3785, obj_.latlon.srid)
109
96
  end
110
97
 
111
-
112
98
  def test_set_and_get_point_from_wkt
113
99
  klass_ = populate_ar_class(:latlon_point)
114
100
  obj_ = klass_.new
@@ -118,7 +104,6 @@ module RGeo
118
104
  assert_equal(1000, obj_.latlon.srid)
119
105
  end
120
106
 
121
-
122
107
  def test_save_and_load_point
123
108
  klass_ = populate_ar_class(:latlon_point)
124
109
  obj_ = klass_.new
@@ -130,7 +115,6 @@ module RGeo
130
115
  assert_equal(3785, obj2_.latlon.srid)
131
116
  end
132
117
 
133
-
134
118
  def test_save_and_load_point_from_wkt
135
119
  klass_ = populate_ar_class(:latlon_point)
136
120
  obj_ = klass_.new
@@ -142,16 +126,15 @@ module RGeo
142
126
  assert_equal(1000, obj2_.latlon.srid)
143
127
  end
144
128
 
145
-
146
129
  def test_readme_example
147
130
  klass_ = create_ar_class
148
- klass_.connection.create_table(:spatial_test, :options => 'ENGINE=MyISAM') do |t_|
149
- t_.column(:latlon, :point, :null => false)
131
+ klass_.connection.create_table(:spatial_test, options: 'ENGINE=MyISAM') do |t_|
132
+ t_.column(:latlon, :point, null: false)
150
133
  t_.line_string(:path)
151
134
  t_.geometry(:shape)
152
135
  end
153
136
  klass_.connection.change_table(:spatial_test) do |t_|
154
- t_.index(:latlon, :spatial => true)
137
+ t_.index(:latlon, spatial: true)
155
138
  end
156
139
  klass_.class_eval do
157
140
  self.rgeo_factory_generator = ::RGeo::Geos.method(:factory)
@@ -165,7 +148,6 @@ module RGeo
165
148
  assert_equal(true, ::RGeo::Geos.is_geos?(rec_.shape))
166
149
  end
167
150
 
168
-
169
151
  def test_create_simple_geometry_using_shortcut
170
152
  klass_ = create_ar_class
171
153
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -175,7 +157,6 @@ module RGeo
175
157
  assert(klass_.cached_attributes.include?('latlon'))
176
158
  end
177
159
 
178
-
179
160
  def test_create_point_geometry_using_shortcut
180
161
  klass_ = create_ar_class
181
162
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -185,21 +166,18 @@ module RGeo
185
166
  assert(klass_.cached_attributes.include?('latlon'))
186
167
  end
187
168
 
188
-
189
169
  def test_create_geometry_using_limit
190
170
  klass_ = create_ar_class
191
171
  klass_.connection.create_table(:spatial_test) do |t_|
192
- t_.spatial 'geom', :limit => {:type => :line_string}
172
+ t_.spatial 'geom', limit: { type: :line_string }
193
173
  end
194
174
  assert_equal(::RGeo::Feature::LineString, klass_.columns.last.geometric_type)
195
175
  assert(klass_.cached_attributes.include?('geom'))
196
176
  end
197
177
 
198
-
199
178
  end
200
179
 
201
180
  end
202
-
203
181
  end
204
182
  end
205
183
  end
@@ -1,8 +1,6 @@
1
- # -----------------------------------------------------------------------------
2
1
  #
3
2
  # Tests for the Mysql2Spatial ActiveRecord adapter
4
3
  #
5
- # -----------------------------------------------------------------------------
6
4
  # Copyright 2010 Daniel Azuma
7
5
  #
8
6
  # All rights reserved.
@@ -30,18 +28,14 @@
30
28
  # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
29
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
30
  # POSSIBILITY OF SUCH DAMAGE.
33
- # -----------------------------------------------------------------------------
34
- ;
35
31
 
36
32
  require 'minitest/autorun'
37
33
  require 'rgeo/active_record/adapter_test_helper'
38
34
 
39
-
40
35
  module RGeo
41
36
  module ActiveRecord # :nodoc:
42
37
  module Mysql2SpatialAdapter # :nodoc:
43
38
  module Tests # :nodoc:
44
-
45
39
  class TestSpatialQueries < ::Minitest::Test # :nodoc:
46
40
 
47
41
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
@@ -49,7 +43,6 @@ module RGeo
49
43
 
50
44
  define_test_methods do
51
45
 
52
-
53
46
  def populate_ar_class(content_)
54
47
  klass_ = create_ar_class
55
48
  case content_
@@ -65,36 +58,32 @@ module RGeo
65
58
  klass_
66
59
  end
67
60
 
68
-
69
61
  def test_query_point
70
62
  klass_ = populate_ar_class(:latlon_point)
71
63
  obj_ = klass_.new
72
64
  obj_.latlon = @factory.point(1, 2)
73
65
  obj_.save!
74
66
  id_ = obj_.id
75
- obj2_ = klass_.where(:latlon => @factory.point(1, 2)).first
67
+ obj2_ = klass_.where(latlon: @factory.point(1, 2)).first
76
68
  assert_equal(id_, obj2_.id)
77
- obj3_ = klass_.where(:latlon => @factory.point(2, 2)).first
69
+ obj3_ = klass_.where(latlon: @factory.point(2, 2)).first
78
70
  assert_nil(obj3_)
79
71
  end
80
72
 
81
-
82
73
  def _test_query_point_wkt
83
74
  klass_ = populate_ar_class(:latlon_point)
84
75
  obj_ = klass_.new
85
76
  obj_.latlon = @factory.point(1, 2)
86
77
  obj_.save!
87
78
  id_ = obj_.id
88
- obj2_ = klass_.where(:latlon => 'POINT(1 2)').first
79
+ obj2_ = klass_.where(latlon: 'POINT(1 2)').first
89
80
  assert_equal(id_, obj2_.id)
90
- obj3_ = klass_.where(:latlon => 'POINT(2 2)').first
81
+ obj3_ = klass_.where(latlon: 'POINT(2 2)').first
91
82
  assert_nil(obj3_)
92
83
  end
93
84
 
94
-
95
85
  if ::RGeo::ActiveRecord.spatial_expressions_supported?
96
86
 
97
-
98
87
  def test_query_st_length
99
88
  klass_ = populate_ar_class(:path_linestring)
100
89
  obj_ = klass_.new
@@ -107,18 +96,13 @@ module RGeo
107
96
  assert_nil(obj3_)
108
97
  end
109
98
 
110
-
111
99
  else
112
-
113
100
  puts "WARNING: The current Arel does not support named functions. Spatial expression tests skipped."
114
-
115
101
  end
116
102
 
117
-
118
103
  end
119
104
 
120
105
  end
121
-
122
106
  end
123
107
  end
124
108
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql2spatial-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-14 00:00:00.000000000 Z
11
+ date: 2017-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -64,20 +64,6 @@ dependencies:
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
66
  version: 0.4.0
67
- - !ruby/object:Gem::Dependency
68
- name: pry
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
- type: :development
75
- prerelease: false
76
- version_requirements: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- version: '0'
81
67
  - !ruby/object:Gem::Dependency
82
68
  name: rake
83
69
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
132
  version: '0'
147
133
  requirements: []
148
134
  rubyforge_project:
149
- rubygems_version: 2.5.2
135
+ rubygems_version: 2.4.3
150
136
  signing_key:
151
137
  specification_version: 4
152
138
  summary: An ActiveRecord adapter for MySQL Spatial Extensions, based on RGeo and the