public_suffix 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle
2
+ .yardoc
3
+ pkg/*
4
+ yardoc
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - ruby-head
5
+ - ree
6
+ - jruby
7
+ - rbx
8
+ - rbx-2.0
9
+ notifications:
10
+ recipients:
11
+ - weppos@weppos.net
data/.yardopts ADDED
@@ -0,0 +1,2 @@
1
+ --readme README.rdoc
2
+ --title 'Ruby Public Suffix API Documentation'
data/CHANGELOG.md ADDED
@@ -0,0 +1,134 @@
1
+ # Changelog
2
+
3
+
4
+ ## Release 1.0.0.rc1
5
+
6
+ The library is now known as PublicSuffix.
7
+
8
+
9
+ ## Release 0.9.1
10
+
11
+ * CHANGED: Renamed PublicSuffixService::RuleList to PublicSuffixService::List.
12
+
13
+ * CHANGED: Renamed PublicSuffixService::List#list to PublicSuffixService::List#rules.
14
+
15
+ * CHANGED: Renamed PublicSuffixService to PublicSuffix.
16
+
17
+ * CHANGED: Updated definitions.
18
+
19
+
20
+ ## Release 0.9.0
21
+
22
+ * CHANGED: Minimum Ruby version increased to Ruby 1.8.7.
23
+
24
+ * CHANGED: rake/gempackagetask is deprecated. Use rubygems/package_task instead.
25
+
26
+
27
+ ## Release 0.8.4
28
+
29
+ * FIXED: Reverted bugfix for issue #12 for Ruby 1.8.6.
30
+ This is the latest version compatible with Ruby 1.8.6.
31
+
32
+
33
+ ## Release 0.8.3
34
+
35
+ * FIXED: Fixed ArgumentError: invalid byte sequence in US-ASCII with Ruby 1.9.2 (#12).
36
+
37
+ * CHANGED: Updated definitions (#11).
38
+
39
+ * CHANGED: Renamed definitions.txt to definitions.dat.
40
+
41
+
42
+ ## Release 0.8.2
43
+
44
+ * NEW: Added support for rubygems-test.
45
+
46
+ * CHANGED: Integrated Bundler.
47
+
48
+ * CHANGED: Updated definitions.
49
+
50
+
51
+ ## Release 0.8.1
52
+
53
+ * FIXED: The files in the release 0.8.0 have wrong permission 600 and can't be loaded (#10).
54
+
55
+
56
+ ## Release 0.8.0
57
+
58
+ * CHANGED: Update public suffix list to d1a5599b49fa 2010-10-25 15:10 +0100 (#9)
59
+
60
+ * NEW: Add support for Fully Qualified Domain Names (#7)
61
+
62
+
63
+ ## Release 0.7.0
64
+
65
+ * CHANGED: Using YARD to document the code instead of RDoc.
66
+
67
+ * FIXED: RuleList cache is not recreated when a new rule is appended to the list (#6)
68
+
69
+ * FIXED: PublicSuffixService.valid? should return false if the domain is not defined or not allowed (#4, #5)
70
+
71
+
72
+ ## Release 0.6.0
73
+
74
+ * NEW: PublicSuffixService.parse raises DomainNotAllowed when trying to parse a domain name
75
+ which exists, but is not allowed by the current definition list (#3)
76
+
77
+ PublicSuffixService.parse("nic.do")
78
+ # => PublicSuffixService::DomainNotAllowed
79
+
80
+ * CHANGED: Renamed PublicSuffixService::InvalidDomain to PublicSuffixService::DomainInvalid
81
+
82
+
83
+ ## Release 0.5.2
84
+
85
+ * CHANGED: Update public suffix list to 248ea690d671 2010-09-16 18:02 +0100
86
+
87
+
88
+ ## Release 0.5.1
89
+
90
+ * CHANGED: Update public suffix list to 14dc66dd53c1 2010-09-15 17:09 +0100
91
+
92
+
93
+ ## Release 0.5.0
94
+
95
+ * CHANGED: Improve documentation for Domain#domain and Domain#subdomain (#1).
96
+
97
+ * CHANGED: Performance improvements (#2).
98
+
99
+
100
+ ## Release 0.4.0
101
+
102
+ * CHANGED: Rename library from DomainName to PublicSuffixService to reduce the probability of name conflicts.
103
+
104
+
105
+ ## Release 0.3.1
106
+
107
+ * Deprecated DomainName library.
108
+
109
+
110
+ ## Release 0.3.0
111
+
112
+ * CHANGED: DomainName#domain and DomainName#subdomain are no longer alias of Domain#sld and Domain#tld.
113
+
114
+ * CHANGED: Removed DomainName#labels and decoupled Rule from DomainName.
115
+
116
+ * CHANGED: DomainName#valid? no longer instantiates new DomainName objects. This means less overhead.
117
+
118
+ * 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.
119
+
120
+
121
+ ## Release 0.2.0
122
+
123
+ * NEW: DomainName#valid?
124
+
125
+ * NEW: DomainName#parse and DomainName#parse!
126
+
127
+ * NEW: DomainName#valid_domain? and DomainName#valid_subdomain?
128
+
129
+ * CHANGED: Make sure RuleList lookup is only performed once.
130
+
131
+
132
+ ## Release 0.1.0
133
+
134
+ * Initial version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in whois.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ public_suffix (1.0.0.rc1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ metaclass (0.0.1)
10
+ mocha (0.10.0)
11
+ metaclass (~> 0.0.1)
12
+ rake (0.9.2)
13
+ yard (0.7.4)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ mocha
20
+ public_suffix!
21
+ rake
22
+ yard
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2009-2011 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.
data/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # Public Suffix List - Ruby implementation
2
+
3
+ *Public Suffix* 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/public_suffix_service.png)](http://travis-ci.org/weppos/public_suffix_service)
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 a real world example:
32
+ http://stackoverflow.com/questions/288810/get-the-subdomain-from-a-url
33
+
34
+
35
+ ## Requirements
36
+
37
+ * Ruby >= 1.8.7
38
+
39
+ *Public Suffix* >= 0.9.0 requires Ruby 1.8.7 or newer.
40
+ For older versions of Ruby, see the CHANGELOG.md file.
41
+
42
+ Successfully tested against the following interpreters:
43
+
44
+ * "Ruby":http://www.ruby-lang.org/ 1.8.x MRI
45
+ * "Ruby":http://www.ruby-lang.org/ 1.9.x MRI
46
+ * "Ruby Enterprise Edition":http://www.rubyenterpriseedition.com/
47
+ * "JRuby":http://jruby.org/
48
+ * "Rubinius":http://rubini.us/
49
+ * "MacRuby":http://www.macruby.org/
50
+
51
+
52
+ ## Installation
53
+
54
+ The best way to install *Public Suffix* is via [RubyGems](http://www.rubygems.org).
55
+
56
+ $ gem install public_suffix_service
57
+
58
+ You might need administrator privileges on your system to install the gem.
59
+
60
+
61
+ ## Basic Usage
62
+
63
+ Example domain without subdomains.
64
+
65
+ domain = PublicSuffix.parse("google.com")
66
+ # => #<PublicSuffix::Domain>
67
+ domain.tld
68
+ # => "com"
69
+ domain.sld
70
+ # => "google"
71
+ domain.trd
72
+ # => nil
73
+ domain.domain
74
+ # => "google.com"
75
+ domain.subdomain
76
+ # => nil
77
+
78
+ Example domain with subdomains.
79
+
80
+ domain = PublicSuffix.parse("www.google.com")
81
+ # => #<PublicSuffix::Domain>
82
+ domain.tld
83
+ # => "com"
84
+ domain.sld
85
+ # => "google"
86
+ domain.trd
87
+ # => "www"
88
+ domain.domain
89
+ # => "google.com"
90
+ domain.subdomain
91
+ # => "google.com"
92
+
93
+ Simple validation example.
94
+
95
+ PublicSuffix.valid?("google.com")
96
+ # => true
97
+
98
+ PublicSuffix.valid?("www.google.com")
99
+ # => true
100
+
101
+ PublicSuffix.valid?("x.yz")
102
+ # => false
103
+
104
+ ## Fully Qualified Domain Names
105
+
106
+ This library automatically recognizes Fully Qualified Domain Names. A FQDN is a domain name that end with a trailing dot.
107
+
108
+ # Parse a standard domain name
109
+ domain = PublicSuffix.parse("www.google.com")
110
+ # => #<PublicSuffix::Domain>
111
+ domain.tld
112
+ # => "com"
113
+
114
+ # Parse a fully qualified domain name
115
+ domain = PublicSuffix.parse("www.google.com.")
116
+ # => #<PublicSuffix::Domain>
117
+ domain.tld
118
+ # => "com"
119
+
120
+
121
+ ## Credits
122
+
123
+ * **Author:** [Simone Carletti](http://www.simonecarletti.com/)
124
+
125
+
126
+ ## FeedBack and Bug reports
127
+
128
+ If you use this library and find yourself missing any functionality, please [let me know](mailto:weppos@weppos.net).
129
+
130
+ Pull requests are very welcome! Please include spec and/or feature coverage for every patch, and create a topic branch for every separate change you make.
131
+
132
+ Report issues or feature requests to [GitHub Issues](https://github.com/weppos/public_suffix_service/issues).
133
+
134
+
135
+ ## More
136
+
137
+ * [Homepage](http://www.simonecarletti.com/code/public_suffix_service)
138
+ * [Repository](https://github.com/weppos/public_suffix_service)
139
+ * [API Documentation](http://rubydoc.info/gems/public_suffix_service)
140
+ * [Introducing the Public Suffix List library for Ruby](http://www.simonecarletti.com/blog/2010/06/public-suffix-list-library-for-ruby/)
141
+
142
+
143
+ ## Changelog
144
+
145
+ See the CHANGELOG.md file for details.
146
+
147
+
148
+ ## License
149
+
150
+ *Public Suffix* is copyright (c) 2009-2011 Simone Carletti.
151
+ This is Free Software distributed under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,109 @@
1
+ require 'rubygems'
2
+ require 'rubygems/package_task'
3
+ require 'bundler'
4
+ require 'rake/testtask'
5
+
6
+ $:.unshift(File.dirname(__FILE__) + "/lib")
7
+ require 'public_suffix'
8
+
9
+
10
+ # Common package properties
11
+ PKG_NAME = ENV['PKG_NAME'] || PublicSuffix::GEM
12
+ PKG_VERSION = ENV['PKG_VERSION'] || PublicSuffix::VERSION
13
+ RUBYFORGE_PROJECT = nil
14
+
15
+
16
+ # Run test by default.
17
+ task :default => :test
18
+
19
+
20
+ spec = Gem::Specification.new do |s|
21
+ s.name = PKG_NAME
22
+ s.version = PKG_VERSION
23
+ s.summary = "Domain name parser based in the Public Suffix List."
24
+ s.description = "PublicSuffix can parse and decompose a domain name into top level domain, domain and subdomains."
25
+
26
+ s.required_ruby_version = ">= 1.8.7"
27
+
28
+ s.author = "Simone Carletti"
29
+ s.email = "weppos@weppos.net"
30
+ s.homepage = "http://www.simonecarletti.com/code/public_suffix_service"
31
+
32
+ # Add any extra files to include in the gem (like your README)
33
+ s.files = `git ls-files`.split("\n")
34
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
35
+ s.require_paths = %w( lib )
36
+
37
+ # If your tests use any gems, include them here
38
+ s.add_development_dependency("rake")
39
+ s.add_development_dependency("mocha")
40
+ s.add_development_dependency("yard")
41
+ end
42
+
43
+ Gem::PackageTask.new(spec) do |pkg|
44
+ pkg.gem_spec = spec
45
+ end
46
+
47
+ desc "Build the gemspec file #{spec.name}.gemspec"
48
+ task :gemspec do
49
+ file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
50
+ File.open(file, "w") {|f| f << spec.to_ruby }
51
+ end
52
+
53
+ desc "Remove any temporary products, including gemspec"
54
+ task :clean => [:clobber] do
55
+ rm "#{spec.name}.gemspec" if File.file?("#{spec.name}.gemspec")
56
+ end
57
+
58
+ desc "Remove any generated file"
59
+ task :clobber => [:clobber_package]
60
+
61
+ desc "Package the library and generates the gemspec"
62
+ task :package => [:gemspec]
63
+
64
+
65
+ # Run all the tests in the /test folder
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 \
98
+ and stores it locally.
99
+ DESC
100
+ task :download_definitions do
101
+ require "net/http"
102
+
103
+ DEFINITION_URL = "http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1"
104
+
105
+ File.open("lib/public_suffix/definitions.txt", "w+") do |f|
106
+ response = Net::HTTP.get_response(URI.parse(DEFINITION_URL))
107
+ f.write(response.body)
108
+ end
109
+ end