phony_attribute 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +49 -0
- data/Rakefile +38 -0
- data/lib/phony_attribute.rb +7 -0
- data/lib/phony_attribute/attribute.rb +23 -0
- data/lib/phony_attribute/phone_number.rb +111 -0
- data/lib/phony_attribute/phony_plausible_validator.rb +17 -0
- data/lib/phony_attribute/railtie.rb +12 -0
- data/lib/phony_attribute/version.rb +3 -0
- data/lib/tasks/phony_attribute_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/user.rb +6 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +53 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +33 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/db/migrate/20130913211052_add_user.rb +9 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +646 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/phone_number_test.rb +67 -0
- data/test/phony_attribute_test.rb +7 -0
- data/test/test_helper.rb +18 -0
- metadata +180 -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,67 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PhoneNumberTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "a blocked number" do
|
6
|
+
pn = PhonyAttribute::PhoneNumber.parse("7378742833")
|
7
|
+
assert(pn.blocked?)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "parsing" do
|
11
|
+
should "work for standard formats" do
|
12
|
+
[
|
13
|
+
"2065556667",
|
14
|
+
"206-555-6667",
|
15
|
+
"206.555.6667",
|
16
|
+
"(206)555-6667",
|
17
|
+
"+12065556667",
|
18
|
+
"+1 206 555 6667",
|
19
|
+
"+1-206-555-6667",
|
20
|
+
"+1 (206)555-6667",
|
21
|
+
].each do |format|
|
22
|
+
pn = PhonyAttribute::PhoneNumber.parse(format)
|
23
|
+
assert(pn.plausible?)
|
24
|
+
assert_equal("+12065556667", pn.format(:db))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
should "not accept bad formats" do
|
29
|
+
[
|
30
|
+
"awefwalef",
|
31
|
+
"206awefae",
|
32
|
+
"206x1234512",
|
33
|
+
].each do |format|
|
34
|
+
begin
|
35
|
+
pn = PhonyAttribute::PhoneNumber.parse(format)
|
36
|
+
assert(!pn.valid?, "#{format} should not be a valid phone number")
|
37
|
+
rescue
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "database model validations" do
|
44
|
+
should "handle bad phone numbers" do
|
45
|
+
u = User.new({
|
46
|
+
name: "Jeff",
|
47
|
+
phone_number: "206asdf"
|
48
|
+
})
|
49
|
+
assert(!u.valid?, "#{u.phone_number} should not be a plausible phone number")
|
50
|
+
assert(u.errors[:phone_number].present?, "should have errors on number")
|
51
|
+
end
|
52
|
+
|
53
|
+
should "format phone numbers before going to the database" do
|
54
|
+
u = User.new({
|
55
|
+
name: "Jeff",
|
56
|
+
phone_number: "2065556667"
|
57
|
+
})
|
58
|
+
assert_difference "User.count", 1 do
|
59
|
+
assert(u.save)
|
60
|
+
end
|
61
|
+
|
62
|
+
user = User.find(u.id)
|
63
|
+
assert_equal("+12065556667", u.phone_number.format(:db), 'phone number should persist')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
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
|
+
require 'shoulda/context'
|
7
|
+
|
8
|
+
Rails.backtrace_cleaner.remove_silencers!
|
9
|
+
|
10
|
+
# Load support files
|
11
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
12
|
+
|
13
|
+
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
14
|
+
|
15
|
+
# Load fixtures from the engine
|
16
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
17
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: phony_attribute
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeff Ching
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-09-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: phony
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.9.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.9.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: shoulda-context
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: ActiveModel field serializer for handling phone numbers via Phony gem
|
70
|
+
email:
|
71
|
+
- ching.jeff@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- lib/phony_attribute/attribute.rb
|
77
|
+
- lib/phony_attribute/phone_number.rb
|
78
|
+
- lib/phony_attribute/phony_plausible_validator.rb
|
79
|
+
- lib/phony_attribute/railtie.rb
|
80
|
+
- lib/phony_attribute/version.rb
|
81
|
+
- lib/phony_attribute.rb
|
82
|
+
- lib/tasks/phony_attribute_tasks.rake
|
83
|
+
- MIT-LICENSE
|
84
|
+
- Rakefile
|
85
|
+
- README.md
|
86
|
+
- test/dummy/app/assets/javascripts/application.js
|
87
|
+
- test/dummy/app/assets/stylesheets/application.css
|
88
|
+
- test/dummy/app/controllers/application_controller.rb
|
89
|
+
- test/dummy/app/helpers/application_helper.rb
|
90
|
+
- test/dummy/app/models/user.rb
|
91
|
+
- test/dummy/app/views/layouts/application.html.erb
|
92
|
+
- test/dummy/config/application.rb
|
93
|
+
- test/dummy/config/boot.rb
|
94
|
+
- test/dummy/config/database.yml
|
95
|
+
- test/dummy/config/environment.rb
|
96
|
+
- test/dummy/config/environments/development.rb
|
97
|
+
- test/dummy/config/environments/production.rb
|
98
|
+
- test/dummy/config/environments/test.rb
|
99
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
100
|
+
- test/dummy/config/initializers/inflections.rb
|
101
|
+
- test/dummy/config/initializers/mime_types.rb
|
102
|
+
- test/dummy/config/initializers/secret_token.rb
|
103
|
+
- test/dummy/config/initializers/session_store.rb
|
104
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
105
|
+
- test/dummy/config/locales/en.yml
|
106
|
+
- test/dummy/config/routes.rb
|
107
|
+
- test/dummy/config.ru
|
108
|
+
- test/dummy/db/migrate/20130913211052_add_user.rb
|
109
|
+
- test/dummy/log/development.log
|
110
|
+
- test/dummy/log/test.log
|
111
|
+
- test/dummy/public/404.html
|
112
|
+
- test/dummy/public/422.html
|
113
|
+
- test/dummy/public/500.html
|
114
|
+
- test/dummy/public/favicon.ico
|
115
|
+
- test/dummy/Rakefile
|
116
|
+
- test/dummy/README.rdoc
|
117
|
+
- test/dummy/script/rails
|
118
|
+
- test/phone_number_test.rb
|
119
|
+
- test/phony_attribute_test.rb
|
120
|
+
- test/test_helper.rb
|
121
|
+
homepage: http://github.com/chingor13/phony_attribute
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.0.3
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: ActiveModel field serializer for handling phone numbers via Phony gem
|
145
|
+
test_files:
|
146
|
+
- test/dummy/app/assets/javascripts/application.js
|
147
|
+
- test/dummy/app/assets/stylesheets/application.css
|
148
|
+
- test/dummy/app/controllers/application_controller.rb
|
149
|
+
- test/dummy/app/helpers/application_helper.rb
|
150
|
+
- test/dummy/app/models/user.rb
|
151
|
+
- test/dummy/app/views/layouts/application.html.erb
|
152
|
+
- test/dummy/config/application.rb
|
153
|
+
- test/dummy/config/boot.rb
|
154
|
+
- test/dummy/config/database.yml
|
155
|
+
- test/dummy/config/environment.rb
|
156
|
+
- test/dummy/config/environments/development.rb
|
157
|
+
- test/dummy/config/environments/production.rb
|
158
|
+
- test/dummy/config/environments/test.rb
|
159
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
160
|
+
- test/dummy/config/initializers/inflections.rb
|
161
|
+
- test/dummy/config/initializers/mime_types.rb
|
162
|
+
- test/dummy/config/initializers/secret_token.rb
|
163
|
+
- test/dummy/config/initializers/session_store.rb
|
164
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
165
|
+
- test/dummy/config/locales/en.yml
|
166
|
+
- test/dummy/config/routes.rb
|
167
|
+
- test/dummy/config.ru
|
168
|
+
- test/dummy/db/migrate/20130913211052_add_user.rb
|
169
|
+
- test/dummy/log/development.log
|
170
|
+
- test/dummy/log/test.log
|
171
|
+
- test/dummy/public/404.html
|
172
|
+
- test/dummy/public/422.html
|
173
|
+
- test/dummy/public/500.html
|
174
|
+
- test/dummy/public/favicon.ico
|
175
|
+
- test/dummy/Rakefile
|
176
|
+
- test/dummy/README.rdoc
|
177
|
+
- test/dummy/script/rails
|
178
|
+
- test/phone_number_test.rb
|
179
|
+
- test/phony_attribute_test.rb
|
180
|
+
- test/test_helper.rb
|