activerecord-spatialite-adapter 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 0.3.3 / 2011-04-12
2
+
3
+ * The .gemspec was missing the databases.rake file. Fixed.
4
+
1
5
  === 0.3.2 / 2011-04-11
2
6
 
3
7
  * A .gemspec file is now available for gem building and bundler git integration.
data/Version CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
@@ -0,0 +1,101 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # Rakefile changes for SpatiaLite 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_spatialite, :create_database
42
+ alias_method :drop_database_without_spatialite, :drop_database
43
+ end
44
+
45
+
46
+ def create_database(config_)
47
+ if config_['adapter'] == 'spatialite'
48
+ if ::File.exist?(config_['database'])
49
+ $stderr.puts "#{config_['database']} already exists"
50
+ else
51
+ begin
52
+ # Create the SQLite database
53
+ ::ActiveRecord::Base.establish_connection(config_)
54
+ conn_ = ::ActiveRecord::Base.connection
55
+ conn_.execute('SELECT InitSpatialMetaData()')
56
+ rescue ::Exception => e_
57
+ $stderr.puts e_, *(e_.backtrace)
58
+ $stderr.puts "Couldn't create database for #{config_.inspect}"
59
+ end
60
+ end
61
+ else
62
+ create_database_without_spatialite(config_)
63
+ end
64
+ end
65
+
66
+
67
+ def drop_database(config_)
68
+ if config_['adapter'] == 'spatialite'
69
+ require 'pathname'
70
+ path_ = ::Pathname.new(config_['database'])
71
+ file_ = path_.absolute? ? path_.to_s : ::File.join(::Rails.root, path_)
72
+ ::FileUtils.rm(file_)
73
+ else
74
+ drop_database_without_spatialite(config_)
75
+ end
76
+ end
77
+
78
+
79
+ ::RGeo::ActiveRecord::TaskHacker.modify('db:charset', nil, 'spatialite') do |config_|
80
+ ::ActiveRecord::Base.establish_connection(config_)
81
+ puts(::ActiveRecord::Base.connection.encoding)
82
+ end
83
+
84
+
85
+ ::RGeo::ActiveRecord::TaskHacker.modify('db:structure:dump', nil, 'spatialite') do |config_|
86
+ dbfile_ = config_["database"] || config_["dbfile"]
87
+ `sqlite3 #{dbfile_} .schema > db/#{::Rails.env}_structure.sql`
88
+ end
89
+
90
+
91
+ ::RGeo::ActiveRecord::TaskHacker.modify('db:test:clone_structure', 'test', 'spatialite') do |config_|
92
+ dbfile_ = config_["database"] || config_["dbfile"]
93
+ `sqlite3 #{dbfile_} < #{::Rails.root}/db/#{::Rails.env}_structure.sql`
94
+ end
95
+
96
+
97
+ ::RGeo::ActiveRecord::TaskHacker.modify('db:test:purge', 'test', 'spatialite') do |config_|
98
+ dbfile_ = config_["database"] || config_["dbfile"]
99
+ ::File.delete(dbfile_) if ::File.exist?(dbfile_)
100
+ create_database(config_)
101
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: activerecord-spatialite-adapter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.2
5
+ version: 0.3.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Daniel Azuma
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-11 00:00:00 Z
13
+ date: 2011-04-13 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rgeo-activerecord
@@ -53,6 +53,7 @@ files:
53
53
  - lib/active_record/connection_adapters/spatialite_adapter/version.rb
54
54
  - lib/active_record/connection_adapters/spatialite_adapter.rb
55
55
  - lib/rgeo/active_record/spatialite_adapter/railtie.rb
56
+ - lib/active_record/connection_adapters/spatialite_adapter/databases.rake
56
57
  - test/tc_basic.rb
57
58
  - test/tc_spatial_queries.rb
58
59
  - History.rdoc