test_track_rails_client 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +11 -8
- data/lib/test_track_rails_client/version.rb +1 -1
- data/vendor/gems/fakeable_her/fakeable_her.gemspec +22 -0
- data/vendor/gems/fakeable_her/lib/fakeable_her/model.rb +148 -0
- data/vendor/gems/fakeable_her/lib/fakeable_her/version.rb +3 -0
- data/vendor/gems/fakeable_her/lib/fakeable_her.rb +5 -0
- data/vendor/gems/her/CONTRIBUTING.md +26 -0
- data/vendor/gems/her/Gemfile +10 -0
- data/vendor/gems/her/LICENSE +7 -0
- data/vendor/gems/her/README.md +1023 -0
- data/vendor/gems/her/Rakefile +11 -0
- data/vendor/gems/her/UPGRADE.md +101 -0
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-3.2.x +7 -0
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.0 +7 -0
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.1 +7 -0
- data/vendor/gems/her/gemfiles/Gemfile.activemodel-4.2 +7 -0
- data/vendor/gems/her/her.gemspec +31 -0
- data/vendor/gems/her/lib/her/api.rb +119 -0
- data/vendor/gems/her/lib/her/collection.rb +12 -0
- data/vendor/gems/her/lib/her/error_collection.rb +15 -0
- data/vendor/gems/her/lib/her/errors.rb +40 -0
- data/vendor/gems/her/lib/her/json_api/model.rb +46 -0
- data/vendor/gems/her/lib/her/middleware/accept_json.rb +17 -0
- data/vendor/gems/her/lib/her/middleware/first_level_parse_json.rb +36 -0
- data/vendor/gems/her/lib/her/middleware/json_api_parser.rb +36 -0
- data/vendor/gems/her/lib/her/middleware/parse_json.rb +21 -0
- data/vendor/gems/her/lib/her/middleware/second_level_parse_json.rb +36 -0
- data/vendor/gems/her/lib/her/middleware.rb +12 -0
- data/vendor/gems/her/lib/her/model/active_model_overrides.rb +13 -0
- data/vendor/gems/her/lib/her/model/associations/association.rb +106 -0
- data/vendor/gems/her/lib/her/model/associations/association_proxy.rb +46 -0
- data/vendor/gems/her/lib/her/model/associations/belongs_to_association.rb +96 -0
- data/vendor/gems/her/lib/her/model/associations/has_many_association.rb +100 -0
- data/vendor/gems/her/lib/her/model/associations/has_one_association.rb +79 -0
- data/vendor/gems/her/lib/her/model/associations.rb +141 -0
- data/vendor/gems/her/lib/her/model/attributes.rb +304 -0
- data/vendor/gems/her/lib/her/model/base.rb +33 -0
- data/vendor/gems/her/lib/her/model/deprecated_methods.rb +61 -0
- data/vendor/gems/her/lib/her/model/http.rb +117 -0
- data/vendor/gems/her/lib/her/model/introspection.rb +65 -0
- data/vendor/gems/her/lib/her/model/nested_attributes.rb +45 -0
- data/vendor/gems/her/lib/her/model/orm.rb +219 -0
- data/vendor/gems/her/lib/her/model/parse.rb +215 -0
- data/vendor/gems/her/lib/her/model/paths.rb +126 -0
- data/vendor/gems/her/lib/her/model/relation.rb +251 -0
- data/vendor/gems/her/lib/her/model.rb +81 -0
- data/vendor/gems/her/lib/her/version.rb +3 -0
- data/vendor/gems/her/lib/her.rb +20 -0
- data/vendor/gems/her/spec/api_spec.rb +114 -0
- data/vendor/gems/her/spec/collection_spec.rb +26 -0
- data/vendor/gems/her/spec/error_collection_spec.rb +33 -0
- data/vendor/gems/her/spec/json_api/model_spec.rb +168 -0
- data/vendor/gems/her/spec/middleware/accept_json_spec.rb +10 -0
- data/vendor/gems/her/spec/middleware/first_level_parse_json_spec.rb +62 -0
- data/vendor/gems/her/spec/middleware/json_api_parser_spec.rb +32 -0
- data/vendor/gems/her/spec/middleware/second_level_parse_json_spec.rb +35 -0
- data/vendor/gems/her/spec/model/associations/association_proxy_spec.rb +31 -0
- data/vendor/gems/her/spec/model/associations_spec.rb +504 -0
- data/vendor/gems/her/spec/model/attributes_spec.rb +404 -0
- data/vendor/gems/her/spec/model/callbacks_spec.rb +145 -0
- data/vendor/gems/her/spec/model/dirty_spec.rb +110 -0
- data/vendor/gems/her/spec/model/http_spec.rb +165 -0
- data/vendor/gems/her/spec/model/introspection_spec.rb +76 -0
- data/vendor/gems/her/spec/model/nested_attributes_spec.rb +134 -0
- data/vendor/gems/her/spec/model/orm_spec.rb +791 -0
- data/vendor/gems/her/spec/model/parse_spec.rb +372 -0
- data/vendor/gems/her/spec/model/paths_spec.rb +347 -0
- data/vendor/gems/her/spec/model/relation_spec.rb +226 -0
- data/vendor/gems/her/spec/model/validations_spec.rb +42 -0
- data/vendor/gems/her/spec/model_spec.rb +31 -0
- data/vendor/gems/her/spec/spec_helper.rb +27 -0
- data/vendor/gems/her/spec/support/extensions/array.rb +5 -0
- data/vendor/gems/her/spec/support/extensions/hash.rb +5 -0
- data/vendor/gems/her/spec/support/macros/her_macros.rb +17 -0
- data/vendor/gems/her/spec/support/macros/model_macros.rb +36 -0
- data/vendor/gems/her/spec/support/macros/request_macros.rb +27 -0
- data/vendor/gems/publicsuffix-ruby/CHANGELOG.md +236 -0
- data/vendor/gems/publicsuffix-ruby/Gemfile +3 -0
- data/vendor/gems/publicsuffix-ruby/LICENSE.txt +22 -0
- data/vendor/gems/publicsuffix-ruby/README.md +151 -0
- data/vendor/gems/publicsuffix-ruby/Rakefile +109 -0
- data/vendor/gems/publicsuffix-ruby/lib/definitions.txt +11467 -0
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/domain.rb +387 -0
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/errors.rb +53 -0
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/list.rb +302 -0
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/rule.rb +373 -0
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix/version.rb +23 -0
- data/vendor/gems/publicsuffix-ruby/lib/public_suffix.rb +131 -0
- data/vendor/gems/publicsuffix-ruby/public_suffix.gemspec +39 -0
- data/vendor/gems/publicsuffix-ruby/test/acceptance_test.rb +42 -0
- data/vendor/gems/publicsuffix-ruby/test/test_helper.rb +6 -0
- data/vendor/gems/publicsuffix-ruby/test/unit/domain_test.rb +170 -0
- data/vendor/gems/publicsuffix-ruby/test/unit/errors_test.rb +23 -0
- data/vendor/gems/publicsuffix-ruby/test/unit/list_test.rb +179 -0
- data/vendor/gems/publicsuffix-ruby/test/unit/public_suffix_test.rb +115 -0
- data/vendor/gems/publicsuffix-ruby/test/unit/rule_test.rb +307 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/capybara_configuration.rb +98 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/matchers.rb +151 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rspec_configuration.rb +34 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/html_safe.rb +15 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/raw.rb +15 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop/cop/betterment/safe_concat.rb +15 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/rubocop.rb +3 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples/betterment_application_examples.rb +47 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/shared_examples.rb +1 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_configuration.rb +42 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/site_prism_dropdown.rb +17 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/version.rb +3 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers/webmock_configuration.rb +8 -0
- data/vendor/gems/ruby_spec_helpers/lib/ruby_spec_helpers.rb +2 -0
- data/vendor/gems/ruby_spec_helpers/ruby_spec_helpers.gemspec +25 -0
- metadata +110 -1
@@ -0,0 +1,36 @@
|
|
1
|
+
module Her
|
2
|
+
module Testing
|
3
|
+
module Macros
|
4
|
+
module ModelMacros
|
5
|
+
# Create a class and automatically inject Her::Model into it
|
6
|
+
def spawn_model(klass, options={}, &block)
|
7
|
+
super_class = options[:super_class]
|
8
|
+
model_type = options[:type] || Her::Model
|
9
|
+
new_class = if super_class
|
10
|
+
Class.new(super_class)
|
11
|
+
else
|
12
|
+
Class.new
|
13
|
+
end
|
14
|
+
if klass =~ /::/
|
15
|
+
base, submodel = klass.split(/::/).map{ |s| s.to_sym }
|
16
|
+
Object.const_set(base, Module.new) unless Object.const_defined?(base)
|
17
|
+
Object.const_get(base).module_eval do
|
18
|
+
remove_const submodel if constants.map(&:to_sym).include?(submodel)
|
19
|
+
submodel = const_set(submodel, new_class)
|
20
|
+
submodel.send(:include, model_type)
|
21
|
+
submodel.class_eval(&block) if block_given?
|
22
|
+
end
|
23
|
+
|
24
|
+
@spawned_models << base
|
25
|
+
else
|
26
|
+
Object.instance_eval { remove_const klass } if Object.const_defined?(klass)
|
27
|
+
Object.const_set(klass, Class.new).send(:include, model_type)
|
28
|
+
Object.const_get(klass).class_eval(&block) if block_given?
|
29
|
+
|
30
|
+
@spawned_models << klass.to_sym
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Her
|
2
|
+
module Testing
|
3
|
+
module Macros
|
4
|
+
module RequestMacros
|
5
|
+
def ok!(body)
|
6
|
+
[200, {}, body.to_json]
|
7
|
+
end
|
8
|
+
|
9
|
+
def error!(body)
|
10
|
+
[400, {}, body.to_json]
|
11
|
+
end
|
12
|
+
|
13
|
+
def params(env)
|
14
|
+
@params ||= begin
|
15
|
+
parsed_query = Faraday::Utils.parse_nested_query(env[:body])
|
16
|
+
|
17
|
+
if parsed_query
|
18
|
+
parsed_query.with_indifferent_access.merge(env[:params])
|
19
|
+
else
|
20
|
+
env[:params].with_indifferent_access
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,236 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
|
4
|
+
#### Release 1.4.6
|
5
|
+
|
6
|
+
- CHANGED: Updated definitions.
|
7
|
+
|
8
|
+
|
9
|
+
#### Release 1.4.5
|
10
|
+
|
11
|
+
- CHANGED: Updated definitions.
|
12
|
+
|
13
|
+
|
14
|
+
#### Release 1.4.4
|
15
|
+
|
16
|
+
- CHANGED: Updated definitions.
|
17
|
+
|
18
|
+
|
19
|
+
#### Release 1.4.3
|
20
|
+
|
21
|
+
- CHANGED: Updated definitions.
|
22
|
+
|
23
|
+
|
24
|
+
#### Release 1.4.2
|
25
|
+
|
26
|
+
- CHANGED: Updated definitions.
|
27
|
+
|
28
|
+
|
29
|
+
#### Release 1.4.1
|
30
|
+
|
31
|
+
- CHANGED: Updated definitions.
|
32
|
+
|
33
|
+
|
34
|
+
#### Release 1.4.0
|
35
|
+
|
36
|
+
- CHANGED: Moved the definitions in the lib folder.
|
37
|
+
|
38
|
+
- CHANGED: Updated definitions.
|
39
|
+
|
40
|
+
|
41
|
+
#### Release 1.3.3
|
42
|
+
|
43
|
+
- CHANGED: Updated definitions.
|
44
|
+
|
45
|
+
|
46
|
+
#### Release 1.3.2
|
47
|
+
|
48
|
+
- CHANGED: Updated definitions.
|
49
|
+
|
50
|
+
|
51
|
+
#### Release 1.3.1
|
52
|
+
|
53
|
+
- CHANGED: Updated definitions.
|
54
|
+
|
55
|
+
|
56
|
+
#### Release 1.3.0
|
57
|
+
|
58
|
+
- NEW: Ability to skip Private Domains (GH-28). [Thanks @rb2k]
|
59
|
+
|
60
|
+
- CHANGED: Updated definitions.
|
61
|
+
|
62
|
+
|
63
|
+
#### Release 1.2.1
|
64
|
+
|
65
|
+
- CHANGED: Updated definitions.
|
66
|
+
|
67
|
+
|
68
|
+
#### Release 1.2.0
|
69
|
+
|
70
|
+
- NEW: Allow a custom List on `PublicSuffix.parse` (GH-26). [Thanks @itspriddle]
|
71
|
+
|
72
|
+
- FIXED: PublicSuffix.parse and PublicSuffix.valid? crashes when input is nil (GH-20).
|
73
|
+
|
74
|
+
- CHANGED: Updated definitions.
|
75
|
+
|
76
|
+
|
77
|
+
#### Release 1.1.3
|
78
|
+
|
79
|
+
- CHANGED: Updated definitions.
|
80
|
+
|
81
|
+
|
82
|
+
#### Release 1.1.2
|
83
|
+
|
84
|
+
- CHANGED: Updated definitions.
|
85
|
+
|
86
|
+
|
87
|
+
#### Release 1.1.1
|
88
|
+
|
89
|
+
- CHANGED: Updated definitions.
|
90
|
+
|
91
|
+
|
92
|
+
#### Release 1.1.0
|
93
|
+
|
94
|
+
- FIXED: #valid? and #parse consider URIs as valid domains (GH-15)
|
95
|
+
|
96
|
+
- CHANGED: Updated definitions.
|
97
|
+
|
98
|
+
- CHANGED: Removed deprecatd PublicSuffixService::RuleList.
|
99
|
+
|
100
|
+
|
101
|
+
#### Release 1.0.0
|
102
|
+
|
103
|
+
- CHANGED: Updated definitions.
|
104
|
+
|
105
|
+
|
106
|
+
#### Release 1.0.0.rc1
|
107
|
+
|
108
|
+
The library is now known as PublicSuffix.
|
109
|
+
|
110
|
+
|
111
|
+
#### Release 0.9.1
|
112
|
+
|
113
|
+
- CHANGED: Renamed PublicSuffixService::RuleList to PublicSuffixService::List.
|
114
|
+
|
115
|
+
- CHANGED: Renamed PublicSuffixService::List#list to PublicSuffixService::List#rules.
|
116
|
+
|
117
|
+
- CHANGED: Renamed PublicSuffixService to PublicSuffix.
|
118
|
+
|
119
|
+
- CHANGED: Updated definitions.
|
120
|
+
|
121
|
+
|
122
|
+
#### Release 0.9.0
|
123
|
+
|
124
|
+
- CHANGED: Minimum Ruby version increased to Ruby 1.8.7.
|
125
|
+
|
126
|
+
- CHANGED: rake/gempackagetask is deprecated. Use rubygems/package_task instead.
|
127
|
+
|
128
|
+
|
129
|
+
#### Release 0.8.4
|
130
|
+
|
131
|
+
- FIXED: Reverted bugfix for issue #12 for Ruby 1.8.6.
|
132
|
+
This is the latest version compatible with Ruby 1.8.6.
|
133
|
+
|
134
|
+
|
135
|
+
#### Release 0.8.3
|
136
|
+
|
137
|
+
- FIXED: Fixed ArgumentError: invalid byte sequence in US-ASCII with Ruby 1.9.2 (#12).
|
138
|
+
|
139
|
+
- CHANGED: Updated definitions (#11).
|
140
|
+
|
141
|
+
- CHANGED: Renamed definitions.txt to definitions.dat.
|
142
|
+
|
143
|
+
|
144
|
+
#### Release 0.8.2
|
145
|
+
|
146
|
+
- NEW: Added support for rubygems-test.
|
147
|
+
|
148
|
+
- CHANGED: Integrated Bundler.
|
149
|
+
|
150
|
+
- CHANGED: Updated definitions.
|
151
|
+
|
152
|
+
|
153
|
+
#### Release 0.8.1
|
154
|
+
|
155
|
+
- FIXED: The files in the release 0.8.0 have wrong permission 600 and can't be loaded (#10).
|
156
|
+
|
157
|
+
|
158
|
+
#### Release 0.8.0
|
159
|
+
|
160
|
+
- CHANGED: Update public suffix list to d1a5599b49fa 2010-10-25 15:10 +0100 (#9)
|
161
|
+
|
162
|
+
- NEW: Add support for Fully Qualified Domain Names (#7)
|
163
|
+
|
164
|
+
|
165
|
+
#### Release 0.7.0
|
166
|
+
|
167
|
+
- CHANGED: Using YARD to document the code instead of RDoc.
|
168
|
+
|
169
|
+
- FIXED: RuleList cache is not recreated when a new rule is appended to the list (#6)
|
170
|
+
|
171
|
+
- FIXED: PublicSuffixService.valid? should return false if the domain is not defined or not allowed (#4, #5)
|
172
|
+
|
173
|
+
|
174
|
+
#### Release 0.6.0
|
175
|
+
|
176
|
+
- NEW: PublicSuffixService.parse raises DomainNotAllowed when trying to parse a domain name
|
177
|
+
which exists, but is not allowed by the current definition list (#3)
|
178
|
+
|
179
|
+
PublicSuffixService.parse("nic.do")
|
180
|
+
# => PublicSuffixService::DomainNotAllowed
|
181
|
+
|
182
|
+
- CHANGED: Renamed PublicSuffixService::InvalidDomain to PublicSuffixService::DomainInvalid
|
183
|
+
|
184
|
+
|
185
|
+
#### Release 0.5.2
|
186
|
+
|
187
|
+
- CHANGED: Update public suffix list to 248ea690d671 2010-09-16 18:02 +0100
|
188
|
+
|
189
|
+
|
190
|
+
#### Release 0.5.1
|
191
|
+
|
192
|
+
- CHANGED: Update public suffix list to 14dc66dd53c1 2010-09-15 17:09 +0100
|
193
|
+
|
194
|
+
|
195
|
+
#### Release 0.5.0
|
196
|
+
|
197
|
+
- CHANGED: Improve documentation for Domain#domain and Domain#subdomain (#1).
|
198
|
+
|
199
|
+
- CHANGED: Performance improvements (#2).
|
200
|
+
|
201
|
+
|
202
|
+
#### Release 0.4.0
|
203
|
+
|
204
|
+
- CHANGED: Rename library from DomainName to PublicSuffixService to reduce the probability of name conflicts.
|
205
|
+
|
206
|
+
|
207
|
+
#### Release 0.3.1
|
208
|
+
|
209
|
+
- Deprecated DomainName library.
|
210
|
+
|
211
|
+
|
212
|
+
#### Release 0.3.0
|
213
|
+
|
214
|
+
- CHANGED: DomainName#domain and DomainName#subdomain are no longer alias of Domain#sld and Domain#tld.
|
215
|
+
|
216
|
+
- CHANGED: Removed DomainName#labels and decoupled Rule from DomainName.
|
217
|
+
|
218
|
+
- CHANGED: DomainName#valid? no longer instantiates new DomainName objects. This means less overhead.
|
219
|
+
|
220
|
+
- CHANGED: Refactoring the entire DomainName API. Removed the internal on-the-fly parsing. Added a bunch of new methods to check and validate the DomainName.
|
221
|
+
|
222
|
+
|
223
|
+
#### Release 0.2.0
|
224
|
+
|
225
|
+
- NEW: DomainName#valid?
|
226
|
+
|
227
|
+
- NEW: DomainName#parse and DomainName#parse!
|
228
|
+
|
229
|
+
- NEW: DomainName#valid_domain? and DomainName#valid_subdomain?
|
230
|
+
|
231
|
+
- CHANGED: Make sure RuleList lookup is only performed once.
|
232
|
+
|
233
|
+
|
234
|
+
#### Release 0.1.0
|
235
|
+
|
236
|
+
- Initial version
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2009-2014 Simone Carletti <weppos@weppos.net>
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,151 @@
|
|
1
|
+
# Public Suffix List
|
2
|
+
|
3
|
+
<tt>PublicSuffix</tt> is a Ruby domain name parser based on the [Public Suffix List](http://publicsuffix.org/).
|
4
|
+
|
5
|
+
[![Build Status](https://secure.travis-ci.org/weppos/publicsuffix-ruby.png)](http://travis-ci.org/weppos/publicsuffix-ruby)
|
6
|
+
|
7
|
+
|
8
|
+
## What is the Public Suffix List?
|
9
|
+
|
10
|
+
The Public Suffix List is a cross-vendor initiative to provide an accurate list of domain name suffixes.
|
11
|
+
|
12
|
+
The Public Suffix List is an initiative of the Mozilla Project, but is maintained as a community resource. It is available for use in any software, but was originally created to meet the needs of browser manufacturers.
|
13
|
+
|
14
|
+
A "public suffix" is one under which Internet users can directly register names. Some examples of public suffixes are ".com", ".co.uk" and "pvt.k12.wy.us". The Public Suffix List is a list of all known public suffixes.
|
15
|
+
|
16
|
+
Source: http://publicsuffix.org
|
17
|
+
|
18
|
+
|
19
|
+
## Why the Public Suffix List is better than any available Regular Expression parser?
|
20
|
+
|
21
|
+
Previously, browsers used an algorithm which basically only denied setting wide-ranging cookies for top-level domains with no dots (e.g. com or org). However, this did not work for top-level domains where only third-level registrations are allowed (e.g. co.uk). In these cases, websites could set a cookie for co.uk which will be passed onto every website registered under co.uk.
|
22
|
+
|
23
|
+
Clearly, this was a security risk as it allowed websites other than the one setting the cookie to read it, and therefore potentially extract sensitive information.
|
24
|
+
|
25
|
+
Since there is no algorithmic method of finding the highest level at which a domain may be registered for a particular top-level domain (the policies differ with each registry), the only method is to create a list of all top-level domains and the level at which domains can be registered. This is the aim of the effective TLD list.
|
26
|
+
|
27
|
+
As well as being used to prevent cookies from being set where they shouldn't be, the list can also potentially be used for other applications where the registry controlled and privately controlled parts of a domain name need to be known, for example when grouping by top-level domains.
|
28
|
+
|
29
|
+
Source: https://wiki.mozilla.org/Public_Suffix_List
|
30
|
+
|
31
|
+
Not convinced yet? Check out [this real world example](http://stackoverflow.com/q/288810/123527).
|
32
|
+
|
33
|
+
|
34
|
+
## Requirements
|
35
|
+
|
36
|
+
- Ruby >= 1.9.3
|
37
|
+
|
38
|
+
For an older versions of Ruby use a previous release. We also support several [Ruby implementations](http://simonecarletti.com/code/publicsuffix/#implementations).
|
39
|
+
|
40
|
+
|
41
|
+
## Installation
|
42
|
+
|
43
|
+
The best way to install *PublicSuffix* is via [RubyGems](https://rubygems.org/).
|
44
|
+
|
45
|
+
$ gem install public_suffix
|
46
|
+
|
47
|
+
You might need administrator privileges on your system to install the gem.
|
48
|
+
|
49
|
+
|
50
|
+
## Basic Usage
|
51
|
+
|
52
|
+
Example domain without subdomains.
|
53
|
+
|
54
|
+
domain = PublicSuffix.parse("google.com")
|
55
|
+
# => #<PublicSuffix::Domain>
|
56
|
+
domain.tld
|
57
|
+
# => "com"
|
58
|
+
domain.sld
|
59
|
+
# => "google"
|
60
|
+
domain.trd
|
61
|
+
# => nil
|
62
|
+
domain.domain
|
63
|
+
# => "google.com"
|
64
|
+
domain.subdomain
|
65
|
+
# => nil
|
66
|
+
|
67
|
+
Example domain with subdomains.
|
68
|
+
|
69
|
+
domain = PublicSuffix.parse("www.google.com")
|
70
|
+
# => #<PublicSuffix::Domain>
|
71
|
+
domain.tld
|
72
|
+
# => "com"
|
73
|
+
domain.sld
|
74
|
+
# => "google"
|
75
|
+
domain.trd
|
76
|
+
# => "www"
|
77
|
+
domain.domain
|
78
|
+
# => "google.com"
|
79
|
+
domain.subdomain
|
80
|
+
# => "www.google.com"
|
81
|
+
|
82
|
+
Simple validation example.
|
83
|
+
|
84
|
+
PublicSuffix.valid?("google.com")
|
85
|
+
# => true
|
86
|
+
|
87
|
+
PublicSuffix.valid?("www.google.com")
|
88
|
+
# => true
|
89
|
+
|
90
|
+
PublicSuffix.valid?("x.yz")
|
91
|
+
# => false
|
92
|
+
|
93
|
+
## Fully Qualified Domain Names
|
94
|
+
|
95
|
+
This library automatically recognizes Fully Qualified Domain Names. A FQDN is a domain name that end with a trailing dot.
|
96
|
+
|
97
|
+
# Parse a standard domain name
|
98
|
+
domain = PublicSuffix.parse("www.google.com")
|
99
|
+
# => #<PublicSuffix::Domain>
|
100
|
+
domain.tld
|
101
|
+
# => "com"
|
102
|
+
|
103
|
+
# Parse a fully qualified domain name
|
104
|
+
domain = PublicSuffix.parse("www.google.com.")
|
105
|
+
# => #<PublicSuffix::Domain>
|
106
|
+
domain.tld
|
107
|
+
# => "com"
|
108
|
+
|
109
|
+
## Private domains
|
110
|
+
|
111
|
+
This library has support for switching off support for private (non-ICANN) domains
|
112
|
+
|
113
|
+
# Parse a domain on a private TLD
|
114
|
+
domain = PublicSuffix.parse("something.blogspot.com")
|
115
|
+
# => #<PublicSuffix::Domain>
|
116
|
+
domain.tld
|
117
|
+
# => "blogspot.com"
|
118
|
+
|
119
|
+
# Disable support for private TLDs
|
120
|
+
PublicSuffix::List.private_domains = false
|
121
|
+
# => #<PublicSuffix::List>
|
122
|
+
domain = PublicSuffix.parse("something.blogspot.com")
|
123
|
+
# => #<PublicSuffix::Domain>
|
124
|
+
domain.tld
|
125
|
+
# => "com"
|
126
|
+
|
127
|
+
## Feedback and bug reports
|
128
|
+
|
129
|
+
If you use this library and find yourself missing any functionality, please [let me know](mailto:weppos@weppos.net).
|
130
|
+
|
131
|
+
Pull requests are very welcome! Please include tests and/or feature coverage for every patch, and create a topic branch for every separate change you make.
|
132
|
+
|
133
|
+
Report issues or feature requests to [GitHub Issues](https://github.com/weppos/publicsuffix-ruby/issues).
|
134
|
+
|
135
|
+
|
136
|
+
## More
|
137
|
+
|
138
|
+
* [Homepage](http://simonecarletti.com/code/publicsuffix)
|
139
|
+
* [Repository](https://github.com/weppos/publicsuffix-ruby)
|
140
|
+
* [API Documentation](http://rubydoc.info/gems/public_suffix)
|
141
|
+
* [Introducing the Public Suffix List library for Ruby](http://simonecarletti.com/blog/2010/06/public-suffix-list-library-for-ruby/)
|
142
|
+
|
143
|
+
|
144
|
+
## Changelog
|
145
|
+
|
146
|
+
See the [CHANGELOG.md](CHANGELOG.md) file for details.
|
147
|
+
|
148
|
+
|
149
|
+
## License
|
150
|
+
|
151
|
+
Copyright (c) 2009-2014 Simone Carletti. This is Free Software distributed under the MIT license.
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
$:.unshift(File.dirname(__FILE__) + "/lib")
|
5
|
+
require 'public_suffix'
|
6
|
+
|
7
|
+
|
8
|
+
# Common package properties
|
9
|
+
PKG_NAME = PublicSuffix::GEM
|
10
|
+
PKG_VERSION = PublicSuffix::VERSION
|
11
|
+
|
12
|
+
|
13
|
+
# Run test by default.
|
14
|
+
task default: :test
|
15
|
+
|
16
|
+
|
17
|
+
spec = Gem::Specification.new do |s|
|
18
|
+
s.name = PKG_NAME
|
19
|
+
s.version = PKG_VERSION
|
20
|
+
s.summary = "Domain name parser based on the Public Suffix List."
|
21
|
+
s.description = "PublicSuffix can parse and decompose a domain name into top level domain, domain and subdomains."
|
22
|
+
|
23
|
+
s.required_ruby_version = ">= 1.9.3"
|
24
|
+
|
25
|
+
s.author = "Simone Carletti"
|
26
|
+
s.email = "weppos@weppos.net"
|
27
|
+
s.homepage = "http://simonecarletti.com/code/publicsuffix"
|
28
|
+
s.license = "MIT"
|
29
|
+
|
30
|
+
s.files = `git ls-files`.split("\n")
|
31
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
32
|
+
s.require_paths = %w( lib )
|
33
|
+
|
34
|
+
s.add_development_dependency("rake")
|
35
|
+
s.add_development_dependency("mocha")
|
36
|
+
s.add_development_dependency("yard")
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
require 'rubygems/package_task'
|
41
|
+
|
42
|
+
Gem::PackageTask.new(spec) do |pkg|
|
43
|
+
pkg.gem_spec = spec
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Build the gemspec file #{spec.name}.gemspec"
|
47
|
+
task :gemspec do
|
48
|
+
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
49
|
+
File.open(file, "w") {|f| f << spec.to_ruby }
|
50
|
+
end
|
51
|
+
|
52
|
+
desc "Remove any temporary products, including gemspec"
|
53
|
+
task clean: [:clobber] do
|
54
|
+
rm "#{spec.name}.gemspec" if File.file?("#{spec.name}.gemspec")
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Remove any generated file"
|
58
|
+
task clobber: [:clobber_package]
|
59
|
+
|
60
|
+
desc "Package the library and generates the gemspec"
|
61
|
+
task package: [:gemspec]
|
62
|
+
|
63
|
+
|
64
|
+
require 'rake/testtask'
|
65
|
+
|
66
|
+
Rake::TestTask.new do |t|
|
67
|
+
t.libs << "test"
|
68
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
69
|
+
t.verbose = !!ENV["VERBOSE"]
|
70
|
+
t.warning = !!ENV["WARNING"]
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
require 'yard'
|
75
|
+
require 'yard/rake/yardoc_task'
|
76
|
+
|
77
|
+
YARD::Rake::YardocTask.new(:yardoc) do |y|
|
78
|
+
y.options = ["--output-dir", "yardoc"]
|
79
|
+
end
|
80
|
+
|
81
|
+
namespace :yardoc do
|
82
|
+
task :clobber do
|
83
|
+
rm_r "yardoc" rescue nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
task clobber: "yardoc:clobber"
|
88
|
+
|
89
|
+
|
90
|
+
desc "Open an irb session preloaded with this library"
|
91
|
+
task :console do
|
92
|
+
sh "irb -rubygems -I lib -r public_suffix.rb"
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
desc <<-DESC
|
97
|
+
Downloads the Public Suffix List file from the repository and stores it locally.
|
98
|
+
DESC
|
99
|
+
task :upddef do
|
100
|
+
require "net/http"
|
101
|
+
|
102
|
+
DEFINITION_URL = "https://publicsuffix.org/list/effective_tld_names.dat"
|
103
|
+
|
104
|
+
File.open("lib/definitions.txt", "w+") do |f|
|
105
|
+
response = Net::HTTP.get_response(URI.parse(DEFINITION_URL))
|
106
|
+
response.body
|
107
|
+
f.write(response.body)
|
108
|
+
end
|
109
|
+
end
|