has_phone_numbers 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README +20 -9
- data/Rakefile +1 -1
- data/app/models/phone_number.rb +5 -5
- data/lib/has_phone_numbers.rb +4 -4
- data/test/app_root/config/environment.rb +5 -10
- data/test/{app_root/test/fixtures → fixtures}/people.yml +0 -0
- data/test/{app_root/test/fixtures → fixtures}/phone_numbers.yml +0 -0
- metadata +6 -7
data/CHANGELOG
CHANGED
data/README
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= has_phone_numbers
|
2
2
|
|
3
|
-
has_phone_numbers adds a base skeleton for handling phone numbers.
|
3
|
+
+has_phone_numbers+ adds a base skeleton for handling phone numbers.
|
4
4
|
|
5
5
|
== Resources
|
6
6
|
|
@@ -14,7 +14,7 @@ Wiki
|
|
14
14
|
|
15
15
|
Announcement
|
16
16
|
|
17
|
-
* http://www.pluginaweek.org
|
17
|
+
* http://www.pluginaweek.org
|
18
18
|
|
19
19
|
Source
|
20
20
|
|
@@ -31,9 +31,11 @@ standardized across multiple applications. Phone numbers are minimialistic in
|
|
31
31
|
terms of the type of data required and follows the standard U.S. format.
|
32
32
|
Support for international formats may be added in the future.
|
33
33
|
|
34
|
+
== Usage
|
35
|
+
|
34
36
|
=== Running migrations
|
35
37
|
|
36
|
-
To migrate the tables required for
|
38
|
+
To migrate the tables required for this plugin, you can either run the
|
37
39
|
migration from the command line like so:
|
38
40
|
|
39
41
|
rake db:migrate:plugins PLUGIN=has_phone_numbers
|
@@ -41,15 +43,24 @@ migration from the command line like so:
|
|
41
43
|
or (more ideally) generate a migration file that will integrate into your main
|
42
44
|
application's migration path:
|
43
45
|
|
44
|
-
ruby script/generate plugin_migration
|
46
|
+
ruby script/generate plugin_migration has_phone_numbers
|
45
47
|
|
46
48
|
== Testing
|
47
49
|
|
48
|
-
|
49
|
-
*
|
50
|
-
*
|
51
|
-
* appable_plugins - http://wiki.pluginaweek.org/Appable_plugins
|
50
|
+
Before you can run any tests, the following gems must be installed:
|
51
|
+
* plugin_test_helper[http://wiki.pluginaweek.org/Plugin_test_helper]
|
52
|
+
* dry_validity_assertions[http://wiki.pluginaweek.org/Dry_validity_assertions]
|
52
53
|
|
53
54
|
== Dependencies
|
54
55
|
|
55
|
-
This plugin
|
56
|
+
This plugin is a plugin+. That means that it contains a slice of an
|
57
|
+
application, such as models and migrations. To test or use a plugin+, you
|
58
|
+
must have the following plugins/gems installed:
|
59
|
+
* plugin_dependencies[http://wiki.pluginaweek.org/Plugin_dependencies]
|
60
|
+
* loaded_plugins[http://wiki.pluginaweek.org/Loaded_plugins]
|
61
|
+
* appable_plugins[http://wiki.pluginaweek.org/Appable_plugins]
|
62
|
+
* plugin_migrations[http://wiki.pluginaweek.org/Plugin_migrations]
|
63
|
+
|
64
|
+
Instead of installing each individual plugin+ feature, you can install them all
|
65
|
+
at once using the plugins+[http://wiki.pluginaweek.org/Plugins_plus] meta package,
|
66
|
+
which contains all additional features.
|
data/Rakefile
CHANGED
data/app/models/phone_number.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# Represents a phone number
|
1
|
+
# Represents a phone number (most likely in the United States)
|
2
2
|
class PhoneNumber < ActiveRecord::Base
|
3
3
|
belongs_to :phoneable,
|
4
4
|
:polymorphic => true
|
5
5
|
|
6
|
-
validates_presence_of
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
validates_presence_of :phoneable_id,
|
7
|
+
:phoneable_type,
|
8
|
+
:country_code,
|
9
|
+
:number
|
10
10
|
|
11
11
|
with_options(:allow_nil => true) do |klass|
|
12
12
|
klass.validates_numericality_of :country_code,
|
data/lib/has_phone_numbers.rb
CHANGED
@@ -9,8 +9,8 @@ module PluginAWeek #:nodoc:
|
|
9
9
|
|
10
10
|
module MacroMethods
|
11
11
|
# Creates a new association for having a single phone number. This
|
12
|
-
# takes the same parameters as
|
13
|
-
#
|
12
|
+
# takes the same parameters as +has_one+. By default, the following
|
13
|
+
# associations are the same:
|
14
14
|
#
|
15
15
|
# class Person < ActiveRecord::Base
|
16
16
|
# has_phone_number
|
@@ -29,8 +29,8 @@ module PluginAWeek #:nodoc:
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# Creates a new association for having a multiple phone numbers. This
|
32
|
-
# takes the same parameters as
|
33
|
-
#
|
32
|
+
# takes the same parameters as +has_many+. By default, the following
|
33
|
+
# associations are the same:
|
34
34
|
#
|
35
35
|
# class Person < ActiveRecord::Base
|
36
36
|
# has_phone_numbers
|
@@ -3,16 +3,10 @@ require 'config/boot'
|
|
3
3
|
$:.unshift("#{RAILS_ROOT}/../../../../../rails/plugin_dependencies/lib")
|
4
4
|
begin
|
5
5
|
require 'plugin_dependencies'
|
6
|
-
rescue
|
6
|
+
rescue Exception => e
|
7
7
|
end
|
8
8
|
|
9
9
|
Rails::Initializer.run do |config|
|
10
|
-
config.log_level = :debug
|
11
|
-
config.cache_classes = false
|
12
|
-
config.whiny_nils = true
|
13
|
-
config.breakpoint_server = true
|
14
|
-
config.load_paths << "#{RAILS_ROOT}/../../lib"
|
15
|
-
|
16
10
|
config.plugin_paths.concat([
|
17
11
|
"#{RAILS_ROOT}/../../..",
|
18
12
|
"#{RAILS_ROOT}/../../../../migrations",
|
@@ -20,11 +14,12 @@ Rails::Initializer.run do |config|
|
|
20
14
|
"#{RAILS_ROOT}/../../../../../test"
|
21
15
|
])
|
22
16
|
config.plugins = [
|
23
|
-
|
17
|
+
'loaded_plugins',
|
24
18
|
'appable_plugins',
|
25
19
|
'plugin_migrations',
|
20
|
+
File.basename(File.expand_path("#{RAILS_ROOT}/../..")),
|
26
21
|
'dry_validity_assertions'
|
27
22
|
]
|
23
|
+
config.cache_classes = false
|
24
|
+
config.whiny_nils = true
|
28
25
|
end
|
29
|
-
|
30
|
-
Dependencies.log_activity = true
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: has_phone_numbers
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.0.2
|
7
|
+
date: 2007-09-26 00:00:00 -04:00
|
8
8
|
summary: Adds a base skeleton for handling phone numbers.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -35,15 +35,14 @@ files:
|
|
35
35
|
- db/migrate/001_create_phone_numbers.rb
|
36
36
|
- lib/has_phone_numbers.rb
|
37
37
|
- test/test_helper.rb
|
38
|
+
- test/fixtures
|
38
39
|
- test/app_root
|
39
40
|
- test/unit
|
40
|
-
- test/
|
41
|
+
- test/fixtures/phone_numbers.yml
|
42
|
+
- test/fixtures/people.yml
|
41
43
|
- test/app_root/config
|
42
44
|
- test/app_root/app
|
43
45
|
- test/app_root/db
|
44
|
-
- test/app_root/test/fixtures
|
45
|
-
- test/app_root/test/fixtures/phone_numbers.yml
|
46
|
-
- test/app_root/test/fixtures/people.yml
|
47
46
|
- test/app_root/config/environment.rb
|
48
47
|
- test/app_root/app/models
|
49
48
|
- test/app_root/app/models/person.rb
|