activerecord-mysql2spatial-adapter 0.4.3 → 0.5.0.nonrelease

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b8d40564381c47e55e634419b4fc6b0dc12d1b03
4
+ data.tar.gz: a1d0306b64f627235233e3d67c48e6b42805cfd0
5
+ SHA512:
6
+ metadata.gz: 7ec780b7f04438865d5a10711ce9f8fd1597151bd34d4692253f12937b7f66c7adcb10d5e8447ce34bdb53322b45ad6d41f3bb38dd1c3e6273dc78562f6c41c5
7
+ data.tar.gz: 87d5a303fdee4b95a3adba3e0ee19fab5ced228ea907955a28c4a3f225fc9c903ecd850d5a7011a0dff08a0120d4e80b35c206441885bd804a3bad8afb9ae2ca
@@ -1,3 +1,7 @@
1
+ === 0.5.0 / 2015-08-06
2
+
3
+ * Compatibility with ActiveRecord >= 4.0, < 4.2 and with rgeo-activerecord 1.x.
4
+
1
5
  === 0.4.3 / 2012-08-02
2
6
 
3
7
  * The gemspec no longer includes the timestamp in the version, so that bundler can pull from github. (Reported by corneverbruggen)
@@ -14,7 +18,7 @@
14
18
 
15
19
  === 0.4.0 / 2011-08-15
16
20
 
17
- * Various fixes for Rails 3.1 compatibility.
21
+ * Various fixes for Rails 3.1 compatibility.
18
22
  * Now requires rgeo-activerecord 0.4.0.
19
23
  * INCOMPATIBLE CHANGE: simple queries (e.g. MyClass.where(:latlon => my_point)) use an objective rather than spatial equality test. Earlier versions transformed this form to use st_equals, but now if you need to test for spatial equality, you'll need to call st_equals explicitly. I'm still evaluating which direction we want to go with this in the future, but we may be stuck with the current behavior because the hack required to transform these queries to use spatial equality was egregious and broke in Rails 3.1 with no clear workaround.
20
24
 
@@ -3,7 +3,7 @@
3
3
  The MySQL2 Spatial \ActiveRecord Adapter is an \ActiveRecord connection
4
4
  adapter based on the standard mysql2 adapter. It extends the standard
5
5
  adapter to provide support for spatial columns and indexes in MySQL,
6
- using the {RGeo}[http://github.com/dazuma/rgeo] library to represent
6
+ using the {RGeo}[http://github.com/rgeo/rgeo] library to represent
7
7
  spatial data in Ruby. Like the standard mysql2 adapter, this adapter
8
8
  requires the mysql2 gem.
9
9
 
@@ -11,7 +11,7 @@ requires the mysql2 gem.
11
11
 
12
12
  === Spatial Migrations
13
13
 
14
- First, this adapter extends the migration syntax to support creating
14
+ First, this adapter extends the migration syntax to support creating
15
15
  spatial columns and indexes. To create a spatial column, use the
16
16
  <tt>:geometry</tt> type, or any of the OGC spatial types such as
17
17
  <tt>:point</tt> or <tt>:line_string</tt>. To create a spatial index, set
@@ -19,7 +19,7 @@ the <tt>:spatial</tt> option to true. Remember that, on some versions of
19
19
  MySQL, only the MyISAM engine supports spatial indexes, and the indexed
20
20
  column may need to be NOT NULL.
21
21
 
22
- Examples:
22
+ Examples (require update):
23
23
 
24
24
  create_table :my_spatial_table, :options => 'ENGINE=MyISAM' do |t|
25
25
  t.column :latlon, :point, :null => false
@@ -55,13 +55,13 @@ the "rgeo-activerecord" gem.
55
55
  Examples, given the spatial table defined above:
56
56
 
57
57
  class MySpatialTable < ActiveRecord::Base
58
-
58
+
59
59
  # By default, use the GEOS implementation for spatial columns.
60
60
  self.rgeo_factory_generator = RGeo::Geos.method(:factory)
61
-
61
+
62
62
  # But use a geographic implementation for the :latlon column.
63
63
  set_rgeo_factory_for_column(:latlon, RGeo::Geographic.spherical_factory)
64
-
64
+
65
65
  end
66
66
 
67
67
  Now you can interact with the data using the RGeo types:
@@ -98,13 +98,13 @@ write more complex queries in SQL.
98
98
 
99
99
  This adapter has the following requirements:
100
100
 
101
- * Ruby 1.8.7 or later. Ruby 1.9.2 or later preferred.
101
+ * Ruby 1.9.3 or later. Ruby 2.0.0 or later preferred.
102
102
  * MySQL server 5.0 or later required for spatial extensions.
103
- * \ActiveRecord 3.0.3 or later. Earlier versions will not work.
104
- Should be compatible with Rails versions through 3.2.x.
103
+ * \ActiveRecord 4.0.0 or later. Earlier versions will not work.
104
+ Should be compatible with Rails versions through 4.0.x-4.1.x.
105
105
  * mysql2 gem 0.2.13 or later.
106
106
  * rgeo gem 0.3.15 or later.
107
- * rgeo-activerecord gem 0.4.5 or later.
107
+ * rgeo-activerecord gem 1.x.
108
108
 
109
109
  Install this adapter as a gem:
110
110
 
@@ -149,18 +149,16 @@ Rails as of Rails 3.0.3, so we hope it will get rectified at some point.
149
149
 
150
150
  === Development and support
151
151
 
152
- Documentation is available at http://dazuma.github.com/activerecord-mysql2spatial-adapter/rdoc
152
+ Documentation is available at http://rgeo.github.com/activerecord-mysql2spatial-adapter/rdoc
153
153
 
154
- Source code is hosted on Github at http://github.com/dazuma/activerecord-mysql2spatial-adapter
154
+ Source code is hosted on Github at http://github.com/rgeo/activerecord-mysql2spatial-adapter
155
155
 
156
156
  Contributions are welcome. Fork the project on Github.
157
157
 
158
- Report bugs on Github issues at http://github.org/dazuma/activerecord-mysql2spatial-adapter/issues
158
+ Report bugs on Github issues at http://github.org/rgeo/activerecord-mysql2spatial-adapter/issues
159
159
 
160
160
  Support available on the rgeo-users google group at http://groups.google.com/group/rgeo-users
161
161
 
162
- Contact the author at dazuma at gmail dot com.
163
-
164
162
  === Acknowledgments
165
163
 
166
164
  The Mysql2Spatial Adapter and its supporting libraries (including RGeo)
data/Version CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.5.0
@@ -84,6 +84,7 @@ end
84
84
 
85
85
 
86
86
  require 'active_record/connection_adapters/mysql2spatial_adapter/version.rb'
87
+ require 'active_record/connection_adapters/mysql2spatial_adapter/column_methods.rb' # check if this works with Rails < 4.x
87
88
  require 'active_record/connection_adapters/mysql2spatial_adapter/main_adapter.rb'
88
89
  require 'active_record/connection_adapters/mysql2spatial_adapter/spatial_column.rb'
89
90
  require 'active_record/connection_adapters/mysql2spatial_adapter/arel_tosql.rb'
@@ -0,0 +1,46 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ module Mysql2SpatialAdapter
4
+ module ColumnMethods
5
+ def spatial(name, options = {})
6
+ raise "You must set a type. For example: 't.spatial limit: { type: 'point' }'" unless options[:limit][:type]
7
+ column(name, options[:limit][:type], options)
8
+ end
9
+
10
+ def geography(name, options = {})
11
+ column(name, :geography, options)
12
+ end
13
+
14
+ def geometry(name, options = {})
15
+ column(name, :geometry, options)
16
+ end
17
+
18
+ def geometry_collection(name, options = {})
19
+ column(name, :geometry_collection, options)
20
+ end
21
+
22
+ def line_string(name, options = {})
23
+ column(name, :line_string, options)
24
+ end
25
+
26
+ def multi_line_string(name, options = {})
27
+ column(name, :multi_line_string, options)
28
+ end
29
+
30
+ def multi_point(name, options = {})
31
+ column(name, :multi_point, options)
32
+ end
33
+
34
+ def multi_polygon(name, options = {})
35
+ column(name, :multi_polygon, options)
36
+ end
37
+
38
+ def point(name, options = {})
39
+ column(name, :point, options)
40
+ end
41
+ end
42
+
43
+ ConnectionAdapters::TableDefinition.send(:include, ColumnMethods)
44
+ end
45
+ end
46
+ end
@@ -46,7 +46,7 @@ module ActiveRecord
46
46
  class MainAdapter < ConnectionAdapters::Mysql2Adapter
47
47
 
48
48
 
49
- NATIVE_DATABASE_TYPES = Mysql2Adapter::NATIVE_DATABASE_TYPES.merge(:spatial => {:name => "geometry"})
49
+ NATIVE_DATABASE_TYPES = Mysql2Adapter::NATIVE_DATABASE_TYPES.merge(spatial: { name: 'geometry' })
50
50
 
51
51
 
52
52
  def initialize(*args_)
@@ -120,7 +120,7 @@ module ActiveRecord
120
120
  columns_
121
121
  end
122
122
 
123
-
123
+ # Returns an array of indexes for the given table.
124
124
  def indexes(table_name_, name_=nil)
125
125
  indexes_ = []
126
126
  current_index_ = nil
@@ -129,11 +129,20 @@ module ActiveRecord
129
129
  if current_index_ != row_[:Key_name]
130
130
  next if row_[:Key_name] == 'PRIMARY' # skip the primary key
131
131
  current_index_ = row_[:Key_name]
132
- indexes_ << ::RGeo::ActiveRecord::SpatialIndexDefinition.new(row_[:Table], row_[:Key_name], row_[:Non_unique] == 0, [], [], row_[:Index_type] == 'SPATIAL')
132
+ mysql_index_type = row_[:Index_type].downcase.to_sym
133
+ index_type = INDEX_TYPES.include?(mysql_index_type) ? mysql_index_type : nil
134
+ index_using = INDEX_USINGS.include?(mysql_index_type) ? mysql_index_type : nil
135
+ options = [row_[:Table], row_[:Key_name], row_[:Non_unique].to_i == 0, [], [], nil, nil, index_type, index_using]
136
+ indexes_ << if mysql_index_type == :spatial
137
+ options.push(true)
138
+ ::RGeo::ActiveRecord::SpatialIndexDefinition.new(*options)
139
+ else
140
+ IndexDefinition.new(*options)
141
+ end
133
142
  end
134
143
  last_index_ = indexes_.last
135
144
  last_index_.columns << row_[:Column_name]
136
- last_index_.lengths << row_[:Sub_part] unless last_index_.spatial
145
+ last_index_.lengths << row_[:Sub_part] unless mysql_index_type == :spatial
137
146
  end
138
147
  indexes_
139
148
  end
@@ -60,7 +60,7 @@ module ActiveRecord
60
60
  super(name_, default_,sql_type_, null_)
61
61
  @geometric_type = ::RGeo::ActiveRecord.geometric_type_from_name(sql_type_)
62
62
  if type == :spatial
63
- @limit = {:type => @geometric_type.type_name.underscore}
63
+ @limit = { type: @geometric_type.type_name.underscore }
64
64
  end
65
65
  FACTORY_SETTINGS_CACHE[factory_settings_.object_id] = factory_settings_
66
66
  end
@@ -33,7 +33,7 @@
33
33
  # -----------------------------------------------------------------------------
34
34
  ;
35
35
 
36
- require 'test/unit'
36
+ require 'minitest/autorun'
37
37
  require 'rgeo/active_record/adapter_test_helper'
38
38
 
39
39
 
@@ -42,10 +42,10 @@ module RGeo
42
42
  module Mysql2SpatialAdapter # :nodoc:
43
43
  module Tests # :nodoc:
44
44
 
45
- class TestBasic < ::Test::Unit::TestCase # :nodoc:
45
+ class TestBasic < ::Minitest::Test # :nodoc:
46
46
 
47
47
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
48
- include AdapterTestHelper
48
+ include RGeo::ActiveRecord::AdapterTestHelper
49
49
 
50
50
  define_test_methods do
51
51
 
@@ -63,7 +63,7 @@ module RGeo
63
63
 
64
64
 
65
65
  def test_version
66
- assert_not_nil(::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::VERSION)
66
+ refute_nil(::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::VERSION)
67
67
  end
68
68
 
69
69
 
@@ -33,7 +33,7 @@
33
33
  # -----------------------------------------------------------------------------
34
34
  ;
35
35
 
36
- require 'test/unit'
36
+ require 'minitest/autorun'
37
37
  require 'rgeo/active_record/adapter_test_helper'
38
38
 
39
39
 
@@ -42,10 +42,10 @@ module RGeo
42
42
  module Mysql2SpatialAdapter # :nodoc:
43
43
  module Tests # :nodoc:
44
44
 
45
- class TestSpatialQueries < ::Test::Unit::TestCase # :nodoc:
45
+ class TestSpatialQueries < ::Minitest::Test # :nodoc:
46
46
 
47
47
  DATABASE_CONFIG_PATH = ::File.dirname(__FILE__)+'/database.yml'
48
- include AdapterTestHelper
48
+ include RGeo::ActiveRecord::AdapterTestHelper
49
49
 
50
50
  define_test_methods do
51
51
 
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-mysql2spatial-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
5
- prerelease:
4
+ version: 0.5.0.nonrelease
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daniel Azuma
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-03 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rgeo-activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 0.4.5
19
+ version: '1.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 0.4.5
26
+ version: '1.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: mysql2
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 0.2.13
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 0.2.13
46
41
  description: This is an ActiveRecord connection adapter for MySQL Spatial Extensions.
@@ -53,41 +48,42 @@ extra_rdoc_files:
53
48
  - History.rdoc
54
49
  - README.rdoc
55
50
  files:
51
+ - History.rdoc
52
+ - README.rdoc
53
+ - Version
54
+ - lib/active_record/connection_adapters/mysql2spatial_adapter.rb
56
55
  - lib/active_record/connection_adapters/mysql2spatial_adapter/arel_tosql.rb
56
+ - lib/active_record/connection_adapters/mysql2spatial_adapter/column_methods.rb
57
57
  - lib/active_record/connection_adapters/mysql2spatial_adapter/main_adapter.rb
58
58
  - lib/active_record/connection_adapters/mysql2spatial_adapter/spatial_column.rb
59
59
  - lib/active_record/connection_adapters/mysql2spatial_adapter/version.rb
60
- - lib/active_record/connection_adapters/mysql2spatial_adapter.rb
61
60
  - test/tc_basic.rb
62
61
  - test/tc_spatial_queries.rb
63
- - History.rdoc
64
- - README.rdoc
65
- - Version
66
62
  homepage: http://dazuma.github.com/activerecord-mysql2spatial-adapter
67
63
  licenses: []
64
+ metadata: {}
68
65
  post_install_message:
69
66
  rdoc_options: []
70
67
  require_paths:
71
68
  - lib
72
69
  required_ruby_version: !ruby/object:Gem::Requirement
73
- none: false
74
70
  requirements:
75
- - - ! '>='
71
+ - - ">="
76
72
  - !ruby/object:Gem::Version
77
- version: 1.8.7
73
+ version: 1.9.3
78
74
  required_rubygems_version: !ruby/object:Gem::Requirement
79
- none: false
80
75
  requirements:
81
- - - ! '>'
76
+ - - ">"
82
77
  - !ruby/object:Gem::Version
83
78
  version: 1.3.1
84
79
  requirements: []
85
80
  rubyforge_project: virtuoso
86
- rubygems_version: 1.8.24
81
+ rubygems_version: 2.4.3
87
82
  signing_key:
88
- specification_version: 3
83
+ specification_version: 4
89
84
  summary: An ActiveRecord adapter for MySQL Spatial Extensions, based on RGeo and the
90
85
  mysql2 gem.
91
86
  test_files:
92
87
  - test/tc_basic.rb
93
88
  - test/tc_spatial_queries.rb
89
+ has_rdoc: