whereabouts 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +30 -7
- data/VERSION +1 -1
- data/lib/whereabouts_methods.rb +0 -43
- data/whereabouts.gemspec +2 -2
- metadata +3 -3
data/README.markdown
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Whereabouts
|
2
|
-
===========
|
1
|
+
# Whereabouts
|
3
2
|
|
4
3
|
Whereabouts is a Rails plugin that generates a polymorphic address model
|
5
4
|
to be associated to ActiveRecord models.
|
@@ -16,11 +15,15 @@ Run migrations
|
|
16
15
|
|
17
16
|
rake db:migrate
|
18
17
|
|
18
|
+
If you have the [Ruby Geocoder](http://www.rubygeocoder.com) specified in
|
19
|
+
your project's Gemfile, adding {:geocode => true} to the has_whereabouts
|
20
|
+
definition will automatically geocode and populate the latitude and
|
21
|
+
longitude fields for the record.
|
19
22
|
|
20
|
-
Examples
|
21
|
-
|
23
|
+
# Examples
|
24
|
+
|
25
|
+
## Basic use:
|
22
26
|
|
23
|
-
# Basic use:
|
24
27
|
class Thing < ActiveRecord::Base
|
25
28
|
has_whereabouts
|
26
29
|
end
|
@@ -28,7 +31,8 @@ Examples
|
|
28
31
|
t = Thing.new
|
29
32
|
t.build_address
|
30
33
|
|
31
|
-
|
34
|
+
## Multiple addresses on same model:
|
35
|
+
|
32
36
|
class Foo < ActiveRecord::Base
|
33
37
|
has_whereabouts :shipping_address
|
34
38
|
has_whereabouts :mailing_address
|
@@ -38,6 +42,26 @@ Examples
|
|
38
42
|
f.build_shipping_address
|
39
43
|
f.build_mailing_address
|
40
44
|
|
45
|
+
## Validating Presence of Attributes
|
46
|
+
|
47
|
+
# Add :validate => [] to the option
|
48
|
+
# hash on the call to has_whereabouts.
|
49
|
+
# Options available in the array are
|
50
|
+
# :line1, :line2, :city, :state, :zip
|
51
|
+
class Thing < ActiveRecord::Base
|
52
|
+
has_whereabouts :location, {:validate => [:city, :state, :zip]}
|
53
|
+
end
|
54
|
+
|
55
|
+
## Automatic Geocoding
|
56
|
+
|
57
|
+
# Must have Ruby Geocoder installed
|
58
|
+
# and configured. Will populate the
|
59
|
+
# latitude and longitude attributes
|
60
|
+
# on the Address
|
61
|
+
class Thing < ActiveRecord::Base
|
62
|
+
has_whereabouts :location, {:geocode => true}
|
63
|
+
end
|
64
|
+
|
41
65
|
Contributing to whereabouts
|
42
66
|
=========
|
43
67
|
|
@@ -50,5 +74,4 @@ Contributing to whereabouts
|
|
50
74
|
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
51
75
|
|
52
76
|
Copyright (c) 2011 [Nicholas Fine](http://ndfine.com), released under the MIT license
|
53
|
-
v0.5.1
|
54
77
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
data/lib/whereabouts_methods.rb
CHANGED
@@ -1,46 +1,4 @@
|
|
1
|
-
# **Whereabouts** is a Rails plugin that generates a polymorphic, inheritable
|
2
|
-
# Address model. Install it as a Rails plugin (Rails 3.x+ required)
|
3
|
-
#
|
4
|
-
# rails plugin install http://github.com/yrgoldteeth/whereabouts.git
|
5
|
-
#
|
6
|
-
# The most simple use case creates a has_one relationship with
|
7
|
-
# a generic Address:
|
8
|
-
#
|
9
|
-
# class Foo < ActiveRecord::Base
|
10
|
-
# has_whereabouts
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# f = Foo.new
|
14
|
-
# f.build_address
|
15
|
-
#
|
16
|
-
# Also, a model can have any number of different inherited types of Addresses,
|
17
|
-
# i.e. shipping address and mailing address
|
18
|
-
#
|
19
|
-
# class Foo < ActiveRecord::Base
|
20
|
-
# has_whereabouts :shipping
|
21
|
-
# has_whereabouts :mailing
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# f = Foo.new
|
25
|
-
# f.build_shipping
|
26
|
-
# f.build_mailing
|
27
|
-
#
|
28
|
-
# If you have the [Ruby Geocoder](http://www.rubygeocoder.com) specified in
|
29
|
-
# your project's Gemfile, adding {:geocode => true} to the has_whereabouts
|
30
|
-
# definition will automatically geocode and populate the latitude and
|
31
|
-
# longitude fields for the record.
|
32
|
-
#
|
33
|
-
# class Foo < ActiveRecord::Base
|
34
|
-
# has_whereabouts :shipping, {:geocode => true}
|
35
|
-
# end
|
36
|
-
#
|
37
|
-
# You can see the source on [github](https://github.com/yrgoldteeth/whereabouts), and
|
38
|
-
# this page was generated with the wonderful
|
39
|
-
# [rocco](http://rtomayko.github.com/rocco/) documentation generator.
|
40
|
-
|
41
|
-
# Hey, that's [me](http://ndfine.com)
|
42
1
|
module Yrgoldteeth
|
43
|
-
# **Whereabouts**
|
44
2
|
module Has
|
45
3
|
module Whereabouts
|
46
4
|
|
@@ -49,7 +7,6 @@ module Yrgoldteeth
|
|
49
7
|
base.extend ClassMethods
|
50
8
|
end
|
51
9
|
|
52
|
-
# **ClassMethods**
|
53
10
|
module ClassMethods
|
54
11
|
# Accepts a symbol that will define the inherited
|
55
12
|
# type of Address. Defaults to the parent class.
|
data/whereabouts.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{whereabouts}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nicholas Fine"]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-23}
|
13
13
|
s.description = %q{Rails plugin for adding associated addresses to Active Record Models}
|
14
14
|
s.email = %q{nicholas.fine@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: whereabouts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.5.
|
5
|
+
version: 0.5.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Nicholas Fine
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-23 00:00:00 -05:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -118,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
118
|
requirements:
|
119
119
|
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
|
-
hash:
|
121
|
+
hash: -40591267
|
122
122
|
segments:
|
123
123
|
- 0
|
124
124
|
version: "0"
|