youtube_pop 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/lib/youtube_pop.rb +1 -0
- data/lib/youtube_pop/standard_api.rb +251 -0
- data/lib/youtube_pop/version.rb +3 -0
- data/spec/youtube_pop_spec.rb +207 -0
- data/youtube_pop.gemspec +24 -0
- metadata +105 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Navid Kamali
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# YouTubePop
|
2
|
+
|
3
|
+
A simple YouTube wrapper around Standard Video Feeds. Gets Top rated, Most viewed, Most shared, Most popular, Most recent, Most discussed, Most
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
gem 'youtube_pop'
|
9
|
+
|
10
|
+
And then execute:
|
11
|
+
|
12
|
+
$ bundle
|
13
|
+
|
14
|
+
Or install it yourself as:
|
15
|
+
|
16
|
+
$ gem install youtube_pop
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
$ require 'youtube_pop'
|
21
|
+
|
22
|
+
$ youtube_pop = YoutubePop::StandardApi.new
|
23
|
+
|
24
|
+
$ top_results = youtube_pop.top_rated # OR
|
25
|
+
$ top_results = youtube_pop.top_favorites # OR
|
26
|
+
$ top_results = youtube_pop.most_viewed # OR
|
27
|
+
$ top_results = youtube_pop.most_shared # OR
|
28
|
+
$ top_results = youtube_pop.most_popular # OR
|
29
|
+
$ top_results = youtube_pop.most_recent # OR
|
30
|
+
$ top_results = youtube_pop.most_discussed # OR
|
31
|
+
$ top_results = youtube_pop.most_responded # OR
|
32
|
+
$ top_results = youtube_pop.recently_featured # OR
|
33
|
+
$ top_results = youtube_pop.trending_videos
|
34
|
+
|
35
|
+
$ top_results.each do |result|
|
36
|
+
$ puts result.published # published date/time
|
37
|
+
$ puts result.updated # last updated date/time
|
38
|
+
$ puts result.content # content describing video
|
39
|
+
$ puts result.link # link to the video
|
40
|
+
$ puts result.author_name # link to the video
|
41
|
+
$ end
|
42
|
+
|
43
|
+
$ top_results.size # will tell you how many results come back. No paging yet. Just up to 25 results will be returned
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/youtube_pop.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'youtube_pop/standard_api'
|
@@ -0,0 +1,251 @@
|
|
1
|
+
require 'youtube_pop/version'
|
2
|
+
require 'faraday'
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
module YoutubePop
|
6
|
+
# Base error class for the extension. Credit to gem youtube_it
|
7
|
+
class Error < RuntimeError
|
8
|
+
attr_reader :code
|
9
|
+
def initialize(msg, code = 0)
|
10
|
+
super(msg)
|
11
|
+
@code = code
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Entry
|
16
|
+
attr_accessor :published, :updated, :content, :link, :author_name
|
17
|
+
end
|
18
|
+
|
19
|
+
class StandardApi
|
20
|
+
def initialize
|
21
|
+
@entries = []
|
22
|
+
|
23
|
+
options = {
|
24
|
+
:timeout => 2,
|
25
|
+
:open_timeout => 2
|
26
|
+
}
|
27
|
+
@conn = Faraday.new(:url => 'https://gdata.youtube.com', :options => options) do |builder|
|
28
|
+
builder.request :url_encoded
|
29
|
+
builder.response :logger
|
30
|
+
builder.adapter :net_http
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#feed/entry/published
|
35
|
+
#feed/entry/updated
|
36
|
+
#feed/entry/content
|
37
|
+
#feed/entry/link rel="alternate" href=
|
38
|
+
#
|
39
|
+
#feed/entry/author/name
|
40
|
+
#feed/entry/author/uri
|
41
|
+
def top_rated
|
42
|
+
response = @conn.get '/feeds/api/standardfeeds/top_rated/'
|
43
|
+
doc = Nokogiri::XML(response.body)
|
44
|
+
doc.css('entry').map do |entry|
|
45
|
+
published = entry.css('published').text
|
46
|
+
updated = entry.css('updated').text
|
47
|
+
content = entry.css('content').text
|
48
|
+
link = entry.at_css("link")['href']
|
49
|
+
author_name = entry.at_css("author uri").text
|
50
|
+
|
51
|
+
entry = Entry.new
|
52
|
+
entry.published = published
|
53
|
+
entry.updated = updated
|
54
|
+
entry.content = content
|
55
|
+
entry.link = link
|
56
|
+
entry.author_name = author_name
|
57
|
+
@entries << entry
|
58
|
+
end
|
59
|
+
@entries
|
60
|
+
end
|
61
|
+
|
62
|
+
def top_favorites
|
63
|
+
response = @conn.get '/feeds/api/standardfeeds/top_favorites'
|
64
|
+
doc = Nokogiri::XML(response.body)
|
65
|
+
doc.css('entry').map do |entry|
|
66
|
+
published = entry.css('published').text
|
67
|
+
updated = entry.css('updated').text
|
68
|
+
content = entry.css('content').text
|
69
|
+
link = entry.at_css("link")['href']
|
70
|
+
author_name = entry.at_css("author uri").text
|
71
|
+
|
72
|
+
entry = Entry.new
|
73
|
+
entry.published = published
|
74
|
+
entry.updated = updated
|
75
|
+
entry.content = content
|
76
|
+
entry.link = link
|
77
|
+
entry.author_name = author_name
|
78
|
+
@entries << entry
|
79
|
+
end
|
80
|
+
@entries
|
81
|
+
end
|
82
|
+
|
83
|
+
def most_shared
|
84
|
+
response = @conn.get '/feeds/api/standardfeeds/most_shared'
|
85
|
+
doc = Nokogiri::XML(response.body)
|
86
|
+
doc.css('entry').map do |entry|
|
87
|
+
published = entry.css('published').text
|
88
|
+
updated = entry.css('updated').text
|
89
|
+
content = entry.css('content').text
|
90
|
+
link = entry.at_css("link")['href']
|
91
|
+
author_name = entry.at_css("author uri").text
|
92
|
+
|
93
|
+
entry = Entry.new
|
94
|
+
entry.published = published
|
95
|
+
entry.updated = updated
|
96
|
+
entry.content = content
|
97
|
+
entry.link = link
|
98
|
+
entry.author_name = author_name
|
99
|
+
@entries << entry
|
100
|
+
end
|
101
|
+
@entries
|
102
|
+
end
|
103
|
+
|
104
|
+
def most_viewed
|
105
|
+
response = @conn.get '/feeds/api/standardfeeds/most_viewed'
|
106
|
+
doc = Nokogiri::XML(response.body)
|
107
|
+
doc.css('entry').map do |entry|
|
108
|
+
published = entry.css('published').text
|
109
|
+
updated = entry.css('updated').text
|
110
|
+
content = entry.css('content').text
|
111
|
+
link = entry.at_css("link")['href']
|
112
|
+
author_name = entry.at_css("author uri").text
|
113
|
+
|
114
|
+
entry = Entry.new
|
115
|
+
entry.published = published
|
116
|
+
entry.updated = updated
|
117
|
+
entry.content = content
|
118
|
+
entry.link = link
|
119
|
+
entry.author_name = author_name
|
120
|
+
@entries << entry
|
121
|
+
end
|
122
|
+
@entries
|
123
|
+
end
|
124
|
+
|
125
|
+
def most_popular
|
126
|
+
response = @conn.get '/feeds/api/standardfeeds/most_popular'
|
127
|
+
doc = Nokogiri::XML(response.body)
|
128
|
+
doc.css('entry').map do |entry|
|
129
|
+
published = entry.css('published').text
|
130
|
+
updated = entry.css('updated').text
|
131
|
+
content = entry.css('content').text
|
132
|
+
link = entry.at_css("link")['href']
|
133
|
+
author_name = entry.at_css("author uri").text
|
134
|
+
|
135
|
+
entry = Entry.new
|
136
|
+
entry.published = published
|
137
|
+
entry.updated = updated
|
138
|
+
entry.content = content
|
139
|
+
entry.link = link
|
140
|
+
entry.author_name = author_name
|
141
|
+
@entries << entry
|
142
|
+
end
|
143
|
+
@entries
|
144
|
+
end
|
145
|
+
|
146
|
+
def most_recent
|
147
|
+
response = @conn.get '/feeds/api/standardfeeds/most_recent'
|
148
|
+
doc = Nokogiri::XML(response.body)
|
149
|
+
doc.css('entry').map do |entry|
|
150
|
+
published = entry.css('published').text
|
151
|
+
updated = entry.css('updated').text
|
152
|
+
content = entry.css('content').text
|
153
|
+
link = entry.at_css("link")['href']
|
154
|
+
author_name = entry.at_css("author uri").text
|
155
|
+
|
156
|
+
entry = Entry.new
|
157
|
+
entry.published = published
|
158
|
+
entry.updated = updated
|
159
|
+
entry.content = content
|
160
|
+
entry.link = link
|
161
|
+
entry.author_name = author_name
|
162
|
+
@entries << entry
|
163
|
+
end
|
164
|
+
@entries
|
165
|
+
end
|
166
|
+
|
167
|
+
def most_discussed
|
168
|
+
response = @conn.get '/feeds/api/standardfeeds/most_discussed'
|
169
|
+
doc = Nokogiri::XML(response.body)
|
170
|
+
doc.css('entry').map do |entry|
|
171
|
+
published = entry.css('published').text
|
172
|
+
updated = entry.css('updated').text
|
173
|
+
content = entry.css('content').text
|
174
|
+
link = entry.at_css("link")['href']
|
175
|
+
author_name = entry.at_css("author uri").text
|
176
|
+
|
177
|
+
entry = Entry.new
|
178
|
+
entry.published = published
|
179
|
+
entry.updated = updated
|
180
|
+
entry.content = content
|
181
|
+
entry.link = link
|
182
|
+
entry.author_name = author_name
|
183
|
+
@entries << entry
|
184
|
+
end
|
185
|
+
@entries
|
186
|
+
end
|
187
|
+
|
188
|
+
def most_responded
|
189
|
+
response = @conn.get '/feeds/api/standardfeeds/most_responded'
|
190
|
+
doc = Nokogiri::XML(response.body)
|
191
|
+
doc.css('entry').map do |entry|
|
192
|
+
published = entry.css('published').text
|
193
|
+
updated = entry.css('updated').text
|
194
|
+
content = entry.css('content').text
|
195
|
+
link = entry.at_css("link")['href']
|
196
|
+
author_name = entry.at_css("author uri").text
|
197
|
+
|
198
|
+
entry = Entry.new
|
199
|
+
entry.published = published
|
200
|
+
entry.updated = updated
|
201
|
+
entry.content = content
|
202
|
+
entry.link = link
|
203
|
+
entry.author_name = author_name
|
204
|
+
@entries << entry
|
205
|
+
end
|
206
|
+
@entries
|
207
|
+
end
|
208
|
+
|
209
|
+
def recently_featured
|
210
|
+
response = @conn.get '/feeds/api/standardfeeds/recently_featured'
|
211
|
+
doc = Nokogiri::XML(response.body)
|
212
|
+
doc.css('entry').map do |entry|
|
213
|
+
published = entry.css('published').text
|
214
|
+
updated = entry.css('updated').text
|
215
|
+
content = entry.css('content').text
|
216
|
+
link = entry.at_css("link")['href']
|
217
|
+
author_name = entry.at_css("author uri").text
|
218
|
+
|
219
|
+
entry = Entry.new
|
220
|
+
entry.published = published
|
221
|
+
entry.updated = updated
|
222
|
+
entry.content = content
|
223
|
+
entry.link = link
|
224
|
+
entry.author_name = author_name
|
225
|
+
@entries << entry
|
226
|
+
end
|
227
|
+
@entries
|
228
|
+
end
|
229
|
+
|
230
|
+
def trending_videos
|
231
|
+
response = @conn.get '/feeds/api/standardfeeds/on_the_web'
|
232
|
+
doc = Nokogiri::XML(response.body)
|
233
|
+
doc.css('entry').map do |entry|
|
234
|
+
published = entry.css('published').text
|
235
|
+
updated = entry.css('updated').text
|
236
|
+
content = entry.css('content').text
|
237
|
+
link = entry.at_css("link")['href']
|
238
|
+
author_name = entry.at_css("author uri").text
|
239
|
+
|
240
|
+
entry = Entry.new
|
241
|
+
entry.published = published
|
242
|
+
entry.updated = updated
|
243
|
+
entry.content = content
|
244
|
+
entry.link = link
|
245
|
+
entry.author_name = author_name
|
246
|
+
@entries << entry
|
247
|
+
end
|
248
|
+
@entries
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
require 'youtube_pop'
|
2
|
+
|
3
|
+
describe YoutubePop::StandardApi do
|
4
|
+
before do
|
5
|
+
@youtube_pop = YoutubePop::StandardApi.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#top_rated' do
|
9
|
+
before do
|
10
|
+
@entries = @youtube_pop.top_rated
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should get data" do
|
14
|
+
@entries.size.should > 0
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should contain valid data" do
|
18
|
+
@entries.each do |entry|
|
19
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
20
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
21
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
22
|
+
entry.link.should start_with 'https://'
|
23
|
+
entry.author_name.should_not be_empty
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#top_favorites' do
|
29
|
+
before do
|
30
|
+
@entries = @youtube_pop.top_favorites
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should get data" do
|
34
|
+
@entries.size.should > 0
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should contain valid data" do
|
38
|
+
@entries.each do |entry|
|
39
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
40
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
41
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
42
|
+
entry.link.should start_with 'https://'
|
43
|
+
entry.author_name.should_not be_empty
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#most_viewed' do
|
49
|
+
before do
|
50
|
+
@entries = @youtube_pop.most_viewed
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should get data" do
|
54
|
+
@entries.size.should > 0
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should contain valid data" do
|
58
|
+
@entries.each do |entry|
|
59
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
60
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
61
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
62
|
+
entry.link.should start_with 'https://'
|
63
|
+
entry.author_name.should_not be_empty
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#most_shared' do
|
69
|
+
before do
|
70
|
+
@entries = @youtube_pop.most_shared
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should get data" do
|
74
|
+
@entries.size.should > 0
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should contain valid data" do
|
78
|
+
@entries.each do |entry|
|
79
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
80
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
81
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
82
|
+
entry.link.should start_with 'https://'
|
83
|
+
entry.author_name.should_not be_empty
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe '#most_popular' do
|
89
|
+
before do
|
90
|
+
@entries = @youtube_pop.most_popular
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should get data" do
|
94
|
+
@entries.size.should > 0
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should contain valid data" do
|
98
|
+
@entries.each do |entry|
|
99
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
100
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
101
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
102
|
+
entry.link.should start_with 'https://'
|
103
|
+
entry.author_name.should_not be_empty
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe '#most_recent' do
|
109
|
+
before do
|
110
|
+
@entries = @youtube_pop.most_recent
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should get data" do
|
114
|
+
@entries.size.should > 0
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should contain valid data" do
|
118
|
+
@entries.each do |entry|
|
119
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
120
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
121
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
122
|
+
entry.link.should start_with 'https://'
|
123
|
+
entry.author_name.should_not be_empty
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
describe '#most_discussed' do
|
129
|
+
before do
|
130
|
+
@entries = @youtube_pop.most_discussed
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should get data" do
|
134
|
+
@entries.size.should > 0
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should contain valid data" do
|
138
|
+
@entries.each do |entry|
|
139
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
140
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
141
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
142
|
+
entry.link.should start_with 'https://'
|
143
|
+
entry.author_name.should_not be_empty
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe '#most_responded' do
|
149
|
+
before do
|
150
|
+
@entries = @youtube_pop.most_responded
|
151
|
+
end
|
152
|
+
|
153
|
+
it "should get data" do
|
154
|
+
@entries.size.should > 0
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should contain valid data" do
|
158
|
+
@entries.each do |entry|
|
159
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
160
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
161
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
162
|
+
entry.link.should start_with 'https://'
|
163
|
+
entry.author_name.should_not be_empty
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
describe '#recently_featured' do
|
169
|
+
before do
|
170
|
+
@entries = @youtube_pop.recently_featured
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should get data" do
|
174
|
+
@entries.size.should > 0
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should contain valid data" do
|
178
|
+
@entries.each do |entry|
|
179
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
180
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
181
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
182
|
+
entry.link.should start_with 'https://'
|
183
|
+
entry.author_name.should_not be_empty
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
describe '#trending_videos' do
|
189
|
+
before do
|
190
|
+
@entries = @youtube_pop.trending_videos
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should get data" do
|
194
|
+
@entries.size.should > 0
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should contain valid data" do
|
198
|
+
@entries.each do |entry|
|
199
|
+
entry.should be_a_kind_of(YoutubePop::Entry)
|
200
|
+
entry.published.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
201
|
+
entry.updated.should =~ /^[\d]{4}\-[\d]{2}\-[\w]{5}:[\d]{2}:[\d]{2}\.[\w]{4}/
|
202
|
+
entry.link.should start_with 'https://'
|
203
|
+
entry.author_name.should_not be_empty
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
data/youtube_pop.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/youtube_pop/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Navid Kamali"]
|
6
|
+
gem.email = ["navidkamali@gmail.com"]
|
7
|
+
gem.description = %q{A simple YouTube wrapper around Standard Video Feeds. }
|
8
|
+
gem.summary = %q{Gets Top rated, Most viewed, Most shared, Most popular, Most recent, Most discussed, Most responded, Recently featured, Trending videos}
|
9
|
+
gem.homepage = "http://github.com/nkamali/youtube_pop"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "youtube_pop"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = YoutubePop::VERSION
|
17
|
+
|
18
|
+
# All Dependencies
|
19
|
+
gem.add_dependency "faraday", "~> 0.8.0"
|
20
|
+
gem.add_dependency "nokogiri", "~> 1.5.4"
|
21
|
+
|
22
|
+
# Development Only Dependencies
|
23
|
+
gem.add_development_dependency "rspec", "~> 2.6"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: youtube_pop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Navid Kamali
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.8.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: nokogiri
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 1.5.4
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 1.5.4
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.6'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.6'
|
62
|
+
description: ! 'A simple YouTube wrapper around Standard Video Feeds. '
|
63
|
+
email:
|
64
|
+
- navidkamali@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- lib/youtube_pop.rb
|
75
|
+
- lib/youtube_pop/standard_api.rb
|
76
|
+
- lib/youtube_pop/version.rb
|
77
|
+
- spec/youtube_pop_spec.rb
|
78
|
+
- youtube_pop.gemspec
|
79
|
+
homepage: http://github.com/nkamali/youtube_pop
|
80
|
+
licenses: []
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 1.8.24
|
100
|
+
signing_key:
|
101
|
+
specification_version: 3
|
102
|
+
summary: Gets Top rated, Most viewed, Most shared, Most popular, Most recent, Most
|
103
|
+
discussed, Most responded, Recently featured, Trending videos
|
104
|
+
test_files:
|
105
|
+
- spec/youtube_pop_spec.rb
|