Skip to content

Commit

Permalink
Merge pull request #2 from seomoz/master
Browse files Browse the repository at this point in the history
Merging moz to master branch
  • Loading branch information
abhishekk1903 authored Apr 2, 2024
2 parents 0e123d7 + 185a93d commit f9355f7
Show file tree
Hide file tree
Showing 50 changed files with 18,006 additions and 11,398 deletions.
Empty file removed .gemtest
Empty file.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [weppos]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: "rubygems/public_suffix"
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with a single custom sponsorship URL
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: bundler
directory: "/"
schedule:
interval: daily
time: "04:00"
open-pull-requests-limit: 10
labels:
- dependencies

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "04:00"
open-pull-requests-limit: 10
labels:
- dependencies
38 changes: 38 additions & 0 deletions .github/workflows/psl-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PSL Update

on:
workflow_dispatch:
schedule:
- cron: '40 6 * * *'

jobs:
update:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
bundler-cache: true

- name: Update PSL
run: bundle exec rake update-list

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
title: PSL auto-update
commit-message: Updated list from source
reviewers: weppos
add-paths: |
data/list.txt
- name: Check Pull Request
if: ${{ steps.cpr.outputs.pull-request-number }}
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- v*.*.*

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Release Gem
uses: cadwallion/publish-rubygems-action@94a6f4cd5350581749c569b5001eecc864e3ad0b
env:
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
RELEASE_COMMAND: rake release
31 changes: 31 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Tests

on:
push:
pull_request:
workflow_dispatch:

jobs:
test:
strategy:
matrix:
ruby-version:
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- "3.2"
- "3.3"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true
- name: Rubocop
run: bundle exec rake rubocop
- name: Run tests
run: bundle exec rake test
13 changes: 5 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
# Bundler
.bundle
Gemfile.lock
pkg/*

# Rubinius
*.rbc
/.bundle
/Gemfile.lock
/pkg/*

# YARD
.yardoc
yardoc/
/.yardoc
/yardoc/
37 changes: 37 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
inherit_from:
- .rubocop_opinionated.yml

AllCops:
Exclude:
# Exclude .gemspec files because they are generally auto-generated
- '*.gemspec'
# Exclude vendored folders
- 'tmp/**/*'
- 'vendor/**/*'
# Exclude artifacts
- 'pkg/**/*'
# Other
- 'test/benchmarks/**/*'
- 'test/profilers/**/*'
TargetRubyVersion: 2.6

# I often use @_variable to avoid clashing.
Naming/MemoizedInstanceVariableName:
Enabled: false

Style/ClassAndModuleChildren:
Exclude:
- 'spec/**/*_spec.rb'
- 'test/**/*_test.rb'

# Dear Rubocop, I don't want to use String#strip_heredoc
Layout/HeredocIndentation:
Enabled: false

Style/WordArray:
Enabled: false
MinSize: 3

Style/SymbolArray:
Enabled: false
MinSize: 3
135 changes: 135 additions & 0 deletions .rubocop_opinionated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
AllCops:
Exclude:
# Exclude .gemspec files because they are generally auto-generated
- '*.gemspec'
# Exclude vendored folders
- 'tmp/**/*'
- 'vendor/**/*'
NewCops: enable

# [codesmell]
Layout/LineLength:
Enabled: false
Exclude:
- 'spec/**/*_spec.rb'
- 'test/**/*_test.rb'
Max: 100

# [codesmell]
Metrics/AbcSize:
Enabled: false
Exclude:
- 'spec/**/*_spec.rb'
- 'test/**/*_test.rb'

# [codesmell]
Metrics/BlockLength:
Enabled: false

# [codesmell]
Metrics/CyclomaticComplexity:
Enabled: false
Exclude:
- 'spec/**/*_spec.rb'
- 'test/**/*_test.rb'

# [codesmell]
Metrics/ClassLength:
Enabled: false
Exclude:
- 'spec/**/*_spec.rb'
- 'test/**/*_test.rb'

# [codesmell]
Metrics/MethodLength:
Enabled: false
Exclude:
- 'spec/**/*_spec.rb'
- 'test/**/*_test.rb'
Max: 10

# [codesmell]
Metrics/ModuleLength:
Enabled: false
Exclude:
- 'spec/**/*_spec.rb'
- 'test/**/*_test.rb'

# [codesmell]
Metrics/ParameterLists:
Enabled: false
Max: 5

# [codesmell]
Metrics/PerceivedComplexity:
Enabled: false

# Do not use "and" or "or" in conditionals, but for readability we can use it
# to chain executions. Just beware of operator order.
Style/AndOr:
EnforcedStyle: conditionals

Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'

# Double empty lines are useful to separate conceptually different methods
# in the same class or module.
Layout/EmptyLines:
Enabled: false

# In most cases, a space is nice. Sometimes, it's not.
# Just be consistent with the rest of the surrounding code.
Layout/EmptyLinesAroundClassBody:
Enabled: false

# In most cases, a space is nice. Sometimes, it's not.
# Just be consistent with the rest of the surrounding code.
Layout/EmptyLinesAroundModuleBody:
Enabled: false

# This is quite buggy, as it doesn't recognize double lines.
# Double empty lines are useful to separate conceptually different methods
# in the same class or module.
Layout/EmptyLineBetweenDefs:
Enabled: false

# Annotated tokens (like %<foo>s) are a good thing, but in most cases we don't need them.
# %s is a simpler and straightforward version that works in almost all cases. So don't complain.
Style/FormatStringToken:
Enabled: false

# unless is not always cool.
Style/NegatedIf:
Enabled: false

# There are cases were the inline rescue is ok. We can either downgrade the severity,
# or rely on the developer judgement on a case-by-case basis.
Style/RescueModifier:
Enabled: false

Style/SymbolArray:
EnforcedStyle: brackets

# Hate It or Love It, I prefer double quotes as this is more consistent
# with several other programming languages and the output of puts and inspect.
Style/StringLiterals:
EnforcedStyle: double_quotes

# It's nice to be consistent. The trailing comma also allows easy reordering,
# and doesn't cause a diff in Git when you add a line to the bottom.
Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: consistent_comma
Style/TrailingCommaInHashLiteral:
EnforcedStyleForMultiline: consistent_comma

Style/TrivialAccessors:
# IgnoreClassMethods because I want to be able to define class-level accessors
# that sets an instance variable on the metaclass, such as:
#
# def self.default=(value)
# @default = value
# end
#
IgnoreClassMethods: true
1 change: 0 additions & 1 deletion .ruby-gemset

This file was deleted.

19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

52 changes: 52 additions & 0 deletions 2.0-Upgrade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Welcome to PublicSuffix 2.0!

PublicSuffix 2.0 contains a rewritten internal representation and comparison logic, that drastically increases the lookup performance. The new version also changes several internal and external API.

This document documents the most relevant changes to help you upgrading from PublicSuffix 1.0 to 2.0.

## What's New

- The library is now 100% compliants with the official PublicSuffix tests. The major breaking change you may experience, is that if a domain passed as input doesn't match any rule, the rule `*` is assumed. You can override this behavior by passing a custom default rule with the `default_rule` option. The old behavior can be restored by passing `default_rule: nil`.
- `PublicSuffix.domain` is a new method that parses the input and returns the domain (combination of second level domain + suffix). This is a convenient helper to parse a domain name, for example when you need to determine the cookie or SSL scope.
- Added the ability to disable the use of private domains either at runtime, in addition to the ability to not load the private domains section when reading the list (`private_domains: false`). This feature also superseded the `private_domains` class-level attribute, that is no longer available.

## Upgrade

When upgrading, here's the most relevant changes to keep an eye on:

- Several futile utility helpers were removed, such as `Domain#rule`, `Domain#is_a_domain?`, `Domain#is_a_subdomain?`, `Domain#valid?`. You can easily obtain the same result by having a custom method that reconstructs the logic, and/or calling `PublicSuffix.{domain|parse}(domain.to_s)`.
- `PublicSuffix::List.private_domains` is no longer available. Instead, you now have two ways to enable/disable the private domains:

1. At runtime, by using the `ignore_private` option

```ruby
PublicSuffix.domain("something.blogspot.com", ignore_private: true)
```

1. Loading a filtered list:

```ruby
# Disable support for private TLDs
PublicSuffix::List.default = PublicSuffix::List.parse(File.read(PublicSuffix::List::DEFAULT_LIST_PATH), private_domains: false)
# => "blogspot.com"
PublicSuffix.domain("something.blogspot.com")
# => "blogspot.com"
```
- Now that the library is 100% compliant with the official PublicSuffix algorithm, if a domain passed as input doesn't match any rule, the wildcard rule `*` is assumed. This means that unlisted TLDs will be considered valid by default, when they would have been invalid in 1.x. However, you can override this behavior to emulate the 1.x behavior if needed:
```ruby
# 1.x:
PublicSuffix.valid?("google.commm")
# => false
# 2.x:
PublicSuffix.valid?("google.commm")
# => true
# Overriding 2.x behavior if needed:
PublicSuffix.valid?("google.commm", default_rule: nil)
# => false
````
Loading

0 comments on commit f9355f7

Please sign in to comment.