dm-geokit 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
- dm-geokit
2
- =========
1
+ # dm-geokit
3
2
 
4
3
  A mixin for Datamapper models that enables geographic functionality.
5
4
 
@@ -7,17 +6,16 @@ A mixin for Datamapper models that enables geographic functionality.
7
6
  * Sort by distance easily: Location.all(:address.near => {:origin => 'Portland, OR', :distance => 5.mi}, :order => [:address_distance.desc])
8
7
  * Ability to specify multiple fields that are geocodable (mostly)
9
8
 
10
- Usage
11
- =====
9
+ # Usage
12
10
 
13
11
  Basic Class Definition:
14
12
 
15
- class Location
16
- include DataMapper::Resource
17
- include DataMapper::GeoKit
18
- property :id, Serial
19
- has_geographic_location :address
20
- end
13
+ class Location
14
+ include DataMapper::Resource
15
+ include DataMapper::GeoKit
16
+ property :id, Serial
17
+ has_geographic_location :address
18
+ end
21
19
 
22
20
  This will automatically generate fields and methods for use with the DM Object, prefixed with the field name specified.
23
21
  Since the above example used the field :address, the following fields would be generated:
@@ -33,14 +31,14 @@ Since the above example used the field :address, the following fields would be g
33
31
 
34
32
  You can either reference those fields directly, or use the proxy object returned by calling .address on your object:
35
33
 
36
- l = Location.all(:address.near => {:origin => 'Portland, OR', :distance => 5.mi})
34
+ l = Location.all(:address.near => {:origin => 'Portland, OR', :distance => 5.mi})
37
35
 
38
- l.each do |loc|
39
- puts loc.address # .to_s yields string representation of full address, e.g. "12345 My St. Portland, OR USA"
40
- puts loc.address.inspect # the proxy object, GeographicLocation, with matching methods for each property
41
- puts loc.address.street_address # getting the street_address from the proxy object
42
- puts loc.address_street_address # directly access the SQL column
43
- end
36
+ l.each do |loc|
37
+ puts loc.address # .to_s yields string representation of full address, e.g. "12345 My St. Portland, OR USA"
38
+ puts loc.address.inspect # the proxy object, GeographicLocation, with matching methods for each property
39
+ puts loc.address.street_address # getting the street_address from the proxy object
40
+ puts loc.address_street_address # directly access the SQL column
41
+ end
44
42
 
45
43
  The GeographicLocation proxy object is a convenience to allow you to compare and sort results in Ruby.
46
44
 
@@ -48,5 +46,5 @@ Requirements
48
46
  ===========
49
47
 
50
48
  * geokit >= 1.5.0
51
- * dm-core >= 0.10.1
52
- * dm-aggregates >= 0.10.1
49
+ * dm-core >= 1.0.2
50
+ * dm-aggregates >= 1.0.2
@@ -12,7 +12,14 @@ module DataMapper
12
12
  send :include, InstanceMethods
13
13
  send :include, ::GeoKit::Mappable
14
14
 
15
- property name.to_sym, String, :length => 255, :auto_validation => false
15
+ if defined?(DataMapper::Validations)
16
+ # since we return a custom object when this property is called, it breaks
17
+ # when dm-validations is included, so we set auto_validation to false if
18
+ # dm-validations is loaded
19
+ property name.to_sym, String, :length => 255, :auto_validation => false
20
+ else
21
+ property name.to_sym, String, :length => 255
22
+ end
16
23
  property "#{name}_distance".to_sym, Float
17
24
 
18
25
  PROPERTY_NAMES.each do |p|
@@ -23,8 +30,6 @@ module DataMapper
23
30
  end
24
31
  end
25
32
 
26
- DataMapper.auto_upgrade!
27
-
28
33
  if options[:auto_geocode] == true or options[:auto_geocode].nil?
29
34
  define_method :auto_geocode? do
30
35
  true
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  $TESTING=true
2
2
  $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
- %w(dm-geokit dm-migrations dm-is-versioned).each{|l| require l}
3
+ %w(dm-geokit dm-validations dm-migrations dm-is-versioned).each{|l| require l}
4
4
 
5
5
  DataMapper::Logger.new(STDOUT, :debug)
6
6
  DataMapper.setup(:default, "mysql://root:1nt3rfac3@localhost/dm_geokit_test")
metadata CHANGED
@@ -1,13 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-geokit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
4
+ version: 1.1.0
11
5
  platform: ruby
12
6
  authors:
13
7
  - Matt King
@@ -15,39 +9,29 @@ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
11
 
18
- date: 2010-09-23 00:00:00 -07:00
12
+ date: 2011-03-19 00:00:00 -07:00
19
13
  default_executable:
20
14
  dependencies:
21
15
  - !ruby/object:Gem::Dependency
22
16
  name: dm-core
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
26
20
  requirements:
27
- - - "="
21
+ - - ">="
28
22
  - !ruby/object:Gem::Version
29
- hash: 51
30
- segments:
31
- - 0
32
- - 10
33
- - 2
34
- version: 0.10.2
35
- type: :runtime
36
- version_requirements: *id001
23
+ version: 1.0.2
24
+ version:
37
25
  - !ruby/object:Gem::Dependency
38
26
  name: geokit
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
42
30
  requirements:
43
31
  - - ">="
44
32
  - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
33
  version: "0"
49
- type: :runtime
50
- version_requirements: *id002
34
+ version:
51
35
  description: Geographic Property support for DataMapper
52
36
  email: mking@mking.me
53
37
  executables: []
@@ -56,11 +40,11 @@ extensions: []
56
40
 
57
41
  extra_rdoc_files:
58
42
  - LICENSE
59
- - README
43
+ - README.md
60
44
  - TODO
61
45
  files:
62
46
  - LICENSE
63
- - README
47
+ - README.md
64
48
  - Rakefile
65
49
  - TODO
66
50
  - VERSION.yml
@@ -76,8 +60,6 @@ files:
76
60
  - lib/dm-geokit/support/symbol.rb
77
61
  - lib/jeweler/templates/.gitignore
78
62
  - lib/skeleton/api_keys_template
79
- - spec/dm_geokit_spec.rb
80
- - spec/spec_helper.rb
81
63
  has_rdoc: true
82
64
  homepage: http://github.com/mattking17/dm-geokit/tree/master
83
65
  licenses: []
@@ -88,27 +70,21 @@ rdoc_options:
88
70
  require_paths:
89
71
  - lib
90
72
  required_ruby_version: !ruby/object:Gem::Requirement
91
- none: false
92
73
  requirements:
93
74
  - - ">="
94
75
  - !ruby/object:Gem::Version
95
- hash: 3
96
- segments:
97
- - 0
98
76
  version: "0"
77
+ version:
99
78
  required_rubygems_version: !ruby/object:Gem::Requirement
100
- none: false
101
79
  requirements:
102
80
  - - ">="
103
81
  - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
82
  version: "0"
83
+ version:
108
84
  requirements: []
109
85
 
110
86
  rubyforge_project: dm-geokit
111
- rubygems_version: 1.3.7
87
+ rubygems_version: 1.3.5
112
88
  signing_key:
113
89
  specification_version: 2
114
90
  summary: DataMapper plugin for geokit