youtube_images 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 1.9.2
5
+ - 2.0.0
6
+ - jruby-19mode
7
+ - rbx-19mode
8
+ - jruby-head
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Getting Started
1
+ # Getting Started [![Build Status](https://travis-ci.org/rahult/youtube_images.png?branch=master)](https://travis-ci.org/rahult/youtube_images) [![Code Climate](https://codeclimate.com/github/rahult/youtube_images.png)](https://codeclimate.com/github/rahult/youtube_images)
2
2
 
3
3
  **YouTube Images** can be used to extract thumbnails/images for a given youtube video ID or URL without a developer ID. It uses a URL constructor instead of an API
4
4
 
@@ -24,6 +24,8 @@ For example if you want to fetch the default thumbnail for youtube URL you can d
24
24
 
25
25
  ```ruby
26
26
  YouTubeImages::For("http://www.youtube.com/watch?v=5zVaFjSxAZs")[:default]
27
+ # or
28
+ YouTubeImages::For("5zVaFjSxAZs")[:default]
27
29
  ```
28
30
 
29
31
  ## Advanced Usage
@@ -5,7 +5,7 @@ module YouTubeImages
5
5
  class IncorrectYouTubeID < Exception; end
6
6
 
7
7
  def self.For(id_or_url, secure=false)
8
- id = id_or_url[/[\w]+$/]
8
+ id = id_or_url[/[\w\-\_]+$/]
9
9
 
10
10
  raise IncorrectYouTubeID if id.nil? || (id.length < 11)
11
11
 
@@ -1,3 +1,3 @@
1
1
  module YoutubeImages
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -2,16 +2,17 @@ require 'minitest/autorun'
2
2
  require 'minitest/pride'
3
3
  require "youtube_images"
4
4
 
5
- describe YouTubeImages do
5
+ def image_hash_for(id)
6
+ @images_hash = {
7
+ default: "http://img.youtube.com/vi/#{id}/default.jpg",
8
+ medium: "http://img.youtube.com/vi/#{id}/hqdefault.jpg",
9
+ high: "http://img.youtube.com/vi/#{id}/mqdefault.jpg",
10
+ maximum: "http://img.youtube.com/vi/#{id}/maxresdefault.jpg"
11
+ }
12
+ end
6
13
 
7
- before do
8
- @images_hash = {
9
- default: "http://img.youtube.com/vi/onghF8NYbPw/default.jpg",
10
- medium: "http://img.youtube.com/vi/onghF8NYbPw/hqdefault.jpg",
11
- high: "http://img.youtube.com/vi/onghF8NYbPw/mqdefault.jpg",
12
- maximum: "http://img.youtube.com/vi/onghF8NYbPw/maxresdefault.jpg"
13
- }
14
- end
14
+
15
+ describe YouTubeImages do
15
16
 
16
17
  describe "when asked about images for a invalid youtube video" do
17
18
 
@@ -28,7 +29,11 @@ describe YouTubeImages do
28
29
  describe "when asked about images for a youtube ID" do
29
30
 
30
31
  it "must respond with an image" do
31
- YouTubeImages::For("onghF8NYbPw").must_equal @images_hash
32
+ YouTubeImages::For("onghF8NYbPw").must_equal image_hash_for("onghF8NYbPw")
33
+ end
34
+
35
+ it "must respond with an image" do
36
+ YouTubeImages::For("wrHU-DSirsw").must_equal image_hash_for("wrHU-DSirsw")
32
37
  end
33
38
 
34
39
  end
@@ -36,7 +41,7 @@ describe YouTubeImages do
36
41
  describe "when asked about images for a youtube URL" do
37
42
 
38
43
  it "must respond with an image" do
39
- YouTubeImages::For("http://www.youtube.com/watch?v=onghF8NYbPw").must_equal @images_hash
44
+ YouTubeImages::For("http://www.youtube.com/watch?v=onghF8NYbPw").must_equal image_hash_for("onghF8NYbPw")
40
45
  end
41
46
 
42
47
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtube_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-23 00:00:00.000000000 Z
12
+ date: 2013-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -54,6 +54,7 @@ files:
54
54
  - .gitignore
55
55
  - .ruby-gemset
56
56
  - .ruby-version
57
+ - .travis.yml
57
58
  - Gemfile
58
59
  - LICENSE.txt
59
60
  - README.md
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
78
  version: '0'
78
79
  segments:
79
80
  - 0
80
- hash: 1375972798781748379
81
+ hash: -1557985715866532097
81
82
  required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  none: false
83
84
  requirements:
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  segments:
88
89
  - 0
89
- hash: 1375972798781748379
90
+ hash: -1557985715866532097
90
91
  requirements: []
91
92
  rubyforge_project:
92
93
  rubygems_version: 1.8.25