activerecord-mysql2spatial-adapter 0.4.1 → 0.4.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.
data/History.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ === 0.4.2 / 2012-02-22
2
+
3
+ * Some compatibility fixes for Rails 3.2. (Reported by Nicholas Zaillian and Ryan Williams with implementation help from Radek Paviensky.)
4
+ * Now requires rgeo-activerecord 0.4.3.
5
+
1
6
  === 0.4.1 / 2011-09-07
2
7
 
3
8
  * Now requests mysql2 >= 0.2.x instead of >= 0.3.x since the latter requires Rails 3.1. (Reported by Greg Hazel)
data/README.rdoc CHANGED
@@ -101,10 +101,10 @@ This adapter has the following requirements:
101
101
  * Ruby 1.8.7 or later. Ruby 1.9.2 or later preferred.
102
102
  * MySQL server 5.0 or later required for spatial extensions.
103
103
  * \ActiveRecord 3.0.3 or later. Earlier versions will not work.
104
- Should be compatible with Rails 3.1.
104
+ Should be compatible with Rails versions through 3.2.x.
105
105
  * mysql2 gem 0.2.13 or later.
106
- * rgeo gem 0.3.2 or later.
107
- * rgeo-activerecord gem 0.4.0 or later.
106
+ * rgeo gem 0.3.4 or later.
107
+ * rgeo-activerecord gem 0.4.3 or later.
108
108
 
109
109
  Install this adapter as a gem:
110
110
 
@@ -166,7 +166,7 @@ Contact the author at dazuma at gmail dot com.
166
166
  The Mysql2Spatial Adapter and its supporting libraries (including RGeo)
167
167
  are written by Daniel Azuma (http://www.daniel-azuma.com).
168
168
 
169
- Development of RGeo is sponsored by GeoPage, Inc. (http://www.geopage.com).
169
+ Development is supported by Pirq. (http://www.pirq.com).
170
170
 
171
171
  This adapter implementation owes some debt to the spatial_adapter plugin
172
172
  (http://github.com/fragility/spatial_adapter). Although we made a few
data/Version CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Mysql2Spatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -42,16 +42,16 @@ require 'active_record/connection_adapters/mysql2_adapter'
42
42
  # connection adapter into ActiveRecord.
43
43
 
44
44
  module ActiveRecord
45
-
46
-
45
+
46
+
47
47
  # ActiveRecord looks for the mysql2spatial_connection factory method in
48
48
  # this class.
49
-
49
+
50
50
  class Base
51
-
52
-
51
+
52
+
53
53
  # Create a mysql2spatial connection adapter.
54
-
54
+
55
55
  def self.mysql2spatial_connection(config_)
56
56
  config_[:username] = 'root' if config_[:username].nil?
57
57
  if ::Mysql2::Client.const_defined?(:FOUND_ROWS)
@@ -61,25 +61,25 @@ module ActiveRecord
61
61
  options_ = [config_[:host], config_[:username], config_[:password], config_[:database], config_[:port], config_[:socket], 0]
62
62
  ::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::MainAdapter.new(client_, logger, options_, config_)
63
63
  end
64
-
65
-
64
+
65
+
66
66
  end
67
-
68
-
67
+
68
+
69
69
  # All ActiveRecord adapters go in this namespace.
70
70
  module ConnectionAdapters
71
-
71
+
72
72
  # The Mysql2Spatial adapter
73
73
  module Mysql2SpatialAdapter
74
-
74
+
75
75
  # The name returned by the adapter_name method of this adapter.
76
76
  ADAPTER_NAME = 'Mysql2Spatial'.freeze
77
-
77
+
78
78
  end
79
-
79
+
80
80
  end
81
-
82
-
81
+
82
+
83
83
  end
84
84
 
85
85
 
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Mysql2Spatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,17 +38,17 @@
38
38
 
39
39
  module Arel
40
40
  module Visitors
41
-
41
+
42
42
  class MySQL2Spatial < MySQL
43
-
43
+
44
44
  FUNC_MAP = {
45
45
  'st_wkttosql' => 'GeomFromText',
46
46
  'st_wkbtosql' => 'GeomFromWKB',
47
47
  'st_length' => 'GLength',
48
48
  }
49
-
49
+
50
50
  include ::RGeo::ActiveRecord::SpatialToSql
51
-
51
+
52
52
  def st_func(standard_name_)
53
53
  if (name_ = FUNC_MAP[standard_name_.downcase])
54
54
  name_
@@ -58,11 +58,11 @@ module Arel
58
58
  standard_name_
59
59
  end
60
60
  end
61
-
61
+
62
62
  end
63
-
63
+
64
64
  VISITORS['mysql2spatial'] = ::Arel::Visitors::MySQL2Spatial
65
-
65
+
66
66
  end
67
67
  end
68
68
 
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Mysql2Spatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -37,38 +37,47 @@
37
37
  # :stopdoc:
38
38
 
39
39
  module ActiveRecord
40
-
40
+
41
41
  module ConnectionAdapters
42
-
42
+
43
43
  module Mysql2SpatialAdapter
44
-
45
-
44
+
45
+
46
46
  class MainAdapter < ConnectionAdapters::Mysql2Adapter
47
-
48
-
47
+
48
+
49
49
  NATIVE_DATABASE_TYPES = Mysql2Adapter::NATIVE_DATABASE_TYPES.merge(:spatial => {:name => "geometry"})
50
-
51
-
50
+
51
+
52
+ def initialize(*args_)
53
+ super
54
+ # Rails 3.2 way of defining the visitor: do so in the constructor
55
+ if defined?(@visitor) && @visitor
56
+ @visitor = ::Arel::Visitors::MySQL2Spatial.new(self)
57
+ end
58
+ end
59
+
60
+
52
61
  def set_rgeo_factory_settings(factory_settings_)
53
62
  @rgeo_factory_settings = factory_settings_
54
63
  end
55
-
56
-
64
+
65
+
57
66
  def adapter_name
58
67
  Mysql2SpatialAdapter::ADAPTER_NAME
59
68
  end
60
-
61
-
69
+
70
+
62
71
  def spatial_column_constructor(name_)
63
72
  ::RGeo::ActiveRecord::DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS[name_]
64
73
  end
65
-
66
-
74
+
75
+
67
76
  def native_database_types
68
77
  NATIVE_DATABASE_TYPES
69
78
  end
70
-
71
-
79
+
80
+
72
81
  def quote(value_, column_=nil)
73
82
  if ::RGeo::Feature::Geometry.check_type(value_)
74
83
  "GeomFromWKB(0x#{::RGeo::WKRep::WKBGenerator.new(:hex_format => true).generate(value_)},#{value_.srid})"
@@ -76,8 +85,8 @@ module ActiveRecord
76
85
  super
77
86
  end
78
87
  end
79
-
80
-
88
+
89
+
81
90
  def type_to_sql(type_, limit_=nil, precision_=nil, scale_=nil)
82
91
  if (info_ = spatial_column_constructor(type_.to_sym))
83
92
  type_ = limit_[:type] || type_ if limit_.is_a?(::Hash)
@@ -86,8 +95,8 @@ module ActiveRecord
86
95
  end
87
96
  super(type_, limit_, precision_, scale_)
88
97
  end
89
-
90
-
98
+
99
+
91
100
  def add_index(table_name_, column_name_, options_={})
92
101
  if options_[:spatial]
93
102
  index_name_ = index_name(table_name_, :column => Array(column_name_))
@@ -99,8 +108,8 @@ module ActiveRecord
99
108
  super
100
109
  end
101
110
  end
102
-
103
-
111
+
112
+
104
113
  def columns(table_name_, name_=nil)
105
114
  result_ = execute("SHOW FIELDS FROM #{quote_table_name(table_name_)}", :skip_logging)
106
115
  columns_ = []
@@ -110,8 +119,8 @@ module ActiveRecord
110
119
  end
111
120
  columns_
112
121
  end
113
-
114
-
122
+
123
+
115
124
  def indexes(table_name_, name_=nil)
116
125
  indexes_ = []
117
126
  current_index_ = nil
@@ -128,15 +137,15 @@ module ActiveRecord
128
137
  end
129
138
  indexes_
130
139
  end
131
-
132
-
140
+
141
+
133
142
  end
134
-
135
-
143
+
144
+
136
145
  end
137
-
146
+
138
147
  end
139
-
148
+
140
149
  end
141
150
 
142
151
  # :startdoc:
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Mysql2Spatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -37,15 +37,23 @@
37
37
  # :stopdoc:
38
38
 
39
39
  module ActiveRecord
40
-
40
+
41
41
  module ConnectionAdapters
42
-
42
+
43
43
  module Mysql2SpatialAdapter
44
-
45
-
46
- class SpatialColumn < ConnectionAdapters::Mysql2Column
47
-
48
-
44
+
45
+
46
+ # ActiveRecord 3.2 uses ConnectionAdapters::Mysql2Adapter::Column
47
+ # whereas 3.0 and 3.1 use ConnectionAdapters::Mysql2Column
48
+ column_base_class_ = defined?(ConnectionAdapters::Mysql2Adapter::Column) ?
49
+ ConnectionAdapters::Mysql2Adapter::Column : ConnectionAdapters::Mysql2Column
50
+
51
+ class SpatialColumn < column_base_class_
52
+
53
+
54
+ FACTORY_SETTINGS_CACHE = {}
55
+
56
+
49
57
  def initialize(factory_settings_, table_name_, name_, default_, sql_type_=nil, null_=true)
50
58
  @factory_settings = factory_settings_
51
59
  @table_name = table_name_
@@ -54,22 +62,23 @@ module ActiveRecord
54
62
  if type == :spatial
55
63
  @limit = {:type => @geometric_type.type_name.underscore}
56
64
  end
65
+ FACTORY_SETTINGS_CACHE[factory_settings_.object_id] = factory_settings_
57
66
  end
58
-
59
-
67
+
68
+
60
69
  attr_reader :geometric_type
61
-
62
-
70
+
71
+
63
72
  def spatial?
64
73
  type == :spatial
65
74
  end
66
-
67
-
75
+
76
+
68
77
  def klass
69
78
  type == :spatial ? ::RGeo::Feature::Geometry : super
70
79
  end
71
-
72
-
80
+
81
+
73
82
  def type_cast(value_)
74
83
  if type == :spatial
75
84
  SpatialColumn.convert_to_geometry(value_, @factory_settings, @table_name, name)
@@ -77,25 +86,26 @@ module ActiveRecord
77
86
  super
78
87
  end
79
88
  end
80
-
81
-
89
+
90
+
82
91
  def type_cast_code(var_name_)
83
92
  if type == :spatial
84
93
  "::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::SpatialColumn.convert_to_geometry("+
85
- "#{var_name_}, self.class.rgeo_factory_settings, self.class.table_name, #{name.inspect})"
94
+ "#{var_name_}, ::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::SpatialColumn::"+
95
+ "FACTORY_SETTINGS_CACHE[#{@factory_settings.object_id}], #{@table_name.inspect}, #{name.inspect})"
86
96
  else
87
97
  super
88
98
  end
89
99
  end
90
-
91
-
100
+
101
+
92
102
  private
93
-
103
+
94
104
  def simplified_type(sql_type_)
95
105
  sql_type_ =~ /geometry|point|linestring|polygon/i ? :spatial : super
96
106
  end
97
-
98
-
107
+
108
+
99
109
  def self.convert_to_geometry(input_, factory_settings_, table_name_, column_)
100
110
  case input_
101
111
  when ::RGeo::Feature::Geometry
@@ -122,15 +132,15 @@ module ActiveRecord
122
132
  nil
123
133
  end
124
134
  end
125
-
126
-
135
+
136
+
127
137
  end
128
-
129
-
138
+
139
+
130
140
  end
131
-
141
+
132
142
  end
133
-
143
+
134
144
  end
135
145
 
136
146
  # :startdoc:
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Mysql2Spatial adapter for ActiveRecord
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,22 +41,22 @@ end
41
41
 
42
42
 
43
43
  module ActiveRecord
44
-
44
+
45
45
  module ConnectionAdapters
46
-
46
+
47
47
  module Mysql2SpatialAdapter
48
-
49
-
48
+
49
+
50
50
  # Current version of Mysql2SpatialAdapter as a frozen string
51
51
  VERSION_STRING = ::File.read(::File.dirname(__FILE__)+'/../../../../Version').strip.freeze
52
-
52
+
53
53
  # Current version of Mysql2SpatialAdapter as a Versionomy object, if the
54
54
  # Versionomy gem is available; otherwise equal to VERSION_STRING.
55
55
  VERSION = defined?(::Versionomy) ? ::Versionomy.parse(VERSION_STRING) : VERSION_STRING
56
-
57
-
56
+
57
+
58
58
  end
59
-
59
+
60
60
  end
61
-
61
+
62
62
  end
data/test/tc_basic.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for the Mysql2Spatial ActiveRecord adapter
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,15 +41,15 @@ module RGeo
41
41
  module ActiveRecord # :nodoc:
42
42
  module Mysql2SpatialAdapter # :nodoc:
43
43
  module Tests # :nodoc:
44
-
44
+
45
45
  class TestBasic < ::Test::Unit::TestCase # :nodoc:
46
-
46
+
47
47
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
48
48
  include AdapterTestHelper
49
-
49
+
50
50
  define_test_methods do
51
-
52
-
51
+
52
+
53
53
  def populate_ar_class(content_)
54
54
  klass_ = create_ar_class
55
55
  case content_
@@ -60,13 +60,13 @@ module RGeo
60
60
  end
61
61
  klass_
62
62
  end
63
-
64
-
63
+
64
+
65
65
  def test_version
66
66
  assert_not_nil(::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::VERSION)
67
67
  end
68
-
69
-
68
+
69
+
70
70
  def test_create_simple_geometry
71
71
  klass_ = create_ar_class
72
72
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -75,8 +75,8 @@ module RGeo
75
75
  assert_equal(::RGeo::Feature::Geometry, klass_.columns.last.geometric_type)
76
76
  assert(klass_.cached_attributes.include?('latlon'))
77
77
  end
78
-
79
-
78
+
79
+
80
80
  def test_create_point_geometry
81
81
  klass_ = create_ar_class
82
82
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -85,8 +85,8 @@ module RGeo
85
85
  assert_equal(::RGeo::Feature::Point, klass_.columns.last.geometric_type)
86
86
  assert(klass_.cached_attributes.include?('latlon'))
87
87
  end
88
-
89
-
88
+
89
+
90
90
  def test_create_geometry_with_index
91
91
  klass_ = create_ar_class
92
92
  klass_.connection.create_table(:spatial_test, :options => 'ENGINE=MyISAM') do |t_|
@@ -97,8 +97,8 @@ module RGeo
97
97
  end
98
98
  assert(klass_.connection.indexes(:spatial_test).last.spatial)
99
99
  end
100
-
101
-
100
+
101
+
102
102
  def test_set_and_get_point
103
103
  klass_ = populate_ar_class(:latlon_point)
104
104
  obj_ = klass_.new
@@ -107,8 +107,8 @@ module RGeo
107
107
  assert_equal(@factory.point(1, 2), obj_.latlon)
108
108
  assert_equal(3785, obj_.latlon.srid)
109
109
  end
110
-
111
-
110
+
111
+
112
112
  def test_set_and_get_point_from_wkt
113
113
  klass_ = populate_ar_class(:latlon_point)
114
114
  obj_ = klass_.new
@@ -117,8 +117,8 @@ module RGeo
117
117
  assert_equal(@factory.point(1, 2), obj_.latlon)
118
118
  assert_equal(1000, obj_.latlon.srid)
119
119
  end
120
-
121
-
120
+
121
+
122
122
  def test_save_and_load_point
123
123
  klass_ = populate_ar_class(:latlon_point)
124
124
  obj_ = klass_.new
@@ -129,8 +129,8 @@ module RGeo
129
129
  assert_equal(@factory.point(1, 2), obj2_.latlon)
130
130
  assert_equal(3785, obj2_.latlon.srid)
131
131
  end
132
-
133
-
132
+
133
+
134
134
  def test_save_and_load_point_from_wkt
135
135
  klass_ = populate_ar_class(:latlon_point)
136
136
  obj_ = klass_.new
@@ -141,8 +141,8 @@ module RGeo
141
141
  assert_equal(@factory.point(1, 2), obj2_.latlon)
142
142
  assert_equal(1000, obj2_.latlon.srid)
143
143
  end
144
-
145
-
144
+
145
+
146
146
  def test_readme_example
147
147
  klass_ = create_ar_class
148
148
  klass_.connection.create_table(:spatial_test, :options => 'ENGINE=MyISAM') do |t_|
@@ -164,8 +164,8 @@ module RGeo
164
164
  rec_.shape = loc_
165
165
  assert_equal(true, ::RGeo::Geos.is_geos?(rec_.shape))
166
166
  end
167
-
168
-
167
+
168
+
169
169
  def test_create_simple_geometry_using_shortcut
170
170
  klass_ = create_ar_class
171
171
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -174,8 +174,8 @@ module RGeo
174
174
  assert_equal(::RGeo::Feature::Geometry, klass_.columns.last.geometric_type)
175
175
  assert(klass_.cached_attributes.include?('latlon'))
176
176
  end
177
-
178
-
177
+
178
+
179
179
  def test_create_point_geometry_using_shortcut
180
180
  klass_ = create_ar_class
181
181
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -184,8 +184,8 @@ module RGeo
184
184
  assert_equal(::RGeo::Feature::Point, klass_.columns.last.geometric_type)
185
185
  assert(klass_.cached_attributes.include?('latlon'))
186
186
  end
187
-
188
-
187
+
188
+
189
189
  def test_create_geometry_using_limit
190
190
  klass_ = create_ar_class
191
191
  klass_.connection.create_table(:spatial_test) do |t_|
@@ -194,12 +194,12 @@ module RGeo
194
194
  assert_equal(::RGeo::Feature::LineString, klass_.columns.last.geometric_type)
195
195
  assert(klass_.cached_attributes.include?('geom'))
196
196
  end
197
-
198
-
197
+
198
+
199
199
  end
200
-
200
+
201
201
  end
202
-
202
+
203
203
  end
204
204
  end
205
205
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Tests for the Mysql2Spatial ActiveRecord adapter
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2010 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,15 +41,15 @@ module RGeo
41
41
  module ActiveRecord # :nodoc:
42
42
  module Mysql2SpatialAdapter # :nodoc:
43
43
  module Tests # :nodoc:
44
-
44
+
45
45
  class TestSpatialQueries < ::Test::Unit::TestCase # :nodoc:
46
-
46
+
47
47
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
48
48
  include AdapterTestHelper
49
-
49
+
50
50
  define_test_methods do
51
-
52
-
51
+
52
+
53
53
  def populate_ar_class(content_)
54
54
  klass_ = create_ar_class
55
55
  case content_
@@ -64,8 +64,8 @@ module RGeo
64
64
  end
65
65
  klass_
66
66
  end
67
-
68
-
67
+
68
+
69
69
  def test_query_point
70
70
  klass_ = populate_ar_class(:latlon_point)
71
71
  obj_ = klass_.new
@@ -77,8 +77,8 @@ module RGeo
77
77
  obj3_ = klass_.where(:latlon => @factory.point(2, 2)).first
78
78
  assert_nil(obj3_)
79
79
  end
80
-
81
-
80
+
81
+
82
82
  def _test_query_point_wkt
83
83
  klass_ = populate_ar_class(:latlon_point)
84
84
  obj_ = klass_.new
@@ -90,11 +90,11 @@ module RGeo
90
90
  obj3_ = klass_.where(:latlon => 'POINT(2 2)').first
91
91
  assert_nil(obj3_)
92
92
  end
93
-
94
-
93
+
94
+
95
95
  if ::RGeo::ActiveRecord.spatial_expressions_supported?
96
-
97
-
96
+
97
+
98
98
  def test_query_st_length
99
99
  klass_ = populate_ar_class(:path_linestring)
100
100
  obj_ = klass_.new
@@ -106,19 +106,19 @@ module RGeo
106
106
  obj3_ = klass_.where(klass_.arel_table[:path].st_length.gt(3)).first
107
107
  assert_nil(obj3_)
108
108
  end
109
-
110
-
109
+
110
+
111
111
  else
112
-
112
+
113
113
  puts "WARNING: The current Arel does not support named functions. Spatial expression tests skipped."
114
-
114
+
115
115
  end
116
-
117
-
116
+
117
+
118
118
  end
119
-
119
+
120
120
  end
121
-
121
+
122
122
  end
123
123
  end
124
124
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql2spatial-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-07 00:00:00.000000000Z
12
+ date: 2012-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rgeo-activerecord
16
- requirement: &2152422340 !ruby/object:Gem::Requirement
16
+ requirement: &2155892300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.4.0
21
+ version: 0.4.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152422340
24
+ version_requirements: *2155892300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mysql2
27
- requirement: &2152426400 !ruby/object:Gem::Requirement
27
+ requirement: &2155891180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 0.2.13
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152426400
35
+ version_requirements: *2155891180
36
36
  description: This is an ActiveRecord connection adapter for MySQL Spatial Extensions.
37
37
  It is based on the stock MySQL2 adapter, but provides built-in support for spatial
38
38
  columns. It uses the RGeo library to represent spatial data in Ruby.
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: 1.3.1
74
74
  requirements: []
75
75
  rubyforge_project: virtuoso
76
- rubygems_version: 1.8.10
76
+ rubygems_version: 1.8.17
77
77
  signing_key:
78
78
  specification_version: 3
79
79
  summary: An ActiveRecord adapter for MySQL Spatial Extensions, based on RGeo and the