activerecord-postgis-adapter 0.3.3 → 0.3.4

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.
@@ -1,3 +1,7 @@
1
+ === 0.3.4 / 2011-04-11
2
+
3
+ * A .gemspec file is now available for gem building and bundler git integration.
4
+
1
5
  === 0.3.3 / 2011-02-28
2
6
 
3
7
  * INCOMPATIBLE CHANGE: the default SRID for non-geography columns is now -1, rather than 4326. (Geography columns still default to 4326.)
@@ -114,8 +114,8 @@ This adapter has the following requirements:
114
114
  * PostGIS 1.5 or later.
115
115
  * pg gem 0.10 or later.
116
116
  * \ActiveRecord 3.0.3 or later. Earlier versions will not work.
117
- * rgeo gem 0.2.4 or later.
118
- * rgeo-activerecord gem 0.3.1 or later.
117
+ * rgeo gem 0.2.8 or later.
118
+ * rgeo-activerecord gem 0.3.3 or later.
119
119
 
120
120
  Install this adapter as a gem:
121
121
 
@@ -276,7 +276,7 @@ source gave us a head start on the implementation.
276
276
 
277
277
  === License
278
278
 
279
- Copyright 2010 Daniel Azuma
279
+ Copyright 2010-2011 Daniel Azuma
280
280
 
281
281
  All rights reserved.
282
282
 
data/Version CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: activerecord-postgis-adapter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.3
5
+ version: 0.3.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Azuma
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-28 00:00:00 -08:00
14
- default_executable:
13
+ date: 2011-04-11 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rgeo-activerecord
@@ -21,7 +20,7 @@ dependencies:
21
20
  requirements:
22
21
  - - ~>
23
22
  - !ruby/object:Gem::Version
24
- version: 0.3.1
23
+ version: 0.3.3
25
24
  type: :runtime
26
25
  version_requirements: *id001
27
26
  - !ruby/object:Gem::Dependency
@@ -53,14 +52,12 @@ files:
53
52
  - lib/active_record/connection_adapters/postgis_adapter/version.rb
54
53
  - lib/active_record/connection_adapters/postgis_adapter.rb
55
54
  - lib/rgeo/active_record/postgis_adapter/railtie.rb
56
- - lib/active_record/connection_adapters/postgis_adapter/databases.rake
57
- - History.rdoc
58
- - README.rdoc
59
55
  - test/tc_basic.rb
60
56
  - test/tc_ddl.rb
61
57
  - test/tc_spatial_queries.rb
58
+ - History.rdoc
59
+ - README.rdoc
62
60
  - Version
63
- has_rdoc: true
64
61
  homepage: http://virtuoso.rubyforge.org/activerecord-postgis-adapter
65
62
  licenses: []
66
63
 
@@ -78,13 +75,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
75
  required_rubygems_version: !ruby/object:Gem::Requirement
79
76
  none: false
80
77
  requirements:
81
- - - ">="
78
+ - - ">"
82
79
  - !ruby/object:Gem::Version
83
- version: "0"
80
+ version: 1.3.1
84
81
  requirements: []
85
82
 
86
83
  rubyforge_project: virtuoso
87
- rubygems_version: 1.5.3
84
+ rubygems_version: 1.7.2
88
85
  signing_key:
89
86
  specification_version: 3
90
87
  summary: An ActiveRecord adapter for PostGIS, based on RGeo.
@@ -1,147 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- #
3
- # Rakefile changes for PostGIS adapter
4
- #
5
- # -----------------------------------------------------------------------------
6
- # Copyright 2010 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
-
36
-
37
- require 'rgeo/active_record/task_hacker'
38
-
39
-
40
- class Object
41
- alias_method :create_database_without_postgis, :create_database
42
- alias_method :drop_database_without_postgis, :drop_database
43
- end
44
-
45
-
46
- def create_database(config_)
47
- if config_['adapter'] == 'postgis'
48
- @encoding = config_['encoding'] || ::ENV['CHARSET'] || 'utf8'
49
- begin
50
- has_su_ = config_.include?('su_username') # Is there a distinct superuser?
51
- username_ = config_['username'] # regular user name
52
- su_username_ = config_['su_username'] || username_ # superuser name
53
- su_password_ = config_['su_password'] || config_['password'] # superuser password
54
-
55
- # Create the database. Optionally do so as the given superuser.
56
- # But make sure the database is owned by the regular user.
57
- ::ActiveRecord::Base.establish_connection(config_.merge('database' => 'postgres', 'schema_search_path' => 'public', 'username' => su_username_, 'password' => su_password_))
58
- extra_configs_ = {'encoding' => @encoding}
59
- extra_configs_['owner'] = username_ if has_su_
60
- ::ActiveRecord::Base.connection.create_database(config_['database'], config_.merge(extra_configs_))
61
-
62
- # Initial setup of the database: Add schemas from the search path.
63
- # If a superuser is given, we log in as the superuser, but we make sure
64
- # the schemas are owned by the regular user.
65
- ::ActiveRecord::Base.establish_connection(config_.merge('schema_search_path' => 'public', 'username' => su_username_, 'password' => su_password_))
66
- conn_ = ::ActiveRecord::Base.connection
67
- search_path_ = config_["schema_search_path"].to_s.strip
68
- search_path_ = search_path_.split(",").map{ |sp_| sp_.strip }
69
- auth_ = has_su_ ? " AUTHORIZATION #{username_}" : ''
70
- search_path_.each do |schema_|
71
- conn_.execute("CREATE SCHEMA #{schema_}#{auth_}") unless schema_.downcase == 'public'
72
- end
73
-
74
- # Define the postgis stuff, if the script_dir is provided.
75
- # Note: a superuser is required to run the postgis definitions.
76
- # If a separate superuser is provided, we need to grant privileges on
77
- # the postgis definitions over to the regular user afterwards.
78
- # The schema for the postgis definitions is chosen as follows:
79
- # If "postgis" is present in the search path, use it.
80
- # Otherwise, use the last schema in the search path.
81
- # If no search path is given, use "public".
82
- if (script_dir_ = config_['script_dir'])
83
- postgis_schema_ = search_path_.include?('postgis') ? 'postgis' : (search_path_.last || 'public')
84
- conn_.execute("SET search_path TO #{postgis_schema_}")
85
- conn_.execute(::File.read(::File.expand_path('postgis.sql', script_dir_)))
86
- conn_.execute(::File.read(::File.expand_path('spatial_ref_sys.sql', script_dir_)))
87
- if has_su_
88
- conn_.execute("GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA #{postgis_schema_} TO #{username_}")
89
- conn_.execute("GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA #{postgis_schema_} TO #{username_}")
90
- end
91
- end
92
-
93
- # Done
94
- ::ActiveRecord::Base.establish_connection(config_)
95
- rescue ::Exception => e_
96
- $stderr.puts(e_, *(e_.backtrace))
97
- $stderr.puts("Couldn't create database for #{config_.inspect}")
98
- end
99
- else
100
- create_database_without_postgis(config_)
101
- end
102
- end
103
-
104
-
105
- def drop_database(config_)
106
- if config_['adapter'] == 'postgis'
107
- ::ActiveRecord::Base.establish_connection(config_.merge('database' => 'postgres', 'schema_search_path' => 'public', 'username' => config_['su_username'] || config_['username'], 'password' => config_['su_password'] || config_['password']))
108
- ::ActiveRecord::Base.connection.drop_database(config_['database'])
109
- else
110
- drop_database_without_postgis(config_)
111
- end
112
- end
113
-
114
-
115
- ::RGeo::ActiveRecord::TaskHacker.modify('db:charset', nil, 'postgis') do |config_|
116
- ::ActiveRecord::Base.establish_connection(config_)
117
- puts(::ActiveRecord::Base.connection.encoding)
118
- end
119
-
120
-
121
- ::RGeo::ActiveRecord::TaskHacker.modify('db:structure:dump', nil, 'postgis') do |config_|
122
- ::ENV['PGHOST'] = config_["host"] if config_["host"]
123
- ::ENV['PGPORT'] = config_["port"].to_s if config_["port"]
124
- ::ENV['PGPASSWORD'] = config_["password"].to_s if config_["password"]
125
- search_path_ = config_["schema_search_path"].to_s.strip
126
- search_path_ = search_path_.split(",").map{ |sp_| sp_.strip }
127
- search_path_.delete('postgis')
128
- search_path_ = ['public'] if search_path_.length == 0
129
- search_path_ = search_path_.map{ |sp_| "--schema=#{sp_}" }.join(" ")
130
- `pg_dump -i -U "#{config_["username"]}" -s -x -O -f db/#{::Rails.env}_structure.sql #{search_path_} #{config_["database"]}`
131
- raise "Error dumping database" if $?.exitstatus == 1
132
- end
133
-
134
-
135
- ::RGeo::ActiveRecord::TaskHacker.modify('db:test:clone_structure', 'test', 'postgis') do |config_|
136
- ::ENV['PGHOST'] = config_["host"] if config_["host"]
137
- ::ENV['PGPORT'] = config_["port"].to_s if config_["port"]
138
- ::ENV['PGPASSWORD'] = config_["password"].to_s if config_["password"]
139
- `psql -U "#{config_["username"]}" -f #{::Rails.root}/db/#{::Rails.env}_structure.sql #{config_["database"]}`
140
- end
141
-
142
-
143
- ::RGeo::ActiveRecord::TaskHacker.modify('db:test:purge', 'test', 'postgis') do |config_|
144
- ::ActiveRecord::Base.clear_active_connections!
145
- drop_database(config_)
146
- create_database(config_)
147
- end