lita-youtube 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e70d337da8c4ccf90f821a90a0d2f251321644fe
4
+ data.tar.gz: 740cee12ca52b86dd0d863124608f7e8aad328da
5
+ SHA512:
6
+ metadata.gz: 50c45733772d1a5e85037e0e8cd131022b84724d5fa0edfc0208955c820f040b9701591683d67eb607996a0c04ea2e4453d433b78d10cc7cd6b2450dd618b031
7
+ data.tar.gz: 1c1081e413a5db13ece1b5d3c39b5434782239bb5ae47528ae4ebbac22a50c3b4c10f75afd86ad7993ef6feff8ecba888f9f79129829ecf2432ef6edbd4f6096
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rake
5
+ before_install:
6
+ - gem update --system
7
+ notifications:
8
+ webhooks:
9
+ urls:
10
+ - https://lita-freenode.herokuapp.com/travis
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Jimmy Cuadra
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # lita-youtube
2
+
3
+ [![Build Status](https://travis-ci.org/jimmycuadra/lita-youtube.png?branch=master)](https://travis-ci.org/jimmycuadra/lita-youtube)
4
+ [![Code Climate](https://codeclimate.com/github/jimmycuadra/lita-youtube.png)](https://codeclimate.com/github/jimmycuadra/lita-youtube)
5
+ [![Coverage Status](https://coveralls.io/repos/jimmycuadra/lita-youtube/badge.png)](https://coveralls.io/r/jimmycuadra/lita-youtube)
6
+
7
+
8
+ **lita-youtube** is a handler for [Lita](http://lita.io/) that listens for [YouTube](https://www.youtube.com/) links in the chat and responds with their titles and durations.
9
+
10
+ ## Installation
11
+
12
+ Add lita-youtube to your Lita instance's Gemfile:
13
+
14
+ ``` ruby
15
+ gem "lita-youtube"
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Link a YouTube video in a message to have Lita provide meta data about the video.
21
+
22
+ ## License
23
+
24
+ [MIT](http://opensource.org/licenses/MIT)
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1 @@
1
+ require "lita/handlers/youtube"
@@ -0,0 +1,70 @@
1
+ require "lita"
2
+
3
+ module Lita
4
+ module Handlers
5
+ # Listen for YouTube links and respond with their titles and duration.
6
+ class Youtube < Handler
7
+ API_URL = "http://gdata.youtube.com/feeds/api/videos/"
8
+
9
+ route(%r{(https?://www\.youtube\.com\/watch\?[^\s]+)}i, :query_string)
10
+ route(%r{(https?://youtu\.be/)([a-z0-9\-_]+)}i, :short_link)
11
+
12
+ def query_string(response)
13
+ video_id = extract_video_id(response.matches[0][0])
14
+ get_video_data_and_respond(video_id, response)
15
+ end
16
+
17
+ def short_link(response)
18
+ get_video_data_and_respond(response.matches[0][1], response)
19
+ end
20
+
21
+ private
22
+
23
+ def get_video_data_and_respond(video_id, response)
24
+ title, time = video_data(video_id)
25
+
26
+ if title && time
27
+ response.reply "#{title} (#{time})"
28
+ end
29
+ end
30
+
31
+ def extract_video_id(url)
32
+ url = URI.parse(url)
33
+ Rack::Utils.parse_nested_query(url.query)["v"]
34
+ end
35
+
36
+ def video_data(video_id)
37
+ Lita.logger.info("Requesting data for YouTube video #{video_id}.")
38
+
39
+ response = http.get("#{API_URL}#{video_id}", alt: "json")
40
+
41
+ if response.status == 200
42
+ data = MultiJson.load(response.body)
43
+ entry = data["entry"]
44
+ title = entry["title"]["$t"]
45
+ time = format_time(entry["media$group"]["yt$duration"]["seconds"])
46
+ [title, time]
47
+ else
48
+ Lita.logger.error(
49
+ "YouTube API returned status code #{response.status}."
50
+ )
51
+ end
52
+ end
53
+
54
+ def format_time(seconds)
55
+ minutes, seconds = seconds.to_i.divmod(60)
56
+ hours, minutes = minutes.divmod(60)
57
+
58
+ if hours > 0
59
+ "#{hours}h#{minutes}m#{seconds}s"
60
+ elsif minutes > 0
61
+ "#{minutes}m#{seconds}s"
62
+ else
63
+ "#{seconds}s"
64
+ end
65
+ end
66
+ end
67
+
68
+ Lita.register_handler(Youtube)
69
+ end
70
+ end
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-youtube"
3
+ spec.version = "0.0.2"
4
+ spec.authors = ["Jimmy Cuadra"]
5
+ spec.email = ["jimmy@jimmycuadra.com"]
6
+ spec.description = %q{A Lita handler for displaying YouTube video information.}
7
+ spec.summary = %q{A Lita handler for displaying YouTube video information.}
8
+ spec.homepage = "https://github.com/jimmycuadra/lita-youtube"
9
+ spec.license = "MIT"
10
+
11
+ spec.files = `git ls-files`.split($/)
12
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
13
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_runtime_dependency "lita", "~> 2.6"
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.3"
19
+ spec.add_development_dependency "rake"
20
+ spec.add_development_dependency "rspec", ">= 2.14"
21
+ spec.add_development_dependency "simplecov"
22
+ spec.add_development_dependency "coveralls"
23
+ end
@@ -0,0 +1 @@
1
+ {"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$media":"http://search.yahoo.com/mrss/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","id":{"$t":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg"},"published":{"$t":"2006-04-06T21:30:53.000Z"},"updated":{"$t":"2013-11-15T08:50:15.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"Comedy","label":"Comedy"}],"title":{"$t":"Evolution of Dance - By Judson Laipply","type":"text"},"content":{"$t":"For more visit http://www.mightaswelldance.com","type":"text"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/related"},{"rel":"http://gdata.youtube.com/schemas/2007#mobile","type":"text/html","href":"http://m.youtube.com/details?v=dMH0bHeiRNg"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg"}],"author":[{"name":{"$t":"Judson Laipply"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/judsonlaipply"}}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments","countHint":434970}},"media$group":{"media$category":[{"$t":"Comedy","label":"Comedy","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/dMH0bHeiRNg?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":4532,"yt$format":5},{"url":"rtsp://r7---sn-o097zuee.c.youtube.com/CiILENy73wIaGQnYRKJ3bPTBdBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":4532,"yt$format":1},{"url":"rtsp://r7---sn-o097zuee.c.youtube.com/CiILENy73wIaGQnYRKJ3bPTBdBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":4532,"yt$format":6}],"media$description":{"$t":"For more visit http://www.mightaswelldance.com","type":"plain"},"media$keywords":{},"media$player":[{"url":"http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata_player"}],"media$thumbnail":[{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/0.jpg","height":360,"width":480,"time":"00:03:00.500"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/1.jpg","height":90,"width":120,"time":"00:01:30.250"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/2.jpg","height":90,"width":120,"time":"00:03:00.500"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/3.jpg","height":90,"width":120,"time":"00:04:30.750"}],"media$title":{"$t":"Evolution of Dance - By Judson Laipply","type":"plain"},"yt$duration":{"seconds":"4532"}},"gd$rating":{"average":4.7032027,"max":5,"min":1,"numRaters":1070900,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"232330267"}}}
@@ -0,0 +1 @@
1
+ {"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$media":"http://search.yahoo.com/mrss/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","id":{"$t":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg"},"published":{"$t":"2006-04-06T21:30:53.000Z"},"updated":{"$t":"2013-11-15T08:50:15.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"Comedy","label":"Comedy"}],"title":{"$t":"Evolution of Dance - By Judson Laipply","type":"text"},"content":{"$t":"For more visit http://www.mightaswelldance.com","type":"text"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/related"},{"rel":"http://gdata.youtube.com/schemas/2007#mobile","type":"text/html","href":"http://m.youtube.com/details?v=dMH0bHeiRNg"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg"}],"author":[{"name":{"$t":"Judson Laipply"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/judsonlaipply"}}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments","countHint":434970}},"media$group":{"media$category":[{"$t":"Comedy","label":"Comedy","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/dMH0bHeiRNg?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":25,"yt$format":5},{"url":"rtsp://r7---sn-o097zuee.c.youtube.com/CiILENy73wIaGQnYRKJ3bPTBdBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":25,"yt$format":1},{"url":"rtsp://r7---sn-o097zuee.c.youtube.com/CiILENy73wIaGQnYRKJ3bPTBdBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":25,"yt$format":6}],"media$description":{"$t":"For more visit http://www.mightaswelldance.com","type":"plain"},"media$keywords":{},"media$player":[{"url":"http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata_player"}],"media$thumbnail":[{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/0.jpg","height":360,"width":480,"time":"00:03:00.500"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/1.jpg","height":90,"width":120,"time":"00:01:30.250"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/2.jpg","height":90,"width":120,"time":"00:03:00.500"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/3.jpg","height":90,"width":120,"time":"00:04:30.750"}],"media$title":{"$t":"Evolution of Dance - By Judson Laipply","type":"plain"},"yt$duration":{"seconds":"25"}},"gd$rating":{"average":4.7032027,"max":5,"min":1,"numRaters":1070900,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"232330267"}}}
@@ -0,0 +1 @@
1
+ {"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$media":"http://search.yahoo.com/mrss/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","id":{"$t":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg"},"published":{"$t":"2006-04-06T21:30:53.000Z"},"updated":{"$t":"2013-11-15T08:50:15.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"Comedy","label":"Comedy"}],"title":{"$t":"Evolution of Dance - By Judson Laipply","type":"text"},"content":{"$t":"For more visit http://www.mightaswelldance.com","type":"text"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/related"},{"rel":"http://gdata.youtube.com/schemas/2007#mobile","type":"text/html","href":"http://m.youtube.com/details?v=dMH0bHeiRNg"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg"}],"author":[{"name":{"$t":"Judson Laipply"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/judsonlaipply"}}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/dMH0bHeiRNg/comments","countHint":434970}},"media$group":{"media$category":[{"$t":"Comedy","label":"Comedy","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/dMH0bHeiRNg?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":361,"yt$format":5},{"url":"rtsp://r7---sn-o097zuee.c.youtube.com/CiILENy73wIaGQnYRKJ3bPTBdBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":361,"yt$format":1},{"url":"rtsp://r7---sn-o097zuee.c.youtube.com/CiILENy73wIaGQnYRKJ3bPTBdBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":361,"yt$format":6}],"media$description":{"$t":"For more visit http://www.mightaswelldance.com","type":"plain"},"media$keywords":{},"media$player":[{"url":"http://www.youtube.com/watch?v=dMH0bHeiRNg&feature=youtube_gdata_player"}],"media$thumbnail":[{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/0.jpg","height":360,"width":480,"time":"00:03:00.500"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/1.jpg","height":90,"width":120,"time":"00:01:30.250"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/2.jpg","height":90,"width":120,"time":"00:03:00.500"},{"url":"http://i1.ytimg.com/vi/dMH0bHeiRNg/3.jpg","height":90,"width":120,"time":"00:04:30.750"}],"media$title":{"$t":"Evolution of Dance - By Judson Laipply","type":"plain"},"yt$duration":{"seconds":"361"}},"gd$rating":{"average":4.7032027,"max":5,"min":1,"numRaters":1070900,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"232330267"}}}
@@ -0,0 +1,119 @@
1
+ require "spec_helper"
2
+
3
+ SUCCESS_JSON = File.read(
4
+ File.expand_path("../../../fixtures/success.json", __FILE__)
5
+ ).chomp
6
+
7
+ LONG_DURATION_JSON = File.read(
8
+ File.expand_path("../../../fixtures/long_duration.json", __FILE__)
9
+ ).chomp
10
+
11
+ SHORT_DURATION_JSON = File.read(
12
+ File.expand_path("../../../fixtures/short_duration.json", __FILE__)
13
+ ).chomp
14
+
15
+ describe Lita::Handlers::Youtube, lita_handler: true do
16
+ it { routes("http://www.youtube.com/watch?v=dMH0bHeiRNg").to(:query_string) }
17
+ it { routes("https://www.youtube.com/watch?v=dMH0bHeiRNg").to(:query_string) }
18
+
19
+ it do
20
+ routes(
21
+ "http://www.youtube.com/watch?feature=player_embedded&v=dMH0bHeiRNg"
22
+ ).to(:query_string)
23
+ end
24
+
25
+ it do
26
+ routes(
27
+ "check this out! http://www.youtube.com/watch?v=dMH0bHeiRNg - it's great!"
28
+ ).to(:query_string)
29
+ end
30
+
31
+ it { routes("http://youtu.be/dMH0bHeiRNg").to(:short_link) }
32
+ it { routes("https://youtu.be/dMH0bHeiRNg").to(:short_link) }
33
+
34
+ describe "#query_string" do
35
+ it "replies with the video's title and duration" do
36
+ response = double("Faraday::Response", status: 200, body: SUCCESS_JSON)
37
+
38
+ allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(
39
+ response
40
+ )
41
+
42
+ send_message("http://www.youtube.com/watch?v=dMH0bHeiRNg")
43
+ expect(replies.last).to eq(
44
+ "Evolution of Dance - By Judson Laipply (6m1s)"
45
+ )
46
+ end
47
+
48
+ it "correctly formats durations longer than an hour" do
49
+ response = double(
50
+ "Faraday::Response",
51
+ status: 200,
52
+ body: LONG_DURATION_JSON
53
+ )
54
+
55
+ allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(
56
+ response
57
+ )
58
+
59
+ send_message("http://www.youtube.com/watch?v=dMH0bHeiRNg")
60
+ expect(replies.last).to eq(
61
+ "Evolution of Dance - By Judson Laipply (1h15m32s)"
62
+ )
63
+ end
64
+
65
+ it "correctly formats durations of less than a minute" do
66
+ response = double(
67
+ "Faraday::Response",
68
+ status: 200,
69
+ body: SHORT_DURATION_JSON
70
+ )
71
+
72
+ allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(
73
+ response
74
+ )
75
+
76
+ send_message("http://www.youtube.com/watch?v=dMH0bHeiRNg")
77
+ expect(replies.last).to eq(
78
+ "Evolution of Dance - By Judson Laipply (25s)"
79
+ )
80
+ end
81
+
82
+ context "when the API returns a non-200 status" do
83
+ let(:response) { double("Faraday::Response", status: 500) }
84
+
85
+ before do
86
+ allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(
87
+ response
88
+ )
89
+ end
90
+
91
+ it "logs an error" do
92
+ expect(Lita.logger).to receive(:error).with(
93
+ "YouTube API returned status code 500."
94
+ )
95
+ send_message("http://www.youtube.com/watch?v=dMH0bHeiRNg")
96
+ end
97
+
98
+ it "doesn't send any messages to the chat" do
99
+ send_message("http://www.youtube.com/watch?v=dMH0bHeiRNg")
100
+ expect(replies).to be_empty
101
+ end
102
+ end
103
+ end
104
+
105
+ describe "#short_link" do
106
+ it "replies with the video's title and duration" do
107
+ response = double("Faraday::Response", status: 200, body: SUCCESS_JSON)
108
+
109
+ allow_any_instance_of(Faraday::Connection).to receive(:get).and_return(
110
+ response
111
+ )
112
+
113
+ send_message("http://youtu.be/dMH0bHeiRNg")
114
+ expect(replies.last).to eq(
115
+ "Evolution of Dance - By Judson Laipply (6m1s)"
116
+ )
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,10 @@
1
+ require "simplecov"
2
+ require "coveralls"
3
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ Coveralls::SimpleCov::Formatter
6
+ ]
7
+ SimpleCov.start { add_filter "/spec/" }
8
+
9
+ require "lita-youtube"
10
+ require "lita/rspec"
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-youtube
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jimmy Cuadra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '2.14'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '2.14'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A Lita handler for displaying YouTube video information.
98
+ email:
99
+ - jimmy@jimmycuadra.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .travis.yml
106
+ - Gemfile
107
+ - LICENSE
108
+ - README.md
109
+ - Rakefile
110
+ - lib/lita-youtube.rb
111
+ - lib/lita/handlers/youtube.rb
112
+ - lita-youtube.gemspec
113
+ - spec/fixtures/long_duration.json
114
+ - spec/fixtures/short_duration.json
115
+ - spec/fixtures/success.json
116
+ - spec/lita/handlers/youtube_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/jimmycuadra/lita-youtube
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.1.3
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: A Lita handler for displaying YouTube video information.
142
+ test_files:
143
+ - spec/fixtures/long_duration.json
144
+ - spec/fixtures/short_duration.json
145
+ - spec/fixtures/success.json
146
+ - spec/lita/handlers/youtube_spec.rb
147
+ - spec/spec_helper.rb