Skip to content

Commit c05d556

Browse files
committed
Code formatting updates; rdoc updates towards next version
1 parent 2862fd1 commit c05d556

File tree

11 files changed

+236
-196
lines changed

11 files changed

+236
-196
lines changed

History.rdoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
16
=== 0.4.1 / 2011-09-07
27

38
* Now requests mysql2 >= 0.2.x instead of >= 0.3.x since the latter requires Rails 3.1. (Reported by Greg Hazel)

README.rdoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ This adapter has the following requirements:
101101
* Ruby 1.8.7 or later. Ruby 1.9.2 or later preferred.
102102
* MySQL server 5.0 or later required for spatial extensions.
103103
* \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.
105105
* 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.
108108

109109
Install this adapter as a gem:
110110

@@ -166,7 +166,7 @@ Contact the author at dazuma at gmail dot com.
166166
The Mysql2Spatial Adapter and its supporting libraries (including RGeo)
167167
are written by Daniel Azuma (http://www.daniel-azuma.com).
168168

169-
Development of RGeo is sponsored by GeoPage, Inc. (http://www.geopage.com).
169+
Development is supported by Pirq. (http://www.pirq.com).
170170

171171
This adapter implementation owes some debt to the spatial_adapter plugin
172172
(http://github.com/fragility/spatial_adapter). Although we made a few

Version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.1
1+
0.4.2

activerecord-mysql2spatial-adapter.gemspec

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
# -----------------------------------------------------------------------------
2+
#
3+
# MySQL2 Spatial ActiveRecord Adapter Gemspec
4+
#
5+
# -----------------------------------------------------------------------------
6+
# Copyright 2011-2012 Daniel Azuma
7+
#
8+
# All rights reserved.
9+
#
10+
# Redistribution and use in source and binary forms, with or without
11+
# modification, are permitted provided that the following conditions are met:
12+
#
13+
# * Redistributions of source code must retain the above copyright notice,
14+
# this list of conditions and the following disclaimer.
15+
# * Redistributions in binary form must reproduce the above copyright notice,
16+
# this list of conditions and the following disclaimer in the documentation
17+
# and/or other materials provided with the distribution.
18+
# * Neither the name of the copyright holder, nor the names of any other
19+
# contributors to this software, may be used to endorse or promote products
20+
# derived from this software without specific prior written permission.
21+
#
22+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32+
# POSSIBILITY OF SUCH DAMAGE.
33+
# -----------------------------------------------------------------------------
34+
;
35+
136
::Gem::Specification.new do |s_|
237
s_.name = 'activerecord-mysql2spatial-adapter'
338
s_.summary = 'An ActiveRecord adapter for MySQL Spatial Extensions, based on RGeo and the mysql2 gem.'
@@ -15,6 +50,6 @@
1550
s_.extra_rdoc_files = ::Dir.glob("*.rdoc")
1651
s_.test_files = ::Dir.glob("test/**/tc_*.rb")
1752
s_.platform = ::Gem::Platform::RUBY
18-
s_.add_dependency('rgeo-activerecord', '~> 0.4.0')
53+
s_.add_dependency('rgeo-activerecord', '~> 0.4.3')
1954
s_.add_dependency('mysql2', '>= 0.2.13')
2055
end

lib/active_record/connection_adapters/mysql2spatial_adapter.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# -----------------------------------------------------------------------------
2-
#
2+
#
33
# Mysql2Spatial adapter for ActiveRecord
4-
#
4+
#
55
# -----------------------------------------------------------------------------
66
# Copyright 2010 Daniel Azuma
7-
#
7+
#
88
# All rights reserved.
9-
#
9+
#
1010
# Redistribution and use in source and binary forms, with or without
1111
# modification, are permitted provided that the following conditions are met:
12-
#
12+
#
1313
# * Redistributions of source code must retain the above copyright notice,
1414
# this list of conditions and the following disclaimer.
1515
# * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
1818
# * Neither the name of the copyright holder, nor the names of any other
1919
# contributors to this software, may be used to endorse or promote products
2020
# derived from this software without specific prior written permission.
21-
#
21+
#
2222
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2323
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2424
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -42,16 +42,16 @@
4242
# connection adapter into ActiveRecord.
4343

4444
module ActiveRecord
45-
46-
45+
46+
4747
# ActiveRecord looks for the mysql2spatial_connection factory method in
4848
# this class.
49-
49+
5050
class Base
51-
52-
51+
52+
5353
# Create a mysql2spatial connection adapter.
54-
54+
5555
def self.mysql2spatial_connection(config_)
5656
config_[:username] = 'root' if config_[:username].nil?
5757
if ::Mysql2::Client.const_defined?(:FOUND_ROWS)
@@ -61,25 +61,25 @@ def self.mysql2spatial_connection(config_)
6161
options_ = [config_[:host], config_[:username], config_[:password], config_[:database], config_[:port], config_[:socket], 0]
6262
::ActiveRecord::ConnectionAdapters::Mysql2SpatialAdapter::MainAdapter.new(client_, logger, options_, config_)
6363
end
64-
65-
64+
65+
6666
end
67-
68-
67+
68+
6969
# All ActiveRecord adapters go in this namespace.
7070
module ConnectionAdapters
71-
71+
7272
# The Mysql2Spatial adapter
7373
module Mysql2SpatialAdapter
74-
74+
7575
# The name returned by the adapter_name method of this adapter.
7676
ADAPTER_NAME = 'Mysql2Spatial'.freeze
77-
77+
7878
end
79-
79+
8080
end
81-
82-
81+
82+
8383
end
8484

8585

lib/active_record/connection_adapters/mysql2spatial_adapter/arel_tosql.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# -----------------------------------------------------------------------------
2-
#
2+
#
33
# Mysql2Spatial adapter for ActiveRecord
4-
#
4+
#
55
# -----------------------------------------------------------------------------
66
# Copyright 2010 Daniel Azuma
7-
#
7+
#
88
# All rights reserved.
9-
#
9+
#
1010
# Redistribution and use in source and binary forms, with or without
1111
# modification, are permitted provided that the following conditions are met:
12-
#
12+
#
1313
# * Redistributions of source code must retain the above copyright notice,
1414
# this list of conditions and the following disclaimer.
1515
# * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
1818
# * Neither the name of the copyright holder, nor the names of any other
1919
# contributors to this software, may be used to endorse or promote products
2020
# derived from this software without specific prior written permission.
21-
#
21+
#
2222
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2323
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2424
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,17 +38,17 @@
3838

3939
module Arel
4040
module Visitors
41-
41+
4242
class MySQL2Spatial < MySQL
43-
43+
4444
FUNC_MAP = {
4545
'st_wkttosql' => 'GeomFromText',
4646
'st_wkbtosql' => 'GeomFromWKB',
4747
'st_length' => 'GLength',
4848
}
49-
49+
5050
include ::RGeo::ActiveRecord::SpatialToSql
51-
51+
5252
def st_func(standard_name_)
5353
if (name_ = FUNC_MAP[standard_name_.downcase])
5454
name_
@@ -58,11 +58,11 @@ def st_func(standard_name_)
5858
standard_name_
5959
end
6060
end
61-
61+
6262
end
63-
63+
6464
VISITORS['mysql2spatial'] = ::Arel::Visitors::MySQL2Spatial
65-
65+
6666
end
6767
end
6868

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# -----------------------------------------------------------------------------
2-
#
2+
#
33
# Mysql2Spatial adapter for ActiveRecord
4-
#
4+
#
55
# -----------------------------------------------------------------------------
66
# Copyright 2010 Daniel Azuma
7-
#
7+
#
88
# All rights reserved.
9-
#
9+
#
1010
# Redistribution and use in source and binary forms, with or without
1111
# modification, are permitted provided that the following conditions are met:
12-
#
12+
#
1313
# * Redistributions of source code must retain the above copyright notice,
1414
# this list of conditions and the following disclaimer.
1515
# * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
1818
# * Neither the name of the copyright holder, nor the names of any other
1919
# contributors to this software, may be used to endorse or promote products
2020
# derived from this software without specific prior written permission.
21-
#
21+
#
2222
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2323
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2424
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -37,56 +37,56 @@
3737
# :stopdoc:
3838

3939
module ActiveRecord
40-
40+
4141
module ConnectionAdapters
42-
42+
4343
module Mysql2SpatialAdapter
44-
45-
44+
45+
4646
class MainAdapter < ConnectionAdapters::Mysql2Adapter
47-
48-
47+
48+
4949
NATIVE_DATABASE_TYPES = Mysql2Adapter::NATIVE_DATABASE_TYPES.merge(:spatial => {:name => "geometry"})
50-
51-
50+
51+
5252
def initialize(*args_)
5353
super
5454
# Rails 3.2 way of defining the visitor: do so in the constructor
5555
if defined?(@visitor) && @visitor
5656
@visitor = ::Arel::Visitors::MySQL2Spatial.new(self)
5757
end
5858
end
59-
60-
59+
60+
6161
def set_rgeo_factory_settings(factory_settings_)
6262
@rgeo_factory_settings = factory_settings_
6363
end
64-
65-
64+
65+
6666
def adapter_name
6767
Mysql2SpatialAdapter::ADAPTER_NAME
6868
end
69-
70-
69+
70+
7171
def spatial_column_constructor(name_)
7272
::RGeo::ActiveRecord::DEFAULT_SPATIAL_COLUMN_CONSTRUCTORS[name_]
7373
end
74-
75-
74+
75+
7676
def native_database_types
7777
NATIVE_DATABASE_TYPES
7878
end
79-
80-
79+
80+
8181
def quote(value_, column_=nil)
8282
if ::RGeo::Feature::Geometry.check_type(value_)
8383
"GeomFromWKB(0x#{::RGeo::WKRep::WKBGenerator.new(:hex_format => true).generate(value_)},#{value_.srid})"
8484
else
8585
super
8686
end
8787
end
88-
89-
88+
89+
9090
def type_to_sql(type_, limit_=nil, precision_=nil, scale_=nil)
9191
if (info_ = spatial_column_constructor(type_.to_sym))
9292
type_ = limit_[:type] || type_ if limit_.is_a?(::Hash)
@@ -95,8 +95,8 @@ def type_to_sql(type_, limit_=nil, precision_=nil, scale_=nil)
9595
end
9696
super(type_, limit_, precision_, scale_)
9797
end
98-
99-
98+
99+
100100
def add_index(table_name_, column_name_, options_={})
101101
if options_[:spatial]
102102
index_name_ = index_name(table_name_, :column => Array(column_name_))
@@ -108,8 +108,8 @@ def add_index(table_name_, column_name_, options_={})
108108
super
109109
end
110110
end
111-
112-
111+
112+
113113
def columns(table_name_, name_=nil)
114114
result_ = execute("SHOW FIELDS FROM #{quote_table_name(table_name_)}", :skip_logging)
115115
columns_ = []
@@ -119,8 +119,8 @@ def columns(table_name_, name_=nil)
119119
end
120120
columns_
121121
end
122-
123-
122+
123+
124124
def indexes(table_name_, name_=nil)
125125
indexes_ = []
126126
current_index_ = nil
@@ -137,15 +137,15 @@ def indexes(table_name_, name_=nil)
137137
end
138138
indexes_
139139
end
140-
141-
140+
141+
142142
end
143-
144-
143+
144+
145145
end
146-
146+
147147
end
148-
148+
149149
end
150150

151151
# :startdoc:

0 commit comments

Comments
 (0)