activerecord-spatial 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/activerecord-spatial/active_record/connection_adapters/postgresql/adapter_extensions.rb +24 -6
- data/lib/activerecord-spatial/associations.rb +5 -283
- data/lib/activerecord-spatial/associations/active_record.rb +146 -0
- data/lib/activerecord-spatial/associations/active_record_3.rb +123 -0
- data/lib/activerecord-spatial/associations/base.rb +182 -0
- data/lib/activerecord-spatial/spatial_columns.rb +1 -1
- data/lib/activerecord-spatial/spatial_function.rb +3 -2
- data/lib/activerecord-spatial/version.rb +1 -1
- data/test/associations_tests.rb +24 -4
- data/test/spatial_function_tests.rb +77 -0
- data/test/spatial_scopes_geographies_tests.rb +14 -14
- data/test/spatial_scopes_tests.rb +68 -68
- data/test/test_helper.rb +40 -31
- metadata +22 -11
- checksums.yaml +0 -15
data/test/test_helper.rb
CHANGED
@@ -25,11 +25,12 @@ POSTGIS_PATHS = [
|
|
25
25
|
'/usr/pgsql-*/share/contrib/postgis-*',
|
26
26
|
].compact
|
27
27
|
|
28
|
-
puts "
|
29
|
-
puts "
|
30
|
-
puts "
|
31
|
-
puts "
|
32
|
-
puts "GEOS
|
28
|
+
puts "ActiveRecordSpatial #{ActiveRecordSpatial::VERSION}"
|
29
|
+
puts "ActiveRecord #{Gem.loaded_specs['activerecord'].version.to_s}"
|
30
|
+
puts "Ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} - #{RbConfig::CONFIG['RUBY_INSTALL_NAME']}"
|
31
|
+
puts "Geos library #{Geos::VERSION}" if defined?(Geos::VERSION)
|
32
|
+
puts "GEOS #{Geos::GEOS_VERSION}"
|
33
|
+
puts "GEOS extensions #{Geos::GEOS_EXTENSIONS_VERSION}"
|
33
34
|
if defined?(Geos::FFIGeos)
|
34
35
|
puts "Using #{Geos::FFIGeos.geos_library_paths.join(', ')}"
|
35
36
|
end
|
@@ -174,10 +175,6 @@ class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
174
175
|
klass = model.classify
|
175
176
|
|
176
177
|
ActiveSupport::Dependencies.load_file(BASE_PATH.join("models/#{model}.rb"), [ klass ])
|
177
|
-
|
178
|
-
ActiveRecord::Base.silence do
|
179
|
-
fixtures model.pluralize
|
180
|
-
end
|
181
178
|
end
|
182
179
|
end
|
183
180
|
|
@@ -223,37 +220,49 @@ class ActiveRecordSpatialTestCase < ActiveRecord::TestCase
|
|
223
220
|
[ 0, 0 ]
|
224
221
|
], cs.to_a)
|
225
222
|
end
|
223
|
+
|
224
|
+
# Starting with Rails 4, `order` scopes are prepended to prior scopes, so
|
225
|
+
# we need to account for both here.
|
226
|
+
def apply_id_order_scope(scope)
|
227
|
+
if ActiveRecord::VERSION::MAJOR >= 4
|
228
|
+
scope.unscoped.order('id').merge(scope)
|
229
|
+
else
|
230
|
+
scope.order('id')
|
231
|
+
end
|
232
|
+
end
|
226
233
|
end
|
227
234
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
235
|
+
if !defined?(ActiveRecord::SQLCounter)
|
236
|
+
module ActiveRecord
|
237
|
+
class SQLCounter
|
238
|
+
cattr_accessor :ignored_sql
|
239
|
+
self.ignored_sql = [
|
240
|
+
/^PRAGMA (?!(table_info))/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/,
|
241
|
+
/^SELECT @@ROWCOUNT/, /^SAVEPOINT/, /^ROLLBACK TO SAVEPOINT/, /^RELEASE SAVEPOINT/,
|
242
|
+
/^SHOW max_identifier_length/, /^BEGIN/, /^COMMIT/, /^ROLLBACK/, /\WFROM pg_/
|
243
|
+
]
|
236
244
|
|
237
|
-
|
238
|
-
|
245
|
+
cattr_accessor :log
|
246
|
+
self.log = []
|
239
247
|
|
240
|
-
|
248
|
+
attr_reader :ignore
|
241
249
|
|
242
|
-
|
243
|
-
|
244
|
-
|
250
|
+
def initialize(ignore = self.class.ignored_sql)
|
251
|
+
@ignore = ignore
|
252
|
+
end
|
245
253
|
|
246
|
-
|
247
|
-
|
254
|
+
def call(name, start, finish, message_id, values)
|
255
|
+
sql = values[:sql]
|
248
256
|
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
257
|
+
# FIXME: this seems bad. we should probably have a better way to indicate
|
258
|
+
# the query was cached
|
259
|
+
return if 'CACHE' == values[:name] || ignore.any? { |x| x =~ sql }
|
260
|
+
self.class.log << sql
|
261
|
+
end
|
253
262
|
end
|
254
|
-
end
|
255
263
|
|
256
|
-
|
264
|
+
ActiveSupport::Notifications.subscribe('sql.active_record', SQLCounter.new)
|
265
|
+
end
|
257
266
|
end
|
258
267
|
|
259
268
|
class SpatialTestRunner < MiniTest::Reporters::SpecReporter
|
metadata
CHANGED
@@ -1,43 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-spatial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- J Smith
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
type: :runtime
|
14
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
15
19
|
requirements:
|
16
20
|
- - ! '>='
|
17
21
|
- !ruby/object:Gem::Version
|
18
22
|
version: '3.2'
|
23
|
+
prerelease: false
|
19
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ! '>='
|
22
28
|
- !ruby/object:Gem::Version
|
23
29
|
version: '3.2'
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
name: rails
|
27
30
|
- !ruby/object:Gem::Dependency
|
31
|
+
name: geos-extensions
|
32
|
+
type: :runtime
|
28
33
|
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
29
35
|
requirements:
|
30
36
|
- - ! '>='
|
31
37
|
- !ruby/object:Gem::Version
|
32
38
|
version: 0.3.0.dev
|
39
|
+
prerelease: false
|
33
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
34
42
|
requirements:
|
35
43
|
- - ! '>='
|
36
44
|
- !ruby/object:Gem::Version
|
37
45
|
version: 0.3.0.dev
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
name: geos-extensions
|
41
46
|
description: ActiveRecord Spatial gives AR the ability to work with PostGIS columns.
|
42
47
|
email: code@zoocasa.com
|
43
48
|
executables: []
|
@@ -62,6 +67,9 @@ files:
|
|
62
67
|
- lib/activerecord-spatial/active_record/models/spatial_column.rb
|
63
68
|
- lib/activerecord-spatial/active_record/models/spatial_ref_sys.rb
|
64
69
|
- lib/activerecord-spatial/associations.rb
|
70
|
+
- lib/activerecord-spatial/associations/active_record.rb
|
71
|
+
- lib/activerecord-spatial/associations/active_record_3.rb
|
72
|
+
- lib/activerecord-spatial/associations/base.rb
|
65
73
|
- lib/activerecord-spatial/spatial_columns.rb
|
66
74
|
- lib/activerecord-spatial/spatial_function.rb
|
67
75
|
- lib/activerecord-spatial/spatial_scope_constants.rb
|
@@ -87,31 +95,33 @@ files:
|
|
87
95
|
- test/models/foo3d.rb
|
88
96
|
- test/models/foo_geography.rb
|
89
97
|
- test/models/zortable.rb
|
98
|
+
- test/spatial_function_tests.rb
|
90
99
|
- test/spatial_scopes_geographies_tests.rb
|
91
100
|
- test/spatial_scopes_tests.rb
|
92
101
|
- test/test_helper.rb
|
93
102
|
homepage: https://github.com/zoocasa/activerecord-spatial
|
94
103
|
licenses: []
|
95
|
-
metadata: {}
|
96
104
|
post_install_message:
|
97
105
|
rdoc_options: []
|
98
106
|
require_paths:
|
99
107
|
- lib
|
100
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
101
110
|
requirements:
|
102
111
|
- - ! '>='
|
103
112
|
- !ruby/object:Gem::Version
|
104
113
|
version: '0'
|
105
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
106
116
|
requirements:
|
107
117
|
- - ! '>='
|
108
118
|
- !ruby/object:Gem::Version
|
109
119
|
version: '0'
|
110
120
|
requirements: []
|
111
121
|
rubyforge_project:
|
112
|
-
rubygems_version:
|
122
|
+
rubygems_version: 1.8.23
|
113
123
|
signing_key:
|
114
|
-
specification_version:
|
124
|
+
specification_version: 3
|
115
125
|
summary: ActiveRecord Spatial gives AR the ability to work with PostGIS columns.
|
116
126
|
test_files:
|
117
127
|
- test/accessors_geographies_tests.rb
|
@@ -133,6 +143,7 @@ test_files:
|
|
133
143
|
- test/models/foo3d.rb
|
134
144
|
- test/models/foo_geography.rb
|
135
145
|
- test/models/zortable.rb
|
146
|
+
- test/spatial_function_tests.rb
|
136
147
|
- test/spatial_scopes_geographies_tests.rb
|
137
148
|
- test/spatial_scopes_tests.rb
|
138
149
|
- test/test_helper.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
NzVhNGNkYTg1MTBkYTM3MGFmYjI2NTBkOTEyMzRlNDhmZDZhMTM3ZQ==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmUyYzQ0ZjU3ZDllYjhjOGFhNWY3ZmU5OTY1NDRkMjk2YzY1NmFlOQ==
|
7
|
-
!binary "U0hBNTEy":
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
Yjk3MzU1MTllMzdkOWM4OWI2ZGQwNjUzYWQyMzI3ZTQ4MjAzNGRjZWYyN2Vi
|
10
|
-
YjNkYjZlYzAwNzk3MTFkZWEzMGMwMjNmODE2ZTgzYzI1NzFlNjEzMWIzZjRh
|
11
|
-
NjFlY2QxMzI1MTY5MTJiMTYzMzgwNGVjZWZjMDU2NTZlNWFhZGE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OGI3NjI0ZDI5M2JjOWJiOWYxZDExYTJkMTNmMzg1NDYyNjZkZjhmZjA5NmIy
|
14
|
-
OGM4OTIxYWYxMTExYWQ3MGZjNmJkNmY0NTEzMzM4MTZlNTc2YTRjYjBhMDlm
|
15
|
-
NzgxOGIxYTUxMDQ0MGRhNTBhNjE0YzE4ZGQ4ZGU3YmQxMDBlNDI=
|