youtube_id 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed39a7ecd0225864d1e4b877ffe6595b0ea27164
4
+ data.tar.gz: a2382f0d248d1bbb15f5940cb087f83134e17108
5
+ SHA512:
6
+ metadata.gz: 51aa373084c3813a7fe012dde583254afcc4f90e42959a9136c12c1f3c760f619ab0d63d9e3fe251b6b097ec3fdb838d87da744e78710bf8647c3d9288f5a508
7
+ data.tar.gz: 5aaf414153b8774ee8bd718ec7914b3c6506b9c5a3cfc2d27b792b122289dc413697f1ac892e6f6efe5c8a5fcd0f72ccad37df02a02db34bc36ca3626fd52ca7
data/.travis.yml CHANGED
@@ -2,9 +2,11 @@ language: ruby
2
2
  script: bundle exec rspec -bfd spec
3
3
  rvm:
4
4
  - 1.8.7
5
- - 1.9.2
6
5
  - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.10
8
+ - 2.2.7
9
+ - 2.3.4
10
+ - 2.4.1
11
+ - ruby-head
7
12
  - jruby
8
- - ree
9
- - rbx-18mode
10
- - rbx-19mode
data/README.md CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  ```ruby
24
- YoutubeID.from("http//www.youtube.com/watch?v=RCUkmUXMd_k") # => "RCUkmUXMd_k"
24
+ YoutubeID.from("http://www.youtube.com/watch?v=RCUkmUXMd_k") # => "RCUkmUXMd_k"
25
25
  ```
26
26
 
27
27
  It supports these url formats:
data/lib/youtube_id.rb CHANGED
@@ -2,11 +2,11 @@ require "youtube_id/version"
2
2
 
3
3
  module YoutubeID
4
4
  FORMATS = [
5
- %r(https?://youtu\.be/(.+)),
6
- %r(https?://www\.youtube\.com/watch\?v=(.*?)(&|#|$)),
7
- %r(https?://www\.youtube\.com/embed/(.*?)(\?|$)),
8
- %r(https?://www\.youtube\.com/v/(.*?)(#|\?|$)),
9
- %r(https?://www\.youtube\.com/user/.*?#\w/\w/\w/\w/(.+)\b)
5
+ %r((?:https?://)?youtu\.be/(.+)),
6
+ %r((?:https?://)?(?:www\.)?youtube\.com/watch\?v=(.*?)(&|#|$)),
7
+ %r((?:https?://)?(?:www\.)?youtube\.com/embed/(.*?)(\?|$)),
8
+ %r((?:https?://)?(?:www\.)?youtube\.com/v/(.*?)(#|\?|$)),
9
+ %r((?:https?://)?(?:www\.)?youtube\.com/user/.*?#\w/\w/\w/\w/(.+)\b)
10
10
  ]
11
11
 
12
12
  def self.from(video_url)
@@ -1,3 +1,3 @@
1
1
  module YoutubeID
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -4,54 +4,56 @@ describe YoutubeID do
4
4
  describe ".from" do
5
5
  subject { described_class.from url }
6
6
 
7
- %w(http https).each do |protocol|
8
- context "direct format" "/v/:id" do
9
- let(:url) { "#{protocol}://www.youtube.com/v/RCUkmUXMd_k" }
10
- it { should == "RCUkmUXMd_k" }
11
- end
12
-
13
- context "legacy embed format" "/v/:id?version=3&hl=en_US&rel=0" do
14
- let(:url) { "#{protocol}://www.youtube.com/v/RCUkmUXMd_k?version=3&hl=en_US&rel=0" }
15
- it { should == "RCUkmUXMd_k" }
16
- end
17
-
18
- context "embed format" "/embed/RCUkmUXMd_k?rel=0" do
19
- let(:url) { "#{protocol}://www.youtube.com/embed/RCUkmUXMd_k?rel=0" }
20
- it { should == "RCUkmUXMd_k" }
21
-
22
- context "without parameters" do
23
- let(:url) { "#{protocol}://www.youtube.com/embed/RCUkmUXMd_k" }
7
+ ["", "http://", "https://"].each do |protocol|
8
+ ["", "www."].each do |www|
9
+ context "direct format" "/v/:id" do
10
+ let(:url) { "#{protocol}#{www}youtube.com/v/RCUkmUXMd_k" }
24
11
  it { should == "RCUkmUXMd_k" }
25
12
  end
26
- end
27
13
 
28
- context "standard format", "/watch?v=:id" do
29
- let(:url) { "#{protocol}://www.youtube.com/watch?v=RCUkmUXMd_k" }
30
- it { should == "RCUkmUXMd_k" }
14
+ context "legacy embed format" "/v/:id?version=3&hl=en_US&rel=0" do
15
+ let(:url) { "#{protocol}#{www}youtube.com/v/RCUkmUXMd_k?version=3&hl=en_US&rel=0" }
16
+ it { should == "RCUkmUXMd_k" }
17
+ end
31
18
 
32
- context "with additional parameters" do
33
- let(:url) { "#{protocol}://www.youtube.com/watch?v=RCUkmUXMd_k&feature=related" }
19
+ context "embed format" "/embed/RCUkmUXMd_k?rel=0" do
20
+ let(:url) { "#{protocol}#{www}youtube.com/embed/RCUkmUXMd_k?rel=0" }
34
21
  it { should == "RCUkmUXMd_k" }
22
+
23
+ context "without parameters" do
24
+ let(:url) { "#{protocol}#{www}youtube.com/embed/RCUkmUXMd_k" }
25
+ it { should == "RCUkmUXMd_k" }
26
+ end
35
27
  end
36
28
 
37
- context "with start time specification" do
38
- let(:url) { "#{protocol}://www.youtube.com/watch?v=RCUkmUXMd_k#t=0m10s" }
29
+ context "standard format", "/watch?v=:id" do
30
+ let(:url) { "#{protocol}#{www}youtube.com/watch?v=RCUkmUXMd_k" }
39
31
  it { should == "RCUkmUXMd_k" }
32
+
33
+ context "with additional parameters" do
34
+ let(:url) { "#{protocol}#{www}youtube.com/watch?v=RCUkmUXMd_k&feature=related" }
35
+ it { should == "RCUkmUXMd_k" }
36
+ end
37
+
38
+ context "with start time specification" do
39
+ let(:url) { "#{protocol}#{www}youtube.com/watch?v=RCUkmUXMd_k#t=0m10s" }
40
+ it { should == "RCUkmUXMd_k" }
41
+ end
40
42
  end
41
- end
42
43
 
43
- context "user video format", "/user/name#p/a/u/0/:id" do
44
- let(:url) { "#{protocol}://www.youtube.com/user/ForceD3strategy#p/a/u/0/8WVTOUh53QY" }
45
- it { should == "8WVTOUh53QY" }
44
+ context "user video format", "/user/name#p/a/u/0/:id" do
45
+ let(:url) { "#{protocol}#{www}youtube.com/user/ForceD3strategy#p/a/u/0/8WVTOUh53QY" }
46
+ it { should == "8WVTOUh53QY" }
47
+ end
46
48
  end
47
49
 
48
50
  context "short url format", "//youtu.be/RCUkmUXMd_k" do
49
- let(:url) { "#{protocol}://youtu.be/RCUkmUXMd_k" }
51
+ let(:url) { "#{protocol}youtu.be/RCUkmUXMd_k" }
50
52
  it { should == "RCUkmUXMd_k" }
51
53
  end
52
54
 
53
55
  context "short url format with dashes", "//youtu.be/Hu0i--4tz0N" do
54
- let(:url) { "#{protocol}://youtu.be/Hu0i--4tz0N" }
56
+ let(:url) { "#{protocol}youtu.be/Hu0i--4tz0N" }
55
57
  it { should == "Hu0i--4tz0N" }
56
58
  end
57
59
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtube_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rodrigo Navarro
@@ -11,19 +10,22 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2012-05-14 00:00:00.000000000Z
13
+ date: 2018-02-07 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rspec
18
- requirement: &2152883180 !ruby/object:Gem::Requirement
19
- none: false
17
+ requirement: !ruby/object:Gem::Requirement
20
18
  requirements:
21
- - - ! '>='
19
+ - - ">="
22
20
  - !ruby/object:Gem::Version
23
21
  version: '0'
24
22
  type: :development
25
23
  prerelease: false
26
- version_requirements: *2152883180
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
27
29
  description: Easily extract the video id from youtube videos urls
28
30
  email:
29
31
  - rnavarro1@gmail.com
@@ -33,8 +35,8 @@ executables: []
33
35
  extensions: []
34
36
  extra_rdoc_files: []
35
37
  files:
36
- - .gitignore
37
- - .travis.yml
38
+ - ".gitignore"
39
+ - ".travis.yml"
38
40
  - Gemfile
39
41
  - LICENSE
40
42
  - README.md
@@ -45,26 +47,25 @@ files:
45
47
  - youtube_id.gemspec
46
48
  homepage: https://github.com/reu/youtube_id
47
49
  licenses: []
50
+ metadata: {}
48
51
  post_install_message:
49
52
  rdoc_options: []
50
53
  require_paths:
51
54
  - lib
52
55
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
56
  requirements:
55
- - - ! '>='
57
+ - - ">="
56
58
  - !ruby/object:Gem::Version
57
59
  version: '0'
58
60
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
61
  requirements:
61
- - - ! '>='
62
+ - - ">="
62
63
  - !ruby/object:Gem::Version
63
64
  version: '0'
64
65
  requirements: []
65
66
  rubyforge_project:
66
- rubygems_version: 1.8.17
67
+ rubygems_version: 2.4.5
67
68
  signing_key:
68
- specification_version: 3
69
+ specification_version: 4
69
70
  summary: Easily extract the video id from youtube videos urls
70
71
  test_files: []