Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use String#match? for speed in 'usable?' helper #210

Merged
merged 4 commits into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 9 additions & 32 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,19 @@
name: Ruby Unit Tests

on:
push:
branches:
- master
pull_request:
on: [push, pull_request]

jobs:
build:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [ '2.5', '2.6', '2.7' ]

name: Ruby ${{ matrix.ruby }}
ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', 'head']
continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-ruby@v1
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
- name: Cache gems
uses: actions/cache@v2
env:
cache-name: cache-gems
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install bundler
run: |
gem install bundler
- name: Set bundle config path
run: |
bundle config path vendor/bundle
- name: Install dependencies
run: |
bundle install
- name: Ruby Unit tests
run: |
bundle exec rspec
bundler-cache: true
- run: bundle exec rspec
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ rdoc
pkg
Gemfile.lock
*.gem
tmp/*

## PROJECT::SPECIFIC
.bundle/config
vendor/bundle/

.ruby-version
bin
2 changes: 1 addition & 1 deletion lib/video_info/providers/dailymotion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class VideoInfo
module Providers
class Dailymotion < Provider
def self.usable?(url)
url =~ /(dai(?:\.ly|lymotion\.com))/
url.match? /(dai(?:\.ly|lymotion\.com))/
end

def provider
Expand Down
2 changes: 1 addition & 1 deletion lib/video_info/providers/vimeo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(url, options = {})
end

def self.usable?(url)
url =~ %r{(vimeo\.com\/(?!album|hubnut\/album).*)}
url.match? /(vimeo\.com\/(?!album|hubnut\/album).*)/
end

def provider
Expand Down
2 changes: 1 addition & 1 deletion lib/video_info/providers/wistia.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class VideoInfo
module Providers
class Wistia < Provider
def self.usable?(url)
url =~ /(.*)(wistia.com|wistia.net|wi.st)/
url.match? /(.*)(wistia.com|wistia.net|wi.st)/
end

def provider
Expand Down
3 changes: 1 addition & 2 deletions lib/video_info/providers/youtube.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ def initialize(url, options = {})
end

def self.usable?(url)
url =~ %r{(youtube\.com\/(?!playlist|embed\/videoseries).*)|
(youtu\.be)}x
url.match? /(youtube\.com\/(?!playlist|embed\/videoseries).*)|(youtu\.be)/
end

def provider
Expand Down
3 changes: 1 addition & 2 deletions lib/video_info/providers/youtubeplaylist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def initialize(url, options = {})
end

def self.usable?(url)
url =~ %r{((youtube\.com)\/playlist)|
((youtube\.com)\/embed\/videoseries)}x
url.match? /((youtube\.com)\/playlist)|((youtube\.com)\/embed\/videoseries)/
end

def date
Expand Down
25 changes: 0 additions & 25 deletions tmp/rspec_guard_result

This file was deleted.