postgis_adapter 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/README.rdoc +7 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/postgis_adapter.rb +1 -1
- data/postgis_adapter.gemspec +3 -3
- data/rails/init.rb +2 -1
- data/spec/postgis_adapter_spec.rb +51 -4
- data/spec/spec.opts +3 -3
- data/spec/spec_helper.rb +1 -0
- metadata +3 -3
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Spatial Adapter Copyright (c) 2006 Guilhem Vellut <guilhem.vellut+georuby@gmail.com>
|
1
|
+
Spatial Adapter Copyright (c) 2006 Guilhem Vellut <guilhem.vellut+georuby@gmail.com>
|
2
2
|
PostGis Adapter Functions (c) 2008 Marcos Piccinini <nofxx>
|
3
3
|
|
4
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
data/README.rdoc
CHANGED
@@ -57,6 +57,13 @@ in ruby schema mode and loaded in migrations the same way as columns
|
|
57
57
|
of basic types.
|
58
58
|
|
59
59
|
|
60
|
+
=== Example App
|
61
|
+
|
62
|
+
Simple rails app to demonstrate, check it out:
|
63
|
+
|
64
|
+
http://github.com/nofxx/postgis_example
|
65
|
+
|
66
|
+
|
60
67
|
=== Model
|
61
68
|
|
62
69
|
class TablePoint < ActiveRecord::Base
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gem.description = "Execute PostGIS functions on Active Record"
|
10
10
|
gem.email = "x@nofxx.com"
|
11
11
|
gem.homepage = "http://github.com/nofxx/postgis_adapter"
|
12
|
-
gem.authors = ["Marcos
|
12
|
+
gem.authors = ["Marcos Piccinini"]
|
13
13
|
gem.rubyforge_project = "postgis_adapter"
|
14
14
|
# TODO: better way for this.....
|
15
15
|
# gem.add_dependency 'geo_ruby'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.2
|
data/lib/postgis_adapter.rb
CHANGED
@@ -243,7 +243,7 @@ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do
|
|
243
243
|
ActiveRecord::ConnectionAdapters::SpatialPostgreSQLColumn.new(name, default,raw_geom_info.type, notnull == "f", raw_geom_info.srid, raw_geom_info.with_z, raw_geom_info.with_m)
|
244
244
|
end
|
245
245
|
else
|
246
|
-
ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new(name,
|
246
|
+
ActiveRecord::ConnectionAdapters::PostgreSQLColumn.new(name, default, type, notnull == "f")
|
247
247
|
end
|
248
248
|
end
|
249
249
|
end
|
data/postgis_adapter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{postgis_adapter}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Marcos
|
12
|
-
s.date = %q{2009-10-
|
11
|
+
s.authors = ["Marcos Piccinini"]
|
12
|
+
s.date = %q{2009-10-18}
|
13
13
|
s.description = %q{Execute PostGIS functions on Active Record}
|
14
14
|
s.email = %q{x@nofxx.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/rails/init.rb
CHANGED
@@ -3,6 +3,7 @@ end
|
|
3
3
|
|
4
4
|
unless ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
|
5
5
|
raise SpatialAdapterNotCompatibleError.
|
6
|
-
new("
|
6
|
+
new("Database config file not set or it does not map to PostgreSQL\n" +
|
7
|
+
"Only PostgreSQL with PostGIS is supported by postgis_adapter.")
|
7
8
|
end
|
8
9
|
require 'postgis_adapter'
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
2
3
|
|
3
4
|
describe "PostgisAdapter" do
|
@@ -150,8 +151,8 @@ describe "PostgisAdapter" do
|
|
150
151
|
pts = Area.find_all_by_geom(LineString.from_coordinates([[0,0],[2,2]],4326))
|
151
152
|
pts.should be_instance_of(Array)
|
152
153
|
pts.length.should eql(2)
|
153
|
-
pts[0].data.should match
|
154
|
-
pts[1].data.should match
|
154
|
+
pts[0].data.should match(/Point/)
|
155
|
+
pts[1].data.should match(/Point/)
|
155
156
|
end
|
156
157
|
|
157
158
|
it "should find by geom again" do
|
@@ -163,8 +164,8 @@ describe "PostgisAdapter" do
|
|
163
164
|
pts = Area.find_all_by_geom([[0,0],[2,2],4326])
|
164
165
|
pts.should be_instance_of(Array)
|
165
166
|
pts.length.should eql(2)
|
166
|
-
pts[0].data.should match
|
167
|
-
pts[1].data.should match
|
167
|
+
pts[0].data.should match(/Point/)
|
168
|
+
pts[1].data.should match(/Point/)
|
168
169
|
end
|
169
170
|
|
170
171
|
it "should not mess with rails finder" do
|
@@ -174,4 +175,50 @@ describe "PostgisAdapter" do
|
|
174
175
|
|
175
176
|
end
|
176
177
|
|
178
|
+
describe "PostgreSQL-specific types and default values" do
|
179
|
+
|
180
|
+
# Verify that a non-NULL column with a default value is handled correctly.
|
181
|
+
# Additionally, if the database uses UTF8 encoding, set the binary (bytea)
|
182
|
+
# column value to an illegal UTF8 string; it should be stored as the
|
183
|
+
# specified binary string and not as a text string. (The binary data test
|
184
|
+
# cannot fail if the database uses SQL_ASCII or LATIN1 encoding.)
|
185
|
+
|
186
|
+
ActiveRecord::Schema.define() do
|
187
|
+
create_table :binary_defaults, :force => true do |t|
|
188
|
+
t.string :name, :null => false
|
189
|
+
t.string :data, :null => false, :default => ''
|
190
|
+
t.binary :value
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
class BinaryDefault < ActiveRecord::Base
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should create some records" do
|
198
|
+
if BinaryDefault.connection.encoding == "UTF8"
|
199
|
+
BinaryDefault.create!(:name => "foo", :data => "baz",
|
200
|
+
:value => "f\xf4o") # fôo as ISO-8859-1 (i.e., not valid UTF-8 data)
|
201
|
+
BinaryDefault.create!(:name => "bar", # data value not specified, should use default
|
202
|
+
:value => "b\xe5r") # bår as ISO-8859-1 (i.e., not valid UTF-8 data)
|
203
|
+
else
|
204
|
+
BinaryDefault.create!(:name => "foo", :data => "baz")
|
205
|
+
BinaryDefault.create!(:name => "bar")
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should find the records" do
|
210
|
+
foo = BinaryDefault.find_by_name("foo")
|
211
|
+
bar = BinaryDefault.find_by_name("bar")
|
212
|
+
|
213
|
+
foo.data.should eql("baz")
|
214
|
+
bar.data.should eql("")
|
215
|
+
|
216
|
+
if BinaryDefault.connection.encoding == "UTF8"
|
217
|
+
foo.value.should eql("f\xf4o")
|
218
|
+
bar.value.should eql("b\xe5r")
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
end
|
223
|
+
|
177
224
|
end
|
data/spec/spec.opts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
--colour
|
2
|
-
--format profile
|
3
|
-
--timeout 20
|
1
|
+
--colour
|
2
|
+
--format profile
|
3
|
+
--timeout 20
|
4
4
|
--diff
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postgis_adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Marcos
|
7
|
+
- Marcos Piccinini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-18 01:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|