yourub 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/config/yourub.yml +1 -1
- data/lib/yourub/client.rb +3 -2
- data/lib/yourub/count_filter.rb +1 -2
- data/lib/yourub/validator.rb +9 -1
- data/lib/yourub/version.rb +1 -1
- data/spec/count_filter_spec.rb +8 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2aa1059c797a786fea83046d74f8bd6751f954d
|
4
|
+
data.tar.gz: 7906cfcc12e3fd7e7cd82c2290f00a855c3ef8cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cb8c2d1c2c2ebce6e81bd0d8bcf832f0ac7365d3543e445bd3ced8c2e5049a24840e03d83684bd47725a466d277df596cd4b635c752ad1eb0747d85b5ef3f58
|
7
|
+
data.tar.gz: 4533693deb7dd813670d8ec362f44e66e985f41c6233c58798b2d14b977194f9ae59112ce0b67ef9984f0305c541c67c1713346eb01bc854694882df1112e42a
|
data/README.md
CHANGED
data/config/yourub.yml
CHANGED
data/lib/yourub/client.rb
CHANGED
@@ -7,6 +7,7 @@ module Yourub
|
|
7
7
|
def initialize()
|
8
8
|
@extended_info = false
|
9
9
|
@categories, @videos = [], []
|
10
|
+
@count_filter = {}
|
10
11
|
@api_options= {
|
11
12
|
:part => 'snippet',
|
12
13
|
:type => 'video',
|
@@ -97,7 +98,7 @@ module Yourub
|
|
97
98
|
def retrieve_videos
|
98
99
|
consume_criteria do |criteria|
|
99
100
|
req = search_list_request(criteria)
|
100
|
-
if @extended_info ||
|
101
|
+
if @extended_info || Yourub::CountFilter.filter
|
101
102
|
get_details_and_store req
|
102
103
|
else
|
103
104
|
videos = Yourub::Reader.parse_videos(req)
|
@@ -175,7 +176,7 @@ module Yourub
|
|
175
176
|
|
176
177
|
def add_video_to_search_result(entry)
|
177
178
|
video = @extended_info ? entry : Yourub::Reader.parse_entry(entry)
|
178
|
-
if Yourub::CountFilter.accept?(entry
|
179
|
+
if Yourub::CountFilter.accept?(entry)
|
179
180
|
@videos.push(video)
|
180
181
|
end
|
181
182
|
end
|
data/lib/yourub/count_filter.rb
CHANGED
data/lib/yourub/validator.rb
CHANGED
@@ -22,6 +22,7 @@ module Yourub
|
|
22
22
|
countries_to_array
|
23
23
|
add_default_country_if_category_is_present
|
24
24
|
validate_countries
|
25
|
+
set_filter_count_options
|
25
26
|
|
26
27
|
@criteria
|
27
28
|
end
|
@@ -66,7 +67,14 @@ module Yourub
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
|
70
|
+
def set_filter_count_options
|
71
|
+
if @criteria.has_key? :count_filter
|
72
|
+
Yourub::CountFilter.filter = @criteria.delete(:count_filter)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
69
76
|
def valid_category(categories, selected_category)
|
77
|
+
#if selected_category == 'all' return categories
|
70
78
|
categories = categories.select {|k| k.has_value?(selected_category.downcase)}
|
71
79
|
if categories.first.nil?
|
72
80
|
raise ArgumentError.new(
|
@@ -109,7 +117,7 @@ module Yourub
|
|
109
117
|
raise ArgumentError.new(
|
110
118
|
'max 50 videos pro categories or country'
|
111
119
|
) unless(
|
112
|
-
@criteria[:max_results].to_i <
|
120
|
+
@criteria[:max_results].to_i < 51 || @criteria[:max_results].to_i == 0
|
113
121
|
)
|
114
122
|
end
|
115
123
|
|
data/lib/yourub/version.rb
CHANGED
data/spec/count_filter_spec.rb
CHANGED
@@ -16,22 +16,21 @@ describe Yourub::CountFilter do
|
|
16
16
|
}
|
17
17
|
}
|
18
18
|
|
19
|
+
let(:subject) { Yourub::CountFilter.accept?(video) }
|
20
|
+
|
19
21
|
it "accept the video if satisfy the condition" do
|
20
|
-
filter = {views: ">= 100"}
|
21
|
-
|
22
|
-
expect(res).to be_true
|
22
|
+
Yourub::CountFilter.filter = {views: ">= 100"}
|
23
|
+
expect(subject).to be_true
|
23
24
|
end
|
24
25
|
|
25
26
|
it "accept the video if filter is nil" do
|
26
|
-
filter = nil
|
27
|
-
|
28
|
-
expect(res).to be_true
|
27
|
+
Yourub::CountFilter.filter = nil
|
28
|
+
expect(subject).to be_true
|
29
29
|
end
|
30
30
|
|
31
31
|
it "not accept the video if it does not satisfy the condition" do
|
32
|
-
filter = {views: "<= 100"}
|
33
|
-
|
34
|
-
expect(res).to be_false
|
32
|
+
Yourub::CountFilter.filter = {views: "<= 100"}
|
33
|
+
expect(subject).to be_false
|
35
34
|
end
|
36
35
|
|
37
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yourub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Davide Prati
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-api-client
|