rails_phone 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +46 -0
  3. data/Rakefile +38 -0
  4. data/lib/rails_phone.rb +3 -0
  5. data/lib/rails_phone/has_phone_number.rb +51 -0
  6. data/lib/rails_phone/version.rb +3 -0
  7. data/test/dummy/README.rdoc +261 -0
  8. data/test/dummy/Rakefile +7 -0
  9. data/test/dummy/app/assets/javascripts/application.js +15 -0
  10. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  11. data/test/dummy/app/controllers/application_controller.rb +3 -0
  12. data/test/dummy/app/helpers/application_helper.rb +2 -0
  13. data/test/dummy/app/models/company.rb +4 -0
  14. data/test/dummy/app/models/outcast.rb +3 -0
  15. data/test/dummy/app/models/person.rb +4 -0
  16. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  17. data/test/dummy/config.ru +4 -0
  18. data/test/dummy/config/application.rb +59 -0
  19. data/test/dummy/config/boot.rb +10 -0
  20. data/test/dummy/config/database.yml +25 -0
  21. data/test/dummy/config/environment.rb +5 -0
  22. data/test/dummy/config/environments/development.rb +37 -0
  23. data/test/dummy/config/environments/production.rb +67 -0
  24. data/test/dummy/config/environments/test.rb +37 -0
  25. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  26. data/test/dummy/config/initializers/inflections.rb +15 -0
  27. data/test/dummy/config/initializers/mime_types.rb +5 -0
  28. data/test/dummy/config/initializers/secret_token.rb +7 -0
  29. data/test/dummy/config/initializers/session_store.rb +8 -0
  30. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  31. data/test/dummy/config/locales/en.yml +5 -0
  32. data/test/dummy/config/routes.rb +58 -0
  33. data/test/dummy/db/development.sqlite3 +0 -0
  34. data/test/dummy/db/migrate/20130403194712_create_people.rb +10 -0
  35. data/test/dummy/db/migrate/20130403194728_create_companies.rb +11 -0
  36. data/test/dummy/db/migrate/20130403200930_create_outcasts.rb +10 -0
  37. data/test/dummy/db/schema.rb +38 -0
  38. data/test/dummy/db/test.sqlite3 +0 -0
  39. data/test/dummy/log/development.log +69 -0
  40. data/test/dummy/log/test.log +319 -0
  41. data/test/dummy/public/404.html +26 -0
  42. data/test/dummy/public/422.html +26 -0
  43. data/test/dummy/public/500.html +25 -0
  44. data/test/dummy/public/favicon.ico +0 -0
  45. data/test/dummy/script/rails +6 -0
  46. data/test/dummy/test/fixtures/companies.yml +11 -0
  47. data/test/dummy/test/fixtures/outcasts.yml +9 -0
  48. data/test/dummy/test/fixtures/people.yml +9 -0
  49. data/test/dummy/test/unit/company_test.rb +7 -0
  50. data/test/dummy/test/unit/outcast_test.rb +7 -0
  51. data/test/dummy/test/unit/person_test.rb +7 -0
  52. data/test/rails_phone_test.rb +51 -0
  53. data/test/test_helper.rb +15 -0
  54. metadata +184 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ customer_support_phone: MyString
5
+ phone: MyString
6
+ name: MyString
7
+
8
+ two:
9
+ customer_support_phone: MyString
10
+ phone: MyString
11
+ name: MyString
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ phone: MyString
5
+ name: MyString
6
+
7
+ two:
8
+ phone: MyString
9
+ name: MyString
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ phone: MyString
5
+ name: MyString
6
+
7
+ two:
8
+ phone: MyString
9
+ name: MyString
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class CompanyTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class OutcastTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class PersonTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ class RailsPhoneTest < ActiveSupport::TestCase
4
+ setup do
5
+ @jim = Person.new name: "Jim"
6
+ @corp = Company.new name: "Acme Entertainment"
7
+ @outcast = Outcast.new name: "Jon Snow", phone: "ABC-123-456"
8
+ end
9
+
10
+ test "does not affect classes without has_phone_number" do
11
+ assert @outcast.valid?
12
+ end
13
+
14
+ test "custom phone attributes must be valid" do
15
+ @corp.customer_support_phone = "123-123-1233"
16
+ assert @corp.valid?
17
+ @corp.customer_support_phone = "A23-123-1233"
18
+ assert !@corp.valid?
19
+ end
20
+
21
+ test "uses :phone by default" do
22
+ assert_equal [:phone], Person.phone_number_attributes
23
+ end
24
+
25
+ test "accepts phone attributes as arguments" do
26
+ assert_equal [:customer_support_phone, :phone], Company.phone_number_attributes
27
+ end
28
+
29
+ test "unformatted phone is ok" do
30
+ @jim.phone = 1123456789
31
+ assert @jim.valid?, "1123456789 should be valid"
32
+ end
33
+
34
+ test "blank phone is ok" do
35
+ assert @jim.valid?
36
+ end
37
+
38
+ %w{0123456789 012-345-6789 (012)-345-6789}.each do |valid_phone|
39
+ define_method "test_#{valid_phone}" do
40
+ @jim.phone = valid_phone
41
+ assert @jim.valid?, "#{valid_phone} should be valid"
42
+ end
43
+ end
44
+
45
+ %w{123456789 1234 012-A45-6789 (B12)-345-6789}.each do |valid_phone|
46
+ define_method "test_#{valid_phone}" do
47
+ @jim.phone = valid_phone
48
+ assert !@jim.valid?, "#{valid_phone} should be invalid"
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
15
+ end
metadata ADDED
@@ -0,0 +1,184 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_phone
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stephen Pike
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.13
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.13
30
+ - !ruby/object:Gem::Dependency
31
+ name: sqlite3
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: ! 'Handling for phone numbers in rails apps. Make the aggressive
47
+
48
+ assumption that a valid phone number is a 10 digit number. Users can
49
+
50
+ input numbers in any format so long as they contain exactly 10 numeric
51
+
52
+ digits.'
53
+ email:
54
+ - spike@scpike.net
55
+ executables: []
56
+ extensions: []
57
+ extra_rdoc_files: []
58
+ files:
59
+ - lib/rails_phone/has_phone_number.rb
60
+ - lib/rails_phone/version.rb
61
+ - lib/rails_phone.rb
62
+ - MIT-LICENSE
63
+ - Rakefile
64
+ - README.md
65
+ - test/dummy/app/assets/javascripts/application.js
66
+ - test/dummy/app/assets/stylesheets/application.css
67
+ - test/dummy/app/controllers/application_controller.rb
68
+ - test/dummy/app/helpers/application_helper.rb
69
+ - test/dummy/app/models/company.rb
70
+ - test/dummy/app/models/outcast.rb
71
+ - test/dummy/app/models/person.rb
72
+ - test/dummy/app/views/layouts/application.html.erb
73
+ - test/dummy/config/application.rb
74
+ - test/dummy/config/boot.rb
75
+ - test/dummy/config/database.yml
76
+ - test/dummy/config/environment.rb
77
+ - test/dummy/config/environments/development.rb
78
+ - test/dummy/config/environments/production.rb
79
+ - test/dummy/config/environments/test.rb
80
+ - test/dummy/config/initializers/backtrace_silencers.rb
81
+ - test/dummy/config/initializers/inflections.rb
82
+ - test/dummy/config/initializers/mime_types.rb
83
+ - test/dummy/config/initializers/secret_token.rb
84
+ - test/dummy/config/initializers/session_store.rb
85
+ - test/dummy/config/initializers/wrap_parameters.rb
86
+ - test/dummy/config/locales/en.yml
87
+ - test/dummy/config/routes.rb
88
+ - test/dummy/config.ru
89
+ - test/dummy/db/development.sqlite3
90
+ - test/dummy/db/migrate/20130403194712_create_people.rb
91
+ - test/dummy/db/migrate/20130403194728_create_companies.rb
92
+ - test/dummy/db/migrate/20130403200930_create_outcasts.rb
93
+ - test/dummy/db/schema.rb
94
+ - test/dummy/db/test.sqlite3
95
+ - test/dummy/log/development.log
96
+ - test/dummy/log/test.log
97
+ - test/dummy/public/404.html
98
+ - test/dummy/public/422.html
99
+ - test/dummy/public/500.html
100
+ - test/dummy/public/favicon.ico
101
+ - test/dummy/Rakefile
102
+ - test/dummy/README.rdoc
103
+ - test/dummy/script/rails
104
+ - test/dummy/test/fixtures/companies.yml
105
+ - test/dummy/test/fixtures/outcasts.yml
106
+ - test/dummy/test/fixtures/people.yml
107
+ - test/dummy/test/unit/company_test.rb
108
+ - test/dummy/test/unit/outcast_test.rb
109
+ - test/dummy/test/unit/person_test.rb
110
+ - test/rails_phone_test.rb
111
+ - test/test_helper.rb
112
+ homepage: http://github.com/scpike/rails_phone
113
+ licenses: []
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 1.8.24
133
+ signing_key:
134
+ specification_version: 3
135
+ summary: Simple phone number support in rails models.
136
+ test_files:
137
+ - test/dummy/app/assets/javascripts/application.js
138
+ - test/dummy/app/assets/stylesheets/application.css
139
+ - test/dummy/app/controllers/application_controller.rb
140
+ - test/dummy/app/helpers/application_helper.rb
141
+ - test/dummy/app/models/company.rb
142
+ - test/dummy/app/models/outcast.rb
143
+ - test/dummy/app/models/person.rb
144
+ - test/dummy/app/views/layouts/application.html.erb
145
+ - test/dummy/config/application.rb
146
+ - test/dummy/config/boot.rb
147
+ - test/dummy/config/database.yml
148
+ - test/dummy/config/environment.rb
149
+ - test/dummy/config/environments/development.rb
150
+ - test/dummy/config/environments/production.rb
151
+ - test/dummy/config/environments/test.rb
152
+ - test/dummy/config/initializers/backtrace_silencers.rb
153
+ - test/dummy/config/initializers/inflections.rb
154
+ - test/dummy/config/initializers/mime_types.rb
155
+ - test/dummy/config/initializers/secret_token.rb
156
+ - test/dummy/config/initializers/session_store.rb
157
+ - test/dummy/config/initializers/wrap_parameters.rb
158
+ - test/dummy/config/locales/en.yml
159
+ - test/dummy/config/routes.rb
160
+ - test/dummy/config.ru
161
+ - test/dummy/db/development.sqlite3
162
+ - test/dummy/db/migrate/20130403194712_create_people.rb
163
+ - test/dummy/db/migrate/20130403194728_create_companies.rb
164
+ - test/dummy/db/migrate/20130403200930_create_outcasts.rb
165
+ - test/dummy/db/schema.rb
166
+ - test/dummy/db/test.sqlite3
167
+ - test/dummy/log/development.log
168
+ - test/dummy/log/test.log
169
+ - test/dummy/public/404.html
170
+ - test/dummy/public/422.html
171
+ - test/dummy/public/500.html
172
+ - test/dummy/public/favicon.ico
173
+ - test/dummy/Rakefile
174
+ - test/dummy/README.rdoc
175
+ - test/dummy/script/rails
176
+ - test/dummy/test/fixtures/companies.yml
177
+ - test/dummy/test/fixtures/outcasts.yml
178
+ - test/dummy/test/fixtures/people.yml
179
+ - test/dummy/test/unit/company_test.rb
180
+ - test/dummy/test/unit/outcast_test.rb
181
+ - test/dummy/test/unit/person_test.rb
182
+ - test/rails_phone_test.rb
183
+ - test/test_helper.rb
184
+ has_rdoc: