nofxx-postgis_adapter 0.3.9 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ .DS_Store
2
+ doc/*
3
+ rdoc/*
4
+ coverage/*
5
+ spec/debug.log
6
+ pkg/*
7
+ *flymake.rb
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Spatial Adapter Copyright (c) 2006 Guilhem Vellut <guilhem.vellut+georuby@gmail.com>
2
+ PostGis Adapter Functions (c) 2008 Marcos Piccinini <nofxx>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -11,6 +11,7 @@ begin
11
11
  gem.homepage = "http://github.com/nofxx/postgis_adapter"
12
12
  gem.authors = ["Marcos Augusto"]
13
13
  gem.rubyforge_project = "postgis_adapter"
14
+ gem.add_dependency 'geo_ruby'
14
15
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
16
  end
16
17
  rescue LoadError
@@ -28,22 +29,15 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
28
29
  spec.pattern = 'spec/**/*_spec.rb'
29
30
  spec.rcov = true
30
31
  end
31
-
32
-
33
32
  task :default => :spec
34
33
 
35
34
  require 'rake/rdoctask'
36
35
  Rake::RDocTask.new do |rdoc|
37
- if File.exist?('VERSION.yml')
38
- config = YAML.load(File.read('VERSION.yml'))
39
- version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
40
- else
41
- version = ""
42
- end
36
+ config = YAML.load(File.read('VERSION.yml'))
37
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
43
38
 
44
39
  rdoc.rdoc_dir = 'rdoc'
45
40
  rdoc.title = "postgis_adapter #{version}"
46
41
  rdoc.rdoc_files.include('README*')
47
42
  rdoc.rdoc_files.include('lib/**/*.rb')
48
43
  end
49
-
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 3
4
- :patch: 9
3
+ :minor: 5
4
+ :patch: 0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/rails/init"
data/install.rb ADDED
File without changes
@@ -29,7 +29,7 @@ module PostgisFunctions
29
29
  private
30
30
 
31
31
  def get_column_name
32
- @geo_column ||= postgis_geoms[:columns]
32
+ @geo_column ||= postgis_geoms[:columns][0]
33
33
  end
34
34
 
35
35
  #
@@ -0,0 +1,82 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{postgis_adapter}
5
+ s.version = "0.5.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Marcos Augusto"]
9
+ s.date = %q{2009-05-20}
10
+ s.description = %q{Execute PostGIS functions on Active Record}
11
+ s.email = %q{x@nofxx.com}
12
+ s.extra_rdoc_files = [
13
+ "README.rdoc"
14
+ ]
15
+ s.files = [
16
+ ".gitignore",
17
+ "History.txt",
18
+ "MIT-LICENSE",
19
+ "Manifest.txt",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "VERSION.yml",
23
+ "init.rb",
24
+ "install.rb",
25
+ "lib/postgis_adapter.rb",
26
+ "lib/postgis_adapter/acts_as_geom.rb",
27
+ "lib/postgis_adapter/common_spatial_adapter.rb",
28
+ "lib/postgis_functions.rb",
29
+ "lib/postgis_functions/bbox.rb",
30
+ "lib/postgis_functions/class.rb",
31
+ "lib/postgis_functions/common.rb",
32
+ "postgis_adapter.gemspec",
33
+ "rails/init.rb",
34
+ "script/console",
35
+ "script/destroy",
36
+ "script/generate",
37
+ "spec/db/database_postgis.yml",
38
+ "spec/db/models_postgis.rb",
39
+ "spec/db/schema_postgis.rb",
40
+ "spec/postgis_adapter/acts_as_geom_spec.rb",
41
+ "spec/postgis_adapter/common_spatial_adapter_spec.rb",
42
+ "spec/postgis_adapter_spec.rb",
43
+ "spec/postgis_functions/bbox_spec.rb",
44
+ "spec/postgis_functions/class_spec.rb",
45
+ "spec/postgis_functions/common_spec.rb",
46
+ "spec/postgis_functions_spec.rb",
47
+ "spec/spec.opts",
48
+ "spec/spec_helper.rb",
49
+ "uninstall.rb"
50
+ ]
51
+ s.homepage = %q{http://github.com/nofxx/postgis_adapter}
52
+ s.rdoc_options = ["--charset=UTF-8"]
53
+ s.require_paths = ["lib"]
54
+ s.rubyforge_project = %q{postgis_adapter}
55
+ s.rubygems_version = %q{1.3.3}
56
+ s.summary = %q{PostGIS Adapter for Active Record}
57
+ s.test_files = [
58
+ "spec/postgis_functions_spec.rb",
59
+ "spec/postgis_functions/class_spec.rb",
60
+ "spec/postgis_functions/bbox_spec.rb",
61
+ "spec/postgis_functions/common_spec.rb",
62
+ "spec/db/models_postgis.rb",
63
+ "spec/db/schema_postgis.rb",
64
+ "spec/postgis_adapter_spec.rb",
65
+ "spec/postgis_adapter/common_spatial_adapter_spec.rb",
66
+ "spec/postgis_adapter/acts_as_geom_spec.rb",
67
+ "spec/spec_helper.rb"
68
+ ]
69
+
70
+ if s.respond_to? :specification_version then
71
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
72
+ s.specification_version = 3
73
+
74
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
75
+ s.add_runtime_dependency(%q<geo_ruby>, [">= 0"])
76
+ else
77
+ s.add_dependency(%q<geo_ruby>, [">= 0"])
78
+ end
79
+ else
80
+ s.add_dependency(%q<geo_ruby>, [">= 0"])
81
+ end
82
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/postgis_adapter.rb'}"
9
+ puts "Loading postgis_adapter gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,27 +1,26 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
- describe "ActsAsGeom" do
3
+ class DiffColumn < ActiveRecord::Base
4
+ acts_as_geom :ponto
5
+ end
4
6
 
5
- before(:each) do
6
- class DiffColumn < ActiveRecord::Base
7
- acts_as_geom :ponto
8
- end
7
+ class NotInDb < ActiveRecord::Base
8
+ acts_as_geom :geom
9
+ end
9
10
 
10
- class NotInDb < ActiveRecord::Base
11
- acts_as_geom :geom
12
- end
13
- end
11
+ describe "ActsAsGeom" do
14
12
 
15
13
  it "should get the geom type" do
14
+ p City.connection.columns("cities").select { |c| c.name == "geom" }[0]
16
15
  City.get_geom_type(:geom).should eql(:polygon)
17
16
  end
18
17
 
19
- it "should not interfere with migrations" do
20
- NotInDb.get_geom_type(:geom).should be_nil
18
+ it "should get the geom type" do
19
+ Position.get_geom_type(:geom).should eql(:point)
21
20
  end
22
21
 
23
- it "should set the geom constant" do
24
- # City::GEOMS[City].should eql([:geom])
22
+ it "should not interfere with migrations" do
23
+ NotInDb.get_geom_type(:geom).should be_nil
25
24
  end
26
25
 
27
26
  it "should query a diff column name" do
@@ -127,17 +127,17 @@ describe "PostgisAdapter" do
127
127
  end
128
128
 
129
129
  describe "Find" do
130
- before(:all) do
131
- ActiveRecord::Schema.define() do
132
- create_table "parks", :force => true do |t|
133
- t.column "data" , :string, :limit => 100
134
- t.column "value", :integer
135
- t.column "geom", :point,:null=>false,:srid=>4326
136
- end
137
- add_index "parks","geom",:spatial=>true,:name => "example_spatial_index"
138
- end
139
- class Park < ActiveRecord::Base
130
+
131
+ ActiveRecord::Schema.define() do
132
+ create_table "parks", :force => true do |t|
133
+ t.column "data" , :string, :limit => 100
134
+ t.column "value", :integer
135
+ t.column "geom", :point,:null=>false,:srid=>4326
140
136
  end
137
+ add_index "parks","geom",:spatial=>true,:name => "example_spatial_index"
138
+ end
139
+
140
+ class Park < ActiveRecord::Base
141
141
  end
142
142
 
143
143
  it "should create some points" do
@@ -1,6 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper.rb'
2
2
 
3
- describe "Class Functions" do
3
+ describe "ClassMethods" do
4
4
  before(:all) do
5
5
  @c1 ||= City.create!(:data => "CityClass", :geom => Polygon.from_coordinates([[[12,45],[45,41],[4,1],[12,45]],[[2,5],[5,1],[14,1],[2,5]]],4326))
6
6
  @s1 ||= Street.create!(:data => "StreetClass", :geom => LineString.from_coordinates([[1,1],[99,88]],4326))
@@ -10,15 +10,15 @@ describe "Class Functions" do
10
10
  end
11
11
 
12
12
  it "should find the closest other point" do
13
- Position.close_to(@p1.geom, :srid => 4326)[0].data.should == @p1.data
13
+ Position.close_to(Point.from_x_y(99,99,4326), :srid => 4326)[0].data.should == @p1.data
14
14
  end
15
15
 
16
16
  it "should find the closest other point and limit" do
17
- Position.close_to(@p1.geom, :limit => 10).should have(10).positions
17
+ Position.close_to(Point.from_x_y(99,99,4326), :limit => 2).should have(2).positions
18
18
  end
19
19
 
20
20
  it "should find the closest other point" do
21
- Position.closest_to(@p1.geom).data.should == @p1.data
21
+ Position.closest_to(Point.from_x_y(99,99,4326)).data.should == @p1.data
22
22
  end
23
23
 
24
24
  it "should sort by size" do
@@ -35,11 +35,11 @@ describe "Class Functions" do
35
35
  end
36
36
 
37
37
  it "should sort by linestring length" do
38
- Street.by_length(:limit => 10).should have(10).streets
38
+ Street.by_length(:limit => 2).should have(2).streets
39
39
  end
40
40
 
41
41
  it "should find the longest" do
42
- Street.longest.should be_instance_of(Street)
42
+ Street.longest.should == @s1
43
43
  end
44
44
 
45
45
  it "should find all dwithin one" do
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rubygems'
2
2
  require 'spec'
3
- require 'postgres'
3
+ require 'pg'
4
4
  require 'activerecord'
5
5
  require 'rspec_spinner'
6
6
 
@@ -8,7 +8,7 @@ gem 'activerecord', "=2.3.2"
8
8
 
9
9
  $:.unshift((File.join(File.dirname(__FILE__), '..', 'lib')))
10
10
  require 'postgis_adapter'
11
- GeoRuby::Base.srid = -1
11
+ GeoRuby::SimpleFeatures.srid = -1
12
12
  config = YAML.load_file(File.dirname(__FILE__) + '/db/database_postgis.yml')
13
13
  # ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
14
14
  ActiveRecord::Base.establish_connection(config)
data/uninstall.rb ADDED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nofxx-postgis_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Augusto
@@ -9,10 +9,19 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-02 00:00:00 -07:00
12
+ date: 2009-05-20 00:00:00 -07:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: geo_ruby
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
16
25
  description: Execute PostGIS functions on Active Record
17
26
  email: x@nofxx.com
18
27
  executables: []
@@ -22,11 +31,15 @@ extensions: []
22
31
  extra_rdoc_files:
23
32
  - README.rdoc
24
33
  files:
34
+ - .gitignore
25
35
  - History.txt
36
+ - MIT-LICENSE
26
37
  - Manifest.txt
27
38
  - README.rdoc
28
39
  - Rakefile
29
40
  - VERSION.yml
41
+ - init.rb
42
+ - install.rb
30
43
  - lib/postgis_adapter.rb
31
44
  - lib/postgis_adapter/acts_as_geom.rb
32
45
  - lib/postgis_adapter/common_spatial_adapter.rb
@@ -34,7 +47,11 @@ files:
34
47
  - lib/postgis_functions/bbox.rb
35
48
  - lib/postgis_functions/class.rb
36
49
  - lib/postgis_functions/common.rb
50
+ - postgis_adapter.gemspec
37
51
  - rails/init.rb
52
+ - script/console
53
+ - script/destroy
54
+ - script/generate
38
55
  - spec/db/database_postgis.yml
39
56
  - spec/db/models_postgis.rb
40
57
  - spec/db/schema_postgis.rb
@@ -47,7 +64,8 @@ files:
47
64
  - spec/postgis_functions_spec.rb
48
65
  - spec/spec.opts
49
66
  - spec/spec_helper.rb
50
- has_rdoc: true
67
+ - uninstall.rb
68
+ has_rdoc: false
51
69
  homepage: http://github.com/nofxx/postgis_adapter
52
70
  post_install_message:
53
71
  rdoc_options:
@@ -74,13 +92,13 @@ signing_key:
74
92
  specification_version: 3
75
93
  summary: PostGIS Adapter for Active Record
76
94
  test_files:
77
- - spec/db/models_postgis.rb
78
- - spec/db/schema_postgis.rb
95
+ - spec/postgis_functions_spec.rb
79
96
  - spec/postgis_functions/class_spec.rb
80
97
  - spec/postgis_functions/bbox_spec.rb
81
98
  - spec/postgis_functions/common_spec.rb
82
- - spec/postgis_functions_spec.rb
99
+ - spec/db/models_postgis.rb
100
+ - spec/db/schema_postgis.rb
83
101
  - spec/postgis_adapter_spec.rb
84
- - spec/postgis_adapter/acts_as_geom_spec.rb
85
102
  - spec/postgis_adapter/common_spatial_adapter_spec.rb
103
+ - spec/postgis_adapter/acts_as_geom_spec.rb
86
104
  - spec/spec_helper.rb