activerecord-postgis-adapter 3.0.0.beta5 → 3.0.0

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.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/arel_tosql.rb +0 -0
  3. data/lib/active_record/connection_adapters/postgis/column_methods.rb +50 -0
  4. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/create_connection.rb +4 -4
  5. data/lib/active_record/connection_adapters/postgis/databases.rake +16 -0
  6. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/oid/spatial.rb +1 -1
  7. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/postgis_database_tasks.rb +1 -1
  8. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/railtie.rb +1 -1
  9. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/schema_statements.rb +2 -2
  10. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/setup.rb +1 -1
  11. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/spatial_column.rb +1 -1
  12. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/spatial_column_info.rb +2 -2
  13. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/spatial_table_definition.rb +7 -58
  14. data/lib/active_record/connection_adapters/{postgis_adapter → postgis}/version.rb +2 -2
  15. data/lib/active_record/connection_adapters/postgis_adapter.rb +78 -14
  16. data/test/basic_test.rb +1 -1
  17. data/test/ddl_test.rb +26 -17
  18. data/test/tasks_test.rb +2 -2
  19. data/test/type_test.rb +1 -1
  20. metadata +21 -23
  21. data/lib/active_record/connection_adapters/postgis_adapter/databases.rake +0 -17
  22. data/lib/active_record/connection_adapters/postgis_adapter/main_adapter.rb +0 -70
  23. data/lib/activerecord/postgis/adapter.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da8f856d4cf24c6499865f61ffca7aa83dfde847
4
- data.tar.gz: bb1f2d2716ef65650d7a438a62554e5f07cea2b0
3
+ metadata.gz: cae625bce4f6b68a5af7ea8c529ec394f87893e6
4
+ data.tar.gz: 53f7eec3f8cf9f34d65b5b730ebb9b96752c5160
5
5
  SHA512:
6
- metadata.gz: 0aae508c94cd5a4d07e72e451b024f69fefb955db49213700490d7a71007cf3f0c7306479b6292e1b98fc841a7b3868bb26b3f91eb6ec916f0d9a47246dea898
7
- data.tar.gz: 68e42bce528929b082443e7afc6736e80a4d1c89084300e3a648f0574486bae913937a46650153fb357f4f90be69619bbecf9325479e6376821b6d9ccf147179
6
+ metadata.gz: b48c96beba75c73a99c290576316749f2116f2cd2b3e5763e4e58edabbe867998b9c3e4841b721bfb8254d88737a5120a5c0f369aff54c8b7e506d6e682f8055
7
+ data.tar.gz: eda94967ac1d14c80500ae57b62a38982152f8fd5b722d3c37a2995e046398d366214436f832e1942785758a77edd29637eb5a4eecab75fbddc02504686e94d9
@@ -0,0 +1,50 @@
1
+ module ActiveRecord
2
+ module ConnectionAdapters
3
+ module PostGIS
4
+ module ColumnMethods
5
+ def spatial(name, options = {})
6
+ raise "You must set a type. For example: 't.spatial type: :st_point'" unless options[:type]
7
+ column(name, options[: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 st_point(name, options = {})
39
+ column(name, :st_point, options)
40
+ end
41
+
42
+ def st_polygon(name, options = {})
43
+ column(name, :st_polygon, options)
44
+ end
45
+ end
46
+
47
+ PostgreSQL::Table.send(:include, ColumnMethods)
48
+ end
49
+ end
50
+ end
@@ -1,4 +1,4 @@
1
- if(defined?(::RUBY_ENGINE) && ::RUBY_ENGINE == 'jruby')
1
+ if RUBY_ENGINE == 'jruby'
2
2
  require 'active_record/connection_adapters/jdbcpostgresql_adapter'
3
3
  else
4
4
  require 'pg'
@@ -7,10 +7,10 @@ end
7
7
  module ActiveRecord # :nodoc:
8
8
  module ConnectionHandling # :nodoc:
9
9
 
10
- if(defined?(::RUBY_ENGINE) && ::RUBY_ENGINE == 'jruby')
10
+ if RUBY_ENGINE == 'jruby'
11
11
 
12
12
  def postgis_connection(config)
13
- config[:adapter_class] = ::ActiveRecord::ConnectionAdapters::PostGISAdapter::MainAdapter
13
+ config[:adapter_class] = ConnectionAdapters::PostGISAdapter
14
14
  postgresql_connection(config)
15
15
  end
16
16
 
@@ -35,7 +35,7 @@ module ActiveRecord # :nodoc:
35
35
 
36
36
  # The postgres drivers don't allow the creation of an unconnected PGconn object,
37
37
  # so just pass a nil connection object for the time being.
38
- ConnectionAdapters::PostGISAdapter::MainAdapter.new(nil, logger, conn_params, config)
38
+ ConnectionAdapters::PostGISAdapter.new(nil, logger, conn_params, config)
39
39
  end
40
40
 
41
41
  end
@@ -0,0 +1,16 @@
1
+ namespace :db do
2
+ namespace :gis do
3
+ desc "Setup PostGIS data in the database"
4
+ task setup: [:load_config] do
5
+ environments = [Rails.env]
6
+ environments << "test" if Rails.env.development?
7
+ ActiveRecord::Base.configurations
8
+ .values_at(*environments)
9
+ .compact
10
+ .reject{ |config| config["database"].blank? }
11
+ .each do |config|
12
+ ActiveRecord::ConnectionAdapters::PostGIS::PostGISDatabaseTasks.new(config).setup_gis
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
- module PostGISAdapter
3
+ module PostGIS
4
4
  module OID
5
5
  class Spatial < Type::Value
6
6
  # sql_type is a string that comes from the database definition
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord # :nodoc:
2
2
  module ConnectionAdapters # :nodoc:
3
- module PostGISAdapter # :nodoc:
3
+ module PostGIS # :nodoc:
4
4
  class PostGISDatabaseTasks < ::ActiveRecord::Tasks::PostgreSQLDatabaseTasks # :nodoc:
5
5
 
6
6
  def initialize(config)
@@ -3,7 +3,7 @@ require 'active_record/connection_adapters/postgis_adapter'
3
3
 
4
4
  module ActiveRecord # :nodoc:
5
5
  module ConnectionAdapters # :nodoc:
6
- module PostGISAdapter # :nodoc:
6
+ module PostGIS # :nodoc:
7
7
  class Railtie < ::Rails::Railtie # :nodoc:
8
8
  rake_tasks do
9
9
  load ::File.expand_path("databases.rake", ::File.dirname(__FILE__))
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
- module PostGISAdapter
3
+ module PostGIS
4
4
  module SchemaStatements
5
5
  # override
6
6
  # pass table_name to #new_column
@@ -74,7 +74,7 @@ module ActiveRecord
74
74
 
75
75
  # override
76
76
  def create_table_definition(name, temporary, options, as = nil)
77
- PostGISAdapter::TableDefinition.new(native_database_types, name, temporary, options, as, self)
77
+ PostGIS::TableDefinition.new(native_database_types, name, temporary, options, as)
78
78
  end
79
79
 
80
80
  # memoize hash of column infos for tables
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord # :nodoc:
2
2
  module ConnectionAdapters # :nodoc:
3
- module PostGISAdapter # :nodoc:
3
+ module PostGIS # :nodoc:
4
4
 
5
5
  def self.initial_setup
6
6
  ::ActiveRecord::SchemaDumper.ignore_tables |= %w[geometry_columns spatial_ref_sys layer topology]
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord # :nodoc:
2
2
  module ConnectionAdapters # :nodoc:
3
- module PostGISAdapter # :nodoc:
3
+ module PostGIS # :nodoc:
4
4
  class SpatialColumn < ConnectionAdapters::PostgreSQLColumn # :nodoc:
5
5
 
6
6
  # sql_type examples:
@@ -1,6 +1,6 @@
1
1
  module ActiveRecord # :nodoc:
2
2
  module ConnectionAdapters # :nodoc:
3
- module PostGISAdapter
3
+ module PostGIS
4
4
  # Do spatial sql queries for column info and memoize that info.
5
5
  class SpatialColumnInfo
6
6
  def initialize(adapter, table_name)
@@ -32,7 +32,7 @@ module ActiveRecord # :nodoc:
32
32
 
33
33
  # do not query the database for non-spatial columns/tables
34
34
  def get(column_name, type)
35
- return unless MainAdapter.spatial_column_options(type.to_sym)
35
+ return unless PostGISAdapter.spatial_column_options(type.to_sym)
36
36
  @spatial_column_info ||= all
37
37
  @spatial_column_info[column_name]
38
38
  end
@@ -1,17 +1,12 @@
1
1
  module ActiveRecord # :nodoc:
2
2
  module ConnectionAdapters # :nodoc:
3
- module PostGISAdapter # :nodoc:
3
+ module PostGIS # :nodoc:
4
4
  class TableDefinition < PostgreSQL::TableDefinition # :nodoc:
5
+ include ColumnMethods
5
6
 
6
- def initialize(types, name, temporary, options, as, adapter)
7
- @adapter = adapter
8
- @spatial_columns_hash = {}
9
- super(types, name, temporary, options, as)
10
- end
11
-
12
- # super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb#L320
7
+ # super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
13
8
  def new_column_definition(name, type, options)
14
- if (info = MainAdapter.spatial_column_options(type.to_sym))
9
+ if (info = PostGISAdapter.spatial_column_options(type.to_sym))
15
10
  if (limit = options.delete(:limit))
16
11
  options.merge!(limit) if limit.is_a?(::Hash)
17
12
  end
@@ -30,7 +25,6 @@ module ActiveRecord # :nodoc:
30
25
  column.srid = options[:srid]
31
26
  column.has_z = options[:has_z]
32
27
  column.has_m = options[:has_m]
33
- (column.geographic? ? @columns_hash : @spatial_columns_hash)[name] = column
34
28
  else
35
29
  column = super(name, type, options)
36
30
  end
@@ -38,56 +32,11 @@ module ActiveRecord # :nodoc:
38
32
  column
39
33
  end
40
34
 
41
- def non_geographic_spatial_columns
42
- @spatial_columns_hash.values
43
- end
44
-
45
- def spatial(name, options = {})
46
- raise "You must set a type. For example: 't.spatial type: :st_point'" unless options[:type]
47
- column(name, options[:type], options)
48
- end
49
-
50
- def geography(name, options = {})
51
- column(name, :geography, options)
52
- end
53
-
54
- def geometry(name, options = {})
55
- column(name, :geometry, options)
56
- end
57
-
58
- def geometry_collection(name, options = {})
59
- column(name, :geometry_collection, options)
60
- end
61
-
62
- def line_string(name, options = {})
63
- column(name, :line_string, options)
64
- end
65
-
66
- def multi_line_string(name, options = {})
67
- column(name, :multi_line_string, options)
68
- end
69
-
70
- def multi_point(name, options = {})
71
- column(name, :multi_point, options)
72
- end
73
-
74
- def multi_polygon(name, options = {})
75
- column(name, :multi_polygon, options)
76
- end
77
-
78
- def st_point(name, options = {})
79
- column(name, :st_point, options)
80
- end
81
-
82
- def st_polygon(name, options = {})
83
- column(name, :st_polygon, options)
84
- end
85
-
86
35
  private
87
36
 
88
37
  def create_column_definition(name, type)
89
- if MainAdapter.spatial_column_options(type.to_sym)
90
- PostGISAdapter::ColumnDefinition.new(name, type)
38
+ if PostGISAdapter.spatial_column_options(type.to_sym)
39
+ PostGIS::ColumnDefinition.new(name, type)
91
40
  else
92
41
  super
93
42
  end
@@ -143,7 +92,7 @@ module ActiveRecord # :nodoc:
143
92
  if @srid
144
93
  @srid.to_i
145
94
  else
146
- geographic? ? 4326 : PostGISAdapter::MainAdapter::DEFAULT_SRID
95
+ geographic? ? 4326 : PostGISAdapter::DEFAULT_SRID
147
96
  end
148
97
  end
149
98
 
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module ConnectionAdapters
3
- module PostGISAdapter
4
- VERSION = '3.0.0.beta5'.freeze
3
+ module PostGIS
4
+ VERSION = '3.0.0'.freeze
5
5
  end
6
6
  end
7
7
  end
@@ -5,23 +5,87 @@
5
5
 
6
6
  require 'active_record/connection_adapters/postgresql_adapter'
7
7
  require 'rgeo/active_record'
8
- require 'active_record/connection_adapters/postgis_adapter/version'
9
- require 'active_record/connection_adapters/postgis_adapter/schema_statements'
10
- require 'active_record/connection_adapters/postgis_adapter/main_adapter'
11
- require 'active_record/connection_adapters/postgis_adapter/spatial_column_info'
12
- require 'active_record/connection_adapters/postgis_adapter/spatial_table_definition'
13
- require 'active_record/connection_adapters/postgis_adapter/spatial_column'
14
- require 'active_record/connection_adapters/postgis_adapter/arel_tosql'
15
- require 'active_record/connection_adapters/postgis_adapter/setup'
16
- require 'active_record/connection_adapters/postgis_adapter/oid/spatial'
17
- require 'active_record/connection_adapters/postgis_adapter/create_connection'
18
- require 'active_record/connection_adapters/postgis_adapter/postgis_database_tasks'
8
+ require 'active_record/connection_adapters/postgis/version'
9
+ require 'active_record/connection_adapters/postgis/column_methods'
10
+ require 'active_record/connection_adapters/postgis/schema_statements'
11
+ require 'active_record/connection_adapters/postgis/spatial_column_info'
12
+ require 'active_record/connection_adapters/postgis/spatial_table_definition'
13
+ require 'active_record/connection_adapters/postgis/spatial_column'
14
+ require 'active_record/connection_adapters/postgis/arel_tosql'
15
+ require 'active_record/connection_adapters/postgis/setup'
16
+ require 'active_record/connection_adapters/postgis/oid/spatial'
17
+ require 'active_record/connection_adapters/postgis/create_connection'
18
+ require 'active_record/connection_adapters/postgis/postgis_database_tasks'
19
19
 
20
-
21
- ::ActiveRecord::ConnectionAdapters::PostGISAdapter.initial_setup
20
+ ::ActiveRecord::ConnectionAdapters::PostGIS.initial_setup
22
21
 
23
22
  if defined?(::Rails::Railtie)
24
- load ::File.expand_path('postgis_adapter/railtie.rb', ::File.dirname(__FILE__))
23
+ load ::File.expand_path('postgis/railtie.rb', ::File.dirname(__FILE__))
25
24
  end
26
25
 
27
26
  # :startdoc:
27
+
28
+ module ActiveRecord
29
+ module ConnectionAdapters
30
+ class PostGISAdapter < PostgreSQLAdapter
31
+ include PostGIS::SchemaStatements
32
+
33
+ SPATIAL_COLUMN_OPTIONS =
34
+ {
35
+ geography: { geographic: true },
36
+ geometry: {},
37
+ geometry_collection: {},
38
+ line_string: {},
39
+ multi_line_string: {},
40
+ multi_point: {},
41
+ multi_polygon: {},
42
+ spatial: {},
43
+ st_point: {},
44
+ st_polygon: {},
45
+ }
46
+
47
+ # http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
48
+ DEFAULT_SRID = 0
49
+
50
+ def initialize(*args)
51
+ super
52
+ @visitor = Arel::Visitors::PostGIS.new(self)
53
+ end
54
+
55
+ def adapter_name
56
+ "PostGIS".freeze
57
+ end
58
+
59
+ def self.spatial_column_options(key)
60
+ SPATIAL_COLUMN_OPTIONS[key]
61
+ end
62
+
63
+ def postgis_lib_version
64
+ @postgis_lib_version ||= select_value("SELECT PostGIS_Lib_Version()")
65
+ end
66
+
67
+ def default_srid
68
+ DEFAULT_SRID
69
+ end
70
+
71
+ def srs_database_columns
72
+ {
73
+ auth_name_column: 'auth_name',
74
+ auth_srid_column: 'auth_srid',
75
+ proj4text_column: 'proj4text',
76
+ srtext_column: 'srtext',
77
+ }
78
+ end
79
+
80
+ def quote(value, column = nil)
81
+ if RGeo::Feature::Geometry.check_type(value)
82
+ "'#{ RGeo::WKRep::WKBGenerator.new(hex_format: true, type_format: :ewkb, emit_ewkb_srid: true).generate(value) }'"
83
+ elsif value.is_a?(RGeo::Cartesian::BoundingBox)
84
+ "'#{ value.min_x },#{ value.min_y },#{ value.max_x },#{ value.max_y }'::box"
85
+ else
86
+ super
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -3,7 +3,7 @@ require 'test_helper'
3
3
  class BasicTest < ActiveSupport::TestCase # :nodoc:
4
4
 
5
5
  def test_version
6
- refute_nil ActiveRecord::ConnectionAdapters::PostGISAdapter::VERSION
6
+ refute_nil ActiveRecord::ConnectionAdapters::PostGIS::VERSION
7
7
  end
8
8
 
9
9
  def test_postgis_available
@@ -13,7 +13,7 @@ class DDLTest < ActiveSupport::TestCase # :nodoc:
13
13
  :st_point,
14
14
  :st_polygon,
15
15
  ].each do |type|
16
- assert ActiveRecord::ConnectionAdapters::PostGISAdapter::MainAdapter.spatial_column_options(type), type
16
+ assert ActiveRecord::ConnectionAdapters::PostGISAdapter.spatial_column_options(type), type
17
17
  end
18
18
  end
19
19
 
@@ -109,21 +109,30 @@ class DDLTest < ActiveSupport::TestCase # :nodoc:
109
109
  t.column('latlon', :geometry)
110
110
  end
111
111
  klass.connection.change_table(:spatial_models) do |t|
112
+ t.st_point('geom3', srid: 4326, geographic: true)
112
113
  t.column('geom2', :st_point, srid: 4326, geographic: true)
113
114
  t.column('name', :string)
114
115
  end
115
116
  klass.reset_column_information
116
117
  assert_equal 1, count_geometry_columns
117
- cols_ = klass.columns
118
- assert_equal RGeo::Feature::Geometry, cols_[-3].geometric_type
119
- assert_equal 0, cols_[-3].srid
120
- assert_equal true, cols_[-3].spatial?
121
- assert_equal RGeo::Feature::Point, cols_[-2].geometric_type
122
- assert_equal 4326, cols_[-2].srid
123
- assert_equal true, cols_[-2].geographic?
124
- assert_equal true, cols_[-2].spatial?
125
- assert_nil cols_[-1].geometric_type
126
- assert_equal false, cols_[-1].spatial?
118
+ cols = klass.columns
119
+ # latlon
120
+ assert_equal RGeo::Feature::Geometry, cols[-4].geometric_type
121
+ assert_equal 0, cols[-4].srid
122
+ assert_equal true, cols[-4].spatial?
123
+ # geom3
124
+ assert_equal RGeo::Feature::Point, cols[-3].geometric_type
125
+ assert_equal 4326, cols[-3].srid
126
+ assert_equal true, cols[-3].geographic?
127
+ assert_equal true, cols[-3].spatial?
128
+ # geom2
129
+ assert_equal RGeo::Feature::Point, cols[-2].geometric_type
130
+ assert_equal 4326, cols[-2].srid
131
+ assert_equal true, cols[-2].geographic?
132
+ assert_equal true, cols[-2].spatial?
133
+ # name
134
+ assert_nil cols[-1].geometric_type
135
+ assert_equal false, cols[-1].spatial?
127
136
  end
128
137
 
129
138
  def test_drop_geometry_column
@@ -136,11 +145,11 @@ class DDLTest < ActiveSupport::TestCase # :nodoc:
136
145
  end
137
146
  klass.reset_column_information
138
147
  assert_equal 1, count_geometry_columns
139
- cols_ = klass.columns
140
- assert_equal RGeo::Feature::Geometry, cols_[-1].geometric_type
141
- assert_equal 'latlon', cols_[-1].name
142
- assert_equal 0, cols_[-1].srid
143
- assert_equal false, cols_[-1].geographic?
148
+ cols = klass.columns
149
+ assert_equal RGeo::Feature::Geometry, cols[-1].geometric_type
150
+ assert_equal 'latlon', cols[-1].name
151
+ assert_equal 0, cols[-1].srid
152
+ assert_equal false, cols[-1].geographic?
144
153
  end
145
154
 
146
155
  def test_drop_geography_column
@@ -230,7 +239,7 @@ class DDLTest < ActiveSupport::TestCase # :nodoc:
230
239
  end
231
240
  klass.reset_column_information
232
241
  # `all` queries column info from the database - it should not be called when klass.columns is called
233
- ActiveRecord::ConnectionAdapters::PostGISAdapter::SpatialColumnInfo.any_instance.expects(:all).never
242
+ ActiveRecord::ConnectionAdapters::PostGIS::SpatialColumnInfo.any_instance.expects(:all).never
234
243
  # first column is id, second is name
235
244
  refute klass.columns[1].spatial?
236
245
  assert_nil klass.columns[1].has_z
@@ -145,13 +145,13 @@ class TasksTest < ActiveSupport::TestCase # :nodoc:
145
145
  FileUtils.rm_f(tmp_sql_filename)
146
146
  FileUtils.mkdir_p(::File.dirname(tmp_sql_filename))
147
147
  drop_db_if_exists
148
- ActiveRecord::ConnectionAdapters::PostGISAdapter::PostGISDatabaseTasks.new(NEW_CONNECTION).create
148
+ ActiveRecord::ConnectionAdapters::PostGIS::PostGISDatabaseTasks.new(NEW_CONNECTION).create
149
149
  rescue ActiveRecord::Tasks::DatabaseAlreadyExists
150
150
  # ignore
151
151
  end
152
152
 
153
153
  def drop_db_if_exists
154
- ActiveRecord::ConnectionAdapters::PostGISAdapter::PostGISDatabaseTasks.new(NEW_CONNECTION).drop
154
+ ActiveRecord::ConnectionAdapters::PostGIS::PostGISDatabaseTasks.new(NEW_CONNECTION).drop
155
155
  rescue ActiveRecord::Tasks::DatabaseAlreadyExists
156
156
  # ignore
157
157
  end
@@ -21,6 +21,6 @@ class TypeTest < ActiveSupport::TestCase
21
21
  private
22
22
 
23
23
  def spatial
24
- ActiveRecord::ConnectionAdapters::PostGISAdapter::OID::Spatial
24
+ ActiveRecord::ConnectionAdapters::PostGIS::OID::Spatial
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgis-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.beta5
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma, Tee Parham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '4.0'
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: '3.0'
40
+ version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.0'
97
97
  description: ActiveRecord connection adapter for PostGIS. It is based on the stock
98
- PostgreSQL adapter, but provides built-in support for the spatial extensions provided
98
+ PostgreSQL adapter, and adds built-in support for the spatial extensions provided
99
99
  by PostGIS. It uses the RGeo library to represent spatial data in Ruby.
100
100
  email: dazuma@gmail.com, parhameter@gmail.com
101
101
  executables: []
@@ -103,22 +103,21 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - LICENSE.txt
106
+ - lib/active_record/connection_adapters/postgis/arel_tosql.rb
107
+ - lib/active_record/connection_adapters/postgis/column_methods.rb
108
+ - lib/active_record/connection_adapters/postgis/create_connection.rb
109
+ - lib/active_record/connection_adapters/postgis/databases.rake
110
+ - lib/active_record/connection_adapters/postgis/oid/spatial.rb
111
+ - lib/active_record/connection_adapters/postgis/postgis_database_tasks.rb
112
+ - lib/active_record/connection_adapters/postgis/railtie.rb
113
+ - lib/active_record/connection_adapters/postgis/schema_statements.rb
114
+ - lib/active_record/connection_adapters/postgis/setup.rb
115
+ - lib/active_record/connection_adapters/postgis/spatial_column.rb
116
+ - lib/active_record/connection_adapters/postgis/spatial_column_info.rb
117
+ - lib/active_record/connection_adapters/postgis/spatial_table_definition.rb
118
+ - lib/active_record/connection_adapters/postgis/version.rb
106
119
  - lib/active_record/connection_adapters/postgis_adapter.rb
107
- - lib/active_record/connection_adapters/postgis_adapter/arel_tosql.rb
108
- - lib/active_record/connection_adapters/postgis_adapter/create_connection.rb
109
- - lib/active_record/connection_adapters/postgis_adapter/databases.rake
110
- - lib/active_record/connection_adapters/postgis_adapter/main_adapter.rb
111
- - lib/active_record/connection_adapters/postgis_adapter/oid/spatial.rb
112
- - lib/active_record/connection_adapters/postgis_adapter/postgis_database_tasks.rb
113
- - lib/active_record/connection_adapters/postgis_adapter/railtie.rb
114
- - lib/active_record/connection_adapters/postgis_adapter/schema_statements.rb
115
- - lib/active_record/connection_adapters/postgis_adapter/setup.rb
116
- - lib/active_record/connection_adapters/postgis_adapter/spatial_column.rb
117
- - lib/active_record/connection_adapters/postgis_adapter/spatial_column_info.rb
118
- - lib/active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb
119
- - lib/active_record/connection_adapters/postgis_adapter/version.rb
120
120
  - lib/activerecord-postgis-adapter.rb
121
- - lib/activerecord/postgis/adapter.rb
122
121
  - test/basic_test.rb
123
122
  - test/database.yml
124
123
  - test/ddl_test.rb
@@ -143,12 +142,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
142
  version: 1.9.3
144
143
  required_rubygems_version: !ruby/object:Gem::Requirement
145
144
  requirements:
146
- - - ">"
145
+ - - ">="
147
146
  - !ruby/object:Gem::Version
148
- version: 1.3.1
147
+ version: '0'
149
148
  requirements: []
150
149
  rubyforge_project:
151
- rubygems_version: 2.4.6
150
+ rubygems_version: 2.4.7
152
151
  signing_key:
153
152
  specification_version: 4
154
153
  summary: ActiveRecord adapter for PostGIS, based on RGeo.
@@ -162,4 +161,3 @@ test_files:
162
161
  - test/tasks_test.rb
163
162
  - test/test_helper.rb
164
163
  - test/type_test.rb
165
- has_rdoc:
@@ -1,17 +0,0 @@
1
- # :stopdoc:
2
-
3
- namespace :db do
4
- namespace :gis do
5
- desc "Setup PostGIS data in the database"
6
- task :setup => [:load_config] do
7
- environments_ = [::Rails.env]
8
- environments_ << 'test' if ::Rails.env.development?
9
- configs_ = ::ActiveRecord::Base.configurations.values_at(*environments_).compact.reject{ |config_| config_['database'].blank? }
10
- configs_.each do |config_|
11
- ::ActiveRecord::ConnectionAdapters::PostGISAdapter::PostGISDatabaseTasks.new(config_).setup_gis
12
- end
13
- end
14
- end
15
- end
16
-
17
- # :startdoc:
@@ -1,70 +0,0 @@
1
- module ActiveRecord # :nodoc:
2
- module ConnectionAdapters # :nodoc:
3
- module PostGISAdapter # :nodoc:
4
- class MainAdapter < PostgreSQLAdapter # :nodoc:
5
- include PostGISAdapter::SchemaStatements
6
-
7
- SPATIAL_COLUMN_OPTIONS =
8
- {
9
- geography: { geographic: true },
10
- geometry: {},
11
- geometry_collection: {},
12
- line_string: {},
13
- multi_line_string: {},
14
- multi_point: {},
15
- multi_polygon: {},
16
- spatial: {},
17
- st_point: {},
18
- st_polygon: {},
19
- }
20
-
21
- # http://postgis.17.x6.nabble.com/Default-SRID-td5001115.html
22
- DEFAULT_SRID = 0
23
-
24
- def initialize(*args)
25
- super
26
- @visitor = Arel::Visitors::PostGIS.new(self)
27
- end
28
-
29
- # def schema_creation
30
- # PostGISAdapter::SchemaCreation.new self
31
- # end
32
-
33
- def adapter_name
34
- "PostGIS".freeze
35
- end
36
-
37
- def self.spatial_column_options(key)
38
- SPATIAL_COLUMN_OPTIONS[key]
39
- end
40
-
41
- def postgis_lib_version
42
- @postgis_lib_version ||= select_value("SELECT PostGIS_Lib_Version()")
43
- end
44
-
45
- def default_srid
46
- DEFAULT_SRID
47
- end
48
-
49
- def srs_database_columns
50
- {
51
- auth_name_column: 'auth_name',
52
- auth_srid_column: 'auth_srid',
53
- proj4text_column: 'proj4text',
54
- srtext_column: 'srtext',
55
- }
56
- end
57
-
58
- def quote(value, column = nil)
59
- if RGeo::Feature::Geometry.check_type(value)
60
- "'#{ RGeo::WKRep::WKBGenerator.new(hex_format: true, type_format: :ewkb, emit_ewkb_srid: true).generate(value) }'"
61
- elsif value.is_a?(RGeo::Cartesian::BoundingBox)
62
- "'#{ value.min_x },#{ value.min_y },#{ value.max_x },#{ value.max_y }'::box"
63
- else
64
- super
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
@@ -1 +0,0 @@
1
- require 'active_record/connection_adapters/postgis_adapter.rb'