yt-url 0.0.0 → 1.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +11 -0
- data/LICENSE.txt +2 -2
- data/README.md +95 -0
- data/Rakefile +11 -0
- data/bin/yt-url +22 -0
- data/lib/yt/url.rb +98 -3
- data/lib/yt/url/version.rb +4 -2
- data/spec/id_spec.rb +95 -0
- data/spec/kind_spec.rb +35 -0
- data/spec/resource_spec.rb +48 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/support/server.rb +17 -0
- data/yt-url.gemspec +7 -6
- metadata +69 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 739b0b8d6c91fc1762f33f0b0323c7c4909b71fb
|
4
|
+
data.tar.gz: 98637af9de0e03bde5c6257da8e65a2542fb25ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 189cdefce9251aa7c49a8e843d5f3eaa79b614c52a49942fbc898b59d043a47a8cdcf486c4b27e2f32ee3733b7e20cfc619ef2d2ce54f859c23669631871eb85
|
7
|
+
data.tar.gz: 6341364c63066cfeb5041395f7b9be342add569a3dbdda5134497d2011ed5b2ce9af97c1374b82ce558361c3ab562fd23c27571c8927e22f1a945d8c5712b238
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
For more information about changelogs, check
|
6
|
+
[Keep a Changelog](http://keepachangelog.com) and
|
7
|
+
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
|
+
|
9
|
+
## 1.0.0.beta1 - 2017-02-26
|
10
|
+
|
11
|
+
* [FEATURE] Extracted Yt::URL module from Yt
|
data/LICENSE.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2016 Fullscreen, Inc.
|
4
|
-
|
3
|
+
Copyright (c) 2016–present Fullscreen, Inc.
|
4
|
+
-–—
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
7
7
|
in the Software without restriction, including without limitation the rights
|
data/README.md
CHANGED
@@ -1,3 +1,98 @@
|
|
1
1
|
Yt::URL - a URL extension for the Yt library
|
2
2
|
============================================
|
3
3
|
|
4
|
+
Yt::URL helps you identify YouTube resources from their URL.
|
5
|
+
|
6
|
+
The **source code** is available on [GitHub](https://github.com/claudiob/yt-url) and the **documentation** on [RubyDoc](http://www.rubydoc.info/gems/yt-url/frames).
|
7
|
+
|
8
|
+
[](https://travis-ci.org/claudiob/yt-url)
|
9
|
+
[](https://coveralls.io/r/claudiob/yt-url)
|
10
|
+
[](https://gemnasium.com/claudiob/yt-url)
|
11
|
+
[](https://codeclimate.com/github/claudiob/yt-url)
|
12
|
+
[](http://www.rubydoc.info/gems/yt-url/frames)
|
13
|
+
[](http://rubygems.org/gems/yt-url)
|
14
|
+
|
15
|
+
After [registering your app](https://claudiob.github.io/yt), you can run commands like:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
url = Yt::URL.new "youtu.be/gknzFj_0vvY"
|
19
|
+
url.kind # => :video
|
20
|
+
url.id # => "gknzFj_0vvY"
|
21
|
+
url.resource # => #<Yt::Video @id=gknzFj_0vvY>
|
22
|
+
```
|
23
|
+
|
24
|
+
The **full documentation** is available at [rubydoc.info](http://www.rubydoc.info/gems/yt-url/frames).
|
25
|
+
|
26
|
+
|
27
|
+
A comprehensive guide to Yt
|
28
|
+
===========================
|
29
|
+
|
30
|
+
All the classes and methods available are detailed on the [Yt homepage](https://claudiob.github.io/yt/):
|
31
|
+
|
32
|
+
[](https://claudiob.github.io/yt/)
|
33
|
+
|
34
|
+
Please proceed to [https://claudiob.github.io/yt/urls.html](https://claudiob.github.io/yt/urls.html) for more details and examples.
|
35
|
+
|
36
|
+
|
37
|
+
How to install
|
38
|
+
==============
|
39
|
+
|
40
|
+
To install on your system, run
|
41
|
+
|
42
|
+
gem install yt-url
|
43
|
+
|
44
|
+
To use inside a bundled Ruby project, add this line to the Gemfile:
|
45
|
+
|
46
|
+
gem 'yt-url', '~> 0.0.0'
|
47
|
+
|
48
|
+
Since the gem follows [Semantic Versioning](http://semver.org),
|
49
|
+
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
50
|
+
guarantees that your project won’t occur in any error when you `bundle update`
|
51
|
+
and a new version of Yt is released.
|
52
|
+
|
53
|
+
How to test
|
54
|
+
===========
|
55
|
+
|
56
|
+
To run live-tests against the YouTube API, type:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
rspec
|
60
|
+
```
|
61
|
+
|
62
|
+
This will fail unless you have set up a test YouTube application and some
|
63
|
+
tests YouTube accounts to hit the API. If you cannot run tests locally, you
|
64
|
+
can open PR against the repo and Travis CI will run the tests for you.
|
65
|
+
|
66
|
+
These are the environment variables required to run the tests in `spec/requests/server`:
|
67
|
+
|
68
|
+
- `YT_SERVER_API_KEY`: API Key of a Google app with access to the YouTube Data API v3 and the YouTube Analytics API
|
69
|
+
|
70
|
+
No environment variables are required to run the other tests.
|
71
|
+
|
72
|
+
How to release new versions
|
73
|
+
===========================
|
74
|
+
|
75
|
+
If you are a manager of this project, remember to upgrade the [Yt gem](http://rubygems.org/gems/yt-url)
|
76
|
+
whenever a new feature is added or a bug gets fixed.
|
77
|
+
|
78
|
+
Make sure all the tests are passing on [Travis CI](https://travis-ci.org/claudiob/yt-url),
|
79
|
+
document the changes in HISTORY.md and README.md, bump the version, then run
|
80
|
+
|
81
|
+
rake release
|
82
|
+
|
83
|
+
Remember that the yt gem follows [Semantic Versioning](http://semver.org).
|
84
|
+
Any new release that is fully backward-compatible should bump the *patch* version (0.0.x).
|
85
|
+
Any new version that breaks compatibility should bump the *minor* version (0.x.0)
|
86
|
+
|
87
|
+
How to contribute
|
88
|
+
=================
|
89
|
+
|
90
|
+
Contribute to the code by forking the project, adding the missing code,
|
91
|
+
writing the appropriate tests and submitting a pull request.
|
92
|
+
|
93
|
+
In order for a PR to be approved, all the tests need to pass and all the public
|
94
|
+
methods need to be documented and listed in the guides. Remember:
|
95
|
+
|
96
|
+
- to run all tests locally: `bundle exec rspec`
|
97
|
+
- to generate the docs locally: `bundle exec yard`
|
98
|
+
- to list undocumented methods: `bundle exec yard stats --no-doc`
|
data/Rakefile
ADDED
data/bin/yt-url
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# @example bundle exec bin/yt-url "HBO,trueblood"
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'yt/url'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'yt/url'
|
9
|
+
end
|
10
|
+
|
11
|
+
Yt.configuration.api_key = ENV['YT_SERVER_API_KEY']
|
12
|
+
|
13
|
+
puts "id\tchannel"
|
14
|
+
ARGV[0].split(',').each do |text|
|
15
|
+
url = Yt::URL.new text
|
16
|
+
id = begin
|
17
|
+
url.id
|
18
|
+
rescue Yt::Errors::NoItems
|
19
|
+
'?' * 24
|
20
|
+
end
|
21
|
+
puts "#{id}\t#{text}"
|
22
|
+
end
|
data/lib/yt/url.rb
CHANGED
@@ -1,7 +1,102 @@
|
|
1
|
-
require
|
1
|
+
require 'yt'
|
2
2
|
|
3
|
+
# An object-oriented Ruby client for YouTube.
|
4
|
+
# @see http://www.rubydoc.info/gems/yt/
|
3
5
|
module Yt
|
4
|
-
|
5
|
-
|
6
|
+
# Provides methods to identify YouTube resources from names or URLs.
|
7
|
+
# @see https://developers.google.com/youtube/v3/docs
|
8
|
+
# @example Identify a YouTube video from its short URL:
|
9
|
+
# url = Yt::URL.new 'youtu.be/kawaiiguy'
|
10
|
+
# url.id # => 'UC4lU5YG9QDgs0X2jdnt7cdQ'
|
11
|
+
# url.resource # => #<Yt::Channel @id=UC4lU5YG9QDgs0X2jdnt7cdQ>
|
12
|
+
class URL
|
13
|
+
# @param [String] text the name or URL of a YouTube resource (in any form).
|
14
|
+
def initialize(text)
|
15
|
+
@text = text.to_s.strip
|
16
|
+
@match = find_pattern_match
|
17
|
+
end
|
18
|
+
|
19
|
+
### PATTERN MATCHING
|
20
|
+
|
21
|
+
# @return [Symbol] the kind of YouTube resource matching the URL.
|
22
|
+
# Possible values are: +:playlist+, +:video+, +:channel+, and +:unknown:.
|
23
|
+
def kind
|
24
|
+
@match[:kind]
|
25
|
+
end
|
26
|
+
|
27
|
+
# @return [<String, nil>] the ID of the YouTube resource matching the URL.
|
28
|
+
def id
|
29
|
+
@match[:id] ||= fetch_id
|
30
|
+
end
|
31
|
+
|
32
|
+
# @return [<Yt::Channel>] the resource associated with the URL
|
33
|
+
def resource(options = {})
|
34
|
+
@resource ||= case kind
|
35
|
+
when :channel then Yt::Channel
|
36
|
+
when :video then Yt::Video
|
37
|
+
when :playlist then Yt::Playlist
|
38
|
+
else raise Yt::Errors::NoItems
|
39
|
+
end.new options.merge(id: id)
|
40
|
+
end
|
41
|
+
|
42
|
+
# @return [Array<Regexp>] patterns matching URLs of YouTube playlists.
|
43
|
+
PLAYLIST_PATTERNS = [
|
44
|
+
%r{^(?:https?://)?(?:www\.)?youtube\.com/playlist/?\?list=(?<id>[a-zA-Z0-9_-]+)},
|
45
|
+
]
|
46
|
+
|
47
|
+
# @return [Array<Regexp>] patterns matching URLs of YouTube videos.
|
48
|
+
VIDEO_PATTERNS = [
|
49
|
+
%r{^(?:https?://)?(?:www\.)?youtube\.com/watch\?v=(?<id>[a-zA-Z0-9_-]{11})},
|
50
|
+
%r{^(?:https?://)?(?:www\.)?youtu\.be/(?<id>[a-zA-Z0-9_-]{11})},
|
51
|
+
%r{^(?:https?://)?(?:www\.)?youtube\.com/embed/(?<id>[a-zA-Z0-9_-]{11})},
|
52
|
+
%r{^(?:https?://)?(?:www\.)?youtube\.com/v/(?<id>[a-zA-Z0-9_-]{11})},
|
53
|
+
]
|
54
|
+
|
55
|
+
# @return [Array<Regexp>] patterns matching URLs of YouTube channels.
|
56
|
+
CHANNEL_PATTERNS = [
|
57
|
+
%r{^(?:https?://)?(?:www\.)?youtube\.com/channel/(?<id>UC[a-zA-Z0-9_-]{22})},
|
58
|
+
%r{^(?:https?://)?(?:www\.)?youtube\.com/(?<format>c/|user/)?(?<name>[a-zA-Z0-9_-]+)}
|
59
|
+
]
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
### PATTERN MATCHING
|
64
|
+
|
65
|
+
def find_pattern_match
|
66
|
+
patterns.find(-> {{kind: :unknown}}) do |kind, regex|
|
67
|
+
if data = @text.match(regex)
|
68
|
+
# Note: With Ruby 2.4, the following is data.named_captures
|
69
|
+
match = data.names.zip(data.captures).to_h.with_indifferent_access
|
70
|
+
break match.merge kind: kind
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def patterns
|
76
|
+
# @note: :channel *must* be the last since one of its regex eats the
|
77
|
+
# remaining patterns. In short, don't change the following order.
|
78
|
+
Enumerator.new do |patterns|
|
79
|
+
VIDEO_PATTERNS.each {|regex| patterns << [:video, regex]}
|
80
|
+
PLAYLIST_PATTERNS.each {|regex| patterns << [:playlist, regex]}
|
81
|
+
CHANNEL_PATTERNS.each {|regex| patterns << [:channel, regex]}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def fetch_id
|
86
|
+
response = Net::HTTP.start 'www.youtube.com', 443, use_ssl: true do |http|
|
87
|
+
http.request Net::HTTP::Get.new("/#{@match[:format]}#{@match[:name]}")
|
88
|
+
end
|
89
|
+
if response.is_a?(Net::HTTPRedirection)
|
90
|
+
response = Net::HTTP.start 'www.youtube.com', 443, use_ssl: true do |http|
|
91
|
+
http.request Net::HTTP::Get.new(response['location'])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
regex = %r{<meta itemprop="channelId" content="(?<id>UC[a-zA-Z0-9_-]{22})">}
|
95
|
+
if data = response.body.match(regex)
|
96
|
+
data[:id]
|
97
|
+
else
|
98
|
+
raise Yt::Errors::NoItems
|
99
|
+
end
|
100
|
+
end
|
6
101
|
end
|
7
102
|
end
|
data/lib/yt/url/version.rb
CHANGED
data/spec/id_spec.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Yt::URL#id' do
|
4
|
+
subject(:url) { Yt::URL.new text }
|
5
|
+
|
6
|
+
context 'given a YouTube channel URL in the ID form' do
|
7
|
+
let(:text) { "https://www.youtube.com/channel/#{id}" }
|
8
|
+
|
9
|
+
describe 'works with existing channels' do
|
10
|
+
let(:id) { 'UC4lU5YG9QDgs0X2jdnt7cdQ' }
|
11
|
+
it {expect(url.id).to eq id }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'works with unknown channels' do
|
15
|
+
let(:id) { 'UC-not-an-actual-channel' }
|
16
|
+
it {expect(url.id).to eq id }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'given a YouTube channel URL in the name form' do
|
21
|
+
let(:text) { "http://www.youtube.com/#{name}" }
|
22
|
+
|
23
|
+
describe 'works when the name matches the custom URL' do
|
24
|
+
let(:name) { 'nbcsports' }
|
25
|
+
it {expect(url.id).to eq 'UCqZQlzSHbVJrwrn5XvzrzcA' }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'works when the name matches the username' do
|
29
|
+
let(:name) { '2012NBCOlympics' }
|
30
|
+
it {expect(url.id).to eq 'UCqZQlzSHbVJrwrn5XvzrzcA' }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe 'fails with unknown channels' do
|
34
|
+
let(:name) { 'not-an-actual-channel' }
|
35
|
+
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'given a YouTube channel URL in the custom form' do
|
40
|
+
let(:text) { "https://youtube.com/c/#{name}" }
|
41
|
+
|
42
|
+
describe 'works with existing channels' do
|
43
|
+
let(:name) { 'ogeeku' }
|
44
|
+
it {expect(url.id).to eq 'UC4nG_NxJniKoB-n6TLT2yaw' }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'fails with unknown channels' do
|
48
|
+
let(:name) { 'not-an-actual-channel' }
|
49
|
+
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'given a YouTube channel URL in the username form' do
|
54
|
+
let(:text) { "youtube.com/user/#{name}" }
|
55
|
+
|
56
|
+
describe 'works with existing channels' do
|
57
|
+
let(:name) { 'ogeeku' }
|
58
|
+
it {expect(url.id).to eq 'UC4lU5YG9QDgs0X2jdnt7cdQ' }
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'fails with unknown channels' do
|
62
|
+
let(:name) { 'not-an-actual-channel' }
|
63
|
+
it {expect{url.id}.to raise_error Yt::Errors::NoItems }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'given a YouTube video URL' do
|
68
|
+
let(:text) { "https://www.youtube.com/watch?v=#{id}" }
|
69
|
+
|
70
|
+
describe 'works with existing videos' do
|
71
|
+
let(:id) { 'gknzFj_0vvY' }
|
72
|
+
it {expect(url.id).to eq id }
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'works with unknown videos' do
|
76
|
+
let(:id) { 'abc123abc12' }
|
77
|
+
it {expect(url.id).to eq id }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'given a YouTube playlist URL' do
|
82
|
+
let(:text) { "https://www.youtube.com/playlist?list=#{id}" }
|
83
|
+
|
84
|
+
describe 'works with existing playlists' do
|
85
|
+
let(:id) { 'LLxO1tY8h1AhOz0T4ENwmpow' }
|
86
|
+
it {expect(url.id).to eq id }
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'works with unknown playlists' do
|
90
|
+
let(:id) { 'PL12--not-a-playlist' }
|
91
|
+
it {expect(url.id).to eq id }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
data/spec/kind_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Yt::URL#kind' do
|
4
|
+
subject(:url) { Yt::URL.new text }
|
5
|
+
|
6
|
+
context 'given an existing YouTube channel' do
|
7
|
+
let(:text) { 'youtube.com/channel/UCxO1tY8h1AhOz0T4ENwmpow' }
|
8
|
+
it {expect(url.kind).to eq :channel }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'given an existing YouTube video' do
|
12
|
+
let(:text) { 'youtube.com/watch?v=gknzFj_0vvY' }
|
13
|
+
it {expect(url.kind).to eq :video }
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'given an existing YouTube playlist' do
|
17
|
+
let(:text) { 'youtube.com/playlist?list=LLxO1tY8h1AhOz0T4ENwmpow' }
|
18
|
+
it {expect(url.kind).to eq :playlist }
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'given an unknown YouTube channel URL' do
|
22
|
+
let(:text) { 'youtube.com/channel/UC-too-short-to-be-an-id' }
|
23
|
+
it {expect(url.kind).to eq :channel }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'given an unknown YouTube video URL' do
|
27
|
+
let(:text) { 'youtu.be/not-an-id' }
|
28
|
+
it {expect(url.kind).to eq :unknown }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'given an unknown text' do
|
32
|
+
let(:text) { 'not-really-anything---' }
|
33
|
+
it {expect(url.kind).to eq :unknown }
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Yt::URL#resource', :server do
|
4
|
+
subject(:url) { Yt::URL.new text }
|
5
|
+
|
6
|
+
context 'given an existing YouTube channel URL' do
|
7
|
+
let(:text) { "youtube.com/channel/#{$existing_channel_id}" }
|
8
|
+
|
9
|
+
it {expect(url.resource).to be_a Yt::Channel }
|
10
|
+
it {expect(url.resource.title).to be }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'given an existing YouTube video URL' do
|
14
|
+
let(:text) { "youtube.com/watch?v=#{$existing_video_id}" }
|
15
|
+
|
16
|
+
it {expect(url.resource).to be_a Yt::Video }
|
17
|
+
it {expect(url.resource.title).to be }
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'given an unknown YouTube video URL' do
|
21
|
+
let(:text) { "youtu.be/#{$unknown_video_id}" }
|
22
|
+
|
23
|
+
it {expect(url.resource).to be_a Yt::Video }
|
24
|
+
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'given an existing YouTube playlist URL' do
|
28
|
+
let(:text) { "youtube.com/playlist?list=#{$existing_playlist_id}" }
|
29
|
+
|
30
|
+
it {expect(url.resource).to be_a Yt::Playlist }
|
31
|
+
it {expect(url.resource.title).to be }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'given an unknown YouTube playlist URL' do
|
35
|
+
let(:text) { "https://www.youtube.com/playlist?list=#{$unknown_playlist_id}" }
|
36
|
+
|
37
|
+
it {expect(url.resource).to be_a Yt::Playlist }
|
38
|
+
it {expect{url.resource.title}.to raise_error Yt::Errors::NoItems }
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'given an unknown text' do
|
42
|
+
let(:text) { $unknown_text }
|
43
|
+
|
44
|
+
it {expect{url.resource}.to raise_error Yt::Errors::NoItems }
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new [
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
8
|
+
SimpleCov.start
|
9
|
+
|
10
|
+
require 'yt/url'
|
11
|
+
Dir['./spec/support/**/*.rb'].each {|f| require f}
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.order = 'random'
|
15
|
+
config.run_all_when_everything_filtered = false
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.before :all, server: true do
|
3
|
+
Yt.configuration.api_key = ENV['YT_SERVER_API_KEY']
|
4
|
+
Yt.configuration.client_id = ''
|
5
|
+
Yt.configuration.client_secret = ''
|
6
|
+
end
|
7
|
+
|
8
|
+
$existing_channel_id = 'UCxO1tY8h1AhOz0T4ENwmpow'
|
9
|
+
|
10
|
+
$existing_video_id = 'gknzFj_0vvY'
|
11
|
+
$unknown_video_id = 'invalid-id-'
|
12
|
+
|
13
|
+
$existing_playlist_id = 'PL-LeTutc9GRKD3yBDhnRF_yE8UTaQI5Jf'
|
14
|
+
$unknown_playlist_id = 'invalid-id-'
|
15
|
+
|
16
|
+
$unknown_text = 'not-really-anything---'
|
17
|
+
end
|
data/yt-url.gemspec
CHANGED
@@ -5,10 +5,10 @@ require 'yt/url/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "yt-url"
|
8
|
-
spec.version = Yt::
|
8
|
+
spec.version = Yt::URL::VERSION
|
9
9
|
spec.authors = ['Claudio Baccigalupo']
|
10
10
|
spec.email = ['claudio@fullscreen.net']
|
11
|
-
spec.description = %q{URL Extension for the
|
11
|
+
spec.description = %q{URL Extension for the Yt library.}
|
12
12
|
spec.summary = %q{Yt::URL helps identify which YouTube resource (video,
|
13
13
|
channel, playlist) matches a YouTube URL in any given form.}
|
14
14
|
spec.homepage = 'http://github.com/claudiob/yt-url'
|
@@ -16,17 +16,18 @@ Gem::Specification.new do |spec|
|
|
16
16
|
|
17
17
|
spec.required_ruby_version = '>= 2.2.2'
|
18
18
|
|
19
|
-
spec.files = `git ls-files
|
20
|
-
f.match(%r{^(test|spec|features)/})
|
21
|
-
end
|
19
|
+
spec.files = `git ls-files`.split($/)
|
22
20
|
spec.bindir = 'exe'
|
23
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
23
|
spec.require_paths = ['lib']
|
25
24
|
|
26
|
-
|
25
|
+
spec.add_dependency 'activesupport', '>= 5', '< 6'
|
26
|
+
spec.add_dependency 'yt', '>= 0.29'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.5'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
30
31
|
spec.add_development_dependency 'coveralls', '~> 0.8.15'
|
31
32
|
spec.add_development_dependency 'jekyll', '~> 3.3'
|
32
33
|
spec.add_development_dependency 'yard', '~> 0.9.5'
|
metadata
CHANGED
@@ -1,15 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt-url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 1.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: yt
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0.29'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.29'
|
13
47
|
- !ruby/object:Gem::Dependency
|
14
48
|
name: bundler
|
15
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +72,20 @@ dependencies:
|
|
38
72
|
- - "~>"
|
39
73
|
- !ruby/object:Gem::Version
|
40
74
|
version: '3.5'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rake
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '10.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '10.0'
|
41
89
|
- !ruby/object:Gem::Dependency
|
42
90
|
name: coveralls
|
43
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,7 +128,7 @@ dependencies:
|
|
80
128
|
- - "~>"
|
81
129
|
- !ruby/object:Gem::Version
|
82
130
|
version: 0.9.5
|
83
|
-
description: URL Extension for the
|
131
|
+
description: URL Extension for the Yt library.
|
84
132
|
email:
|
85
133
|
- claudio@fullscreen.net
|
86
134
|
executables: []
|
@@ -88,14 +136,23 @@ extensions: []
|
|
88
136
|
extra_rdoc_files: []
|
89
137
|
files:
|
90
138
|
- ".gitignore"
|
139
|
+
- ".rspec"
|
140
|
+
- ".travis.yml"
|
91
141
|
- CHANGELOG.md
|
92
142
|
- Gemfile
|
93
143
|
- LICENSE.txt
|
94
144
|
- README.md
|
145
|
+
- Rakefile
|
95
146
|
- bin/console
|
96
147
|
- bin/setup
|
148
|
+
- bin/yt-url
|
97
149
|
- lib/yt/url.rb
|
98
150
|
- lib/yt/url/version.rb
|
151
|
+
- spec/id_spec.rb
|
152
|
+
- spec/kind_spec.rb
|
153
|
+
- spec/resource_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
- spec/support/server.rb
|
99
156
|
- yt-url.gemspec
|
100
157
|
homepage: http://github.com/claudiob/yt-url
|
101
158
|
licenses:
|
@@ -112,14 +169,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
169
|
version: 2.2.2
|
113
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
171
|
requirements:
|
115
|
-
- - "
|
172
|
+
- - ">"
|
116
173
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
174
|
+
version: 1.3.1
|
118
175
|
requirements: []
|
119
176
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.6.
|
177
|
+
rubygems_version: 2.6.10
|
121
178
|
signing_key:
|
122
179
|
specification_version: 4
|
123
180
|
summary: Yt::URL helps identify which YouTube resource (video, channel, playlist)
|
124
181
|
matches a YouTube URL in any given form.
|
125
|
-
test_files:
|
182
|
+
test_files:
|
183
|
+
- spec/id_spec.rb
|
184
|
+
- spec/kind_spec.rb
|
185
|
+
- spec/resource_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
- spec/support/server.rb
|