url_attribute 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +74 -0
- data/Rakefile +38 -0
- data/lib/url_attribute.rb +9 -0
- data/lib/url_attribute/attribute.rb +24 -0
- data/lib/url_attribute/normalized_url.rb +13 -0
- data/lib/url_attribute/railtie.rb +12 -0
- data/lib/url_attribute/url.rb +37 -0
- data/lib/url_attribute/url_validator.rb +14 -0
- data/lib/url_attribute/version.rb +3 -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 +9 -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 +54 -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 +33 -0
- data/test/dummy/config/environments/production.rb +69 -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/20130916191537_add_users.rb +11 -0
- data/test/dummy/log/test.log +1351 -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/dummy/test/fixtures/users.yml +7 -0
- data/test/test_helper.rb +18 -0
- data/test/unit/user_test.rb +51 -0
- data/test/unit/validator_test.rb +33 -0
- metadata +167 -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'
|
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
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
class UserTest < ActiveSupport::TestCase
|
5
|
+
|
6
|
+
self.use_transactional_fixtures = true
|
7
|
+
fixtures :users
|
8
|
+
|
9
|
+
test "loading from db" do
|
10
|
+
user = User.find(ActiveRecord::Fixtures.identify(:jeff))
|
11
|
+
|
12
|
+
assert(user.website)
|
13
|
+
assert_equal("http://chingr.com/", user.website.to_s)
|
14
|
+
end
|
15
|
+
|
16
|
+
test "creating" do
|
17
|
+
user = User.new({
|
18
|
+
name: "New Person",
|
19
|
+
website: "github.com",
|
20
|
+
stem: "google.com"
|
21
|
+
})
|
22
|
+
|
23
|
+
assert_difference "User.count", 1 do
|
24
|
+
user.save
|
25
|
+
end
|
26
|
+
|
27
|
+
user = User.last
|
28
|
+
assert_equal("http://github.com", user.website.to_s, "should normalize the url")
|
29
|
+
assert_equal("google.com", user.stem.to_s, "should not normalize field marked as unnormalized")
|
30
|
+
assert_nil(user.facebook)
|
31
|
+
end
|
32
|
+
|
33
|
+
test "blank url" do
|
34
|
+
user = User.new({
|
35
|
+
name: "New Person",
|
36
|
+
website: ""
|
37
|
+
})
|
38
|
+
|
39
|
+
assert_equal("", user.website.to_s)
|
40
|
+
end
|
41
|
+
|
42
|
+
test "nil url" do
|
43
|
+
user = User.new({
|
44
|
+
name: "New Person",
|
45
|
+
website: nil
|
46
|
+
})
|
47
|
+
|
48
|
+
assert_nil(user.website)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ValidatorTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
test "invalid url" do
|
6
|
+
user = User.new({
|
7
|
+
name: "New Person",
|
8
|
+
website: "something totally invalid"
|
9
|
+
})
|
10
|
+
|
11
|
+
assert(user.website)
|
12
|
+
|
13
|
+
assert !user.valid?, "invalid website should be invalid"
|
14
|
+
assert user.errors[:website].present?
|
15
|
+
|
16
|
+
assert_equal("something totally invalid", user.website.to_s)
|
17
|
+
end
|
18
|
+
|
19
|
+
test "invalid url2" do
|
20
|
+
user = User.new({
|
21
|
+
name: "New Person",
|
22
|
+
website: "@!*@(*!@(#"
|
23
|
+
})
|
24
|
+
|
25
|
+
assert(user.website)
|
26
|
+
|
27
|
+
assert !user.valid?, "invalid website should be invalid"
|
28
|
+
assert user.errors[:website].present?
|
29
|
+
|
30
|
+
assert_equal("@!*@(*!@(#", user.website.to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: url_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: 2014-04-22 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: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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
|
+
description: ActiveModel field serializer for url fields
|
56
|
+
email:
|
57
|
+
- ching.jeff@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- lib/url_attribute.rb
|
66
|
+
- lib/url_attribute/attribute.rb
|
67
|
+
- lib/url_attribute/normalized_url.rb
|
68
|
+
- lib/url_attribute/railtie.rb
|
69
|
+
- lib/url_attribute/url.rb
|
70
|
+
- lib/url_attribute/url_validator.rb
|
71
|
+
- lib/url_attribute/version.rb
|
72
|
+
- test/dummy/README.rdoc
|
73
|
+
- test/dummy/Rakefile
|
74
|
+
- test/dummy/app/assets/javascripts/application.js
|
75
|
+
- test/dummy/app/assets/stylesheets/application.css
|
76
|
+
- test/dummy/app/controllers/application_controller.rb
|
77
|
+
- test/dummy/app/helpers/application_helper.rb
|
78
|
+
- test/dummy/app/models/user.rb
|
79
|
+
- test/dummy/app/views/layouts/application.html.erb
|
80
|
+
- test/dummy/config.ru
|
81
|
+
- test/dummy/config/application.rb
|
82
|
+
- test/dummy/config/boot.rb
|
83
|
+
- test/dummy/config/database.yml
|
84
|
+
- test/dummy/config/environment.rb
|
85
|
+
- test/dummy/config/environments/development.rb
|
86
|
+
- test/dummy/config/environments/production.rb
|
87
|
+
- test/dummy/config/environments/test.rb
|
88
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
89
|
+
- test/dummy/config/initializers/inflections.rb
|
90
|
+
- test/dummy/config/initializers/mime_types.rb
|
91
|
+
- test/dummy/config/initializers/secret_token.rb
|
92
|
+
- test/dummy/config/initializers/session_store.rb
|
93
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
94
|
+
- test/dummy/config/locales/en.yml
|
95
|
+
- test/dummy/config/routes.rb
|
96
|
+
- test/dummy/db/migrate/20130916191537_add_users.rb
|
97
|
+
- test/dummy/log/test.log
|
98
|
+
- test/dummy/public/404.html
|
99
|
+
- test/dummy/public/422.html
|
100
|
+
- test/dummy/public/500.html
|
101
|
+
- test/dummy/public/favicon.ico
|
102
|
+
- test/dummy/script/rails
|
103
|
+
- test/dummy/test/fixtures/users.yml
|
104
|
+
- test/test_helper.rb
|
105
|
+
- test/unit/user_test.rb
|
106
|
+
- test/unit/validator_test.rb
|
107
|
+
homepage: http://github.com/chingor13/url_attribute
|
108
|
+
licenses:
|
109
|
+
- MIT
|
110
|
+
metadata: {}
|
111
|
+
post_install_message:
|
112
|
+
rdoc_options: []
|
113
|
+
require_paths:
|
114
|
+
- lib
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 2.2.2
|
128
|
+
signing_key:
|
129
|
+
specification_version: 4
|
130
|
+
summary: ActiveModel field serializer for url fields
|
131
|
+
test_files:
|
132
|
+
- test/dummy/app/assets/javascripts/application.js
|
133
|
+
- test/dummy/app/assets/stylesheets/application.css
|
134
|
+
- test/dummy/app/controllers/application_controller.rb
|
135
|
+
- test/dummy/app/helpers/application_helper.rb
|
136
|
+
- test/dummy/app/models/user.rb
|
137
|
+
- test/dummy/app/views/layouts/application.html.erb
|
138
|
+
- test/dummy/config/application.rb
|
139
|
+
- test/dummy/config/boot.rb
|
140
|
+
- test/dummy/config/database.yml
|
141
|
+
- test/dummy/config/environment.rb
|
142
|
+
- test/dummy/config/environments/development.rb
|
143
|
+
- test/dummy/config/environments/production.rb
|
144
|
+
- test/dummy/config/environments/test.rb
|
145
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
146
|
+
- test/dummy/config/initializers/inflections.rb
|
147
|
+
- test/dummy/config/initializers/mime_types.rb
|
148
|
+
- test/dummy/config/initializers/secret_token.rb
|
149
|
+
- test/dummy/config/initializers/session_store.rb
|
150
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
151
|
+
- test/dummy/config/locales/en.yml
|
152
|
+
- test/dummy/config/routes.rb
|
153
|
+
- test/dummy/config.ru
|
154
|
+
- test/dummy/db/migrate/20130916191537_add_users.rb
|
155
|
+
- test/dummy/log/test.log
|
156
|
+
- test/dummy/public/404.html
|
157
|
+
- test/dummy/public/422.html
|
158
|
+
- test/dummy/public/500.html
|
159
|
+
- test/dummy/public/favicon.ico
|
160
|
+
- test/dummy/Rakefile
|
161
|
+
- test/dummy/README.rdoc
|
162
|
+
- test/dummy/script/rails
|
163
|
+
- test/dummy/test/fixtures/users.yml
|
164
|
+
- test/test_helper.rb
|
165
|
+
- test/unit/user_test.rb
|
166
|
+
- test/unit/validator_test.rb
|
167
|
+
has_rdoc:
|