yt 0.7.10 → 0.7.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -1
- data/lib/yt/associations/has_viewer_percentages.rb +15 -2
- data/lib/yt/version.rb +1 -1
- data/spec/requests/as_account/channel_spec.rb +1 -0
- data/spec/requests/as_account/video_spec.rb +1 -0
- data/spec/requests/as_content_owner/channel_spec.rb +3 -0
- data/spec/requests/as_content_owner/video_spec.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f68323942ee8bbe17cfaee4597c9e608f33c118d
|
4
|
+
data.tar.gz: 745a59c51f7ab201a9fa01f14ddf1613ccf0c8fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 470da624d81c6433c66346e55a4d375fec56bf6f10d7d1e730e20956f6afcde80719c95656a0809c4b27e39325e701886076c7c0f5617bd6311dc1e5b06e338d
|
7
|
+
data.tar.gz: fa26426355b8cb643494e483cb1e729d09c1413e5ba78c2d67bee1121a036e5c53ac4031dc86c257e3228c060fe7869ed67580dcd94fdbff48719d357d941076
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -41,7 +41,7 @@ To install on your system, run
|
|
41
41
|
|
42
42
|
To use inside a bundled Ruby project, add this line to the Gemfile:
|
43
43
|
|
44
|
-
gem 'yt', '~> 0.7.
|
44
|
+
gem 'yt', '~> 0.7.11'
|
45
45
|
|
46
46
|
Since the gem follows [Semantic Versioning](http://semver.org),
|
47
47
|
indicating the full version in your Gemfile (~> *major*.*minor*.*patch*)
|
@@ -158,6 +158,7 @@ channel.dislikes to: 2.days.ago #=> {Tue, 27 May 2014 => 0.0, Wed, 28 May 2014 =
|
|
158
158
|
channel.shares since: 7.days.ago, until: 7.days.ago #=> {Wed, 28 May 2014 => 3.0}
|
159
159
|
|
160
160
|
channel.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}…}
|
161
|
+
channel.viewer_percentage(gender: :male) #=> 49.12
|
161
162
|
```
|
162
163
|
|
163
164
|
*The methods above require to be authenticated as the channel’s account (see below).*
|
@@ -175,6 +176,7 @@ channel.shares since: 7.days.ago, until: 7.days.ago #=> {Wed, 28 May 2014 => 3.
|
|
175
176
|
channel.impressions_on 5.days.ago #=> 157.0
|
176
177
|
|
177
178
|
channel.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}…}
|
179
|
+
channel.viewer_percentage(gender: :female) #=> 49.12
|
178
180
|
```
|
179
181
|
|
180
182
|
*The methods above require to be authenticated as the channel’s content owner (see below).*
|
@@ -241,6 +243,7 @@ video.dislikes to: 2.days.ago #=> {Tue, 27 May 2014 => 0.0, Wed, 28 May 2014 =>
|
|
241
243
|
video.shares since: 7.days.ago, until: 7.days.ago #=> {Wed, 28 May 2014 => 3.0}
|
242
244
|
|
243
245
|
video.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}…}
|
246
|
+
video.viewer_percentage(gender: :female) #=> 49.12
|
244
247
|
```
|
245
248
|
|
246
249
|
*The methods above require to be authenticated as the video’s owner (see below).*
|
@@ -258,6 +261,7 @@ video.shares since: 7.days.ago, until: 7.days.ago #=> {Wed, 28 May 2014 => 3.0}
|
|
258
261
|
video.impressions_on 5.days.ago #=> 157.0
|
259
262
|
|
260
263
|
video.viewer_percentages #=> {female: {'18-24' => 12.12, '25-34' => 16.16,…}…}
|
264
|
+
video.viewer_percentage(gender: :female) #=> 49.12
|
261
265
|
```
|
262
266
|
|
263
267
|
*The methods above require to be authenticated as the video’s content owner (see below).*
|
@@ -13,10 +13,16 @@ module Yt
|
|
13
13
|
# '25-34', '35-44', '45-54', '55-64', '65-')
|
14
14
|
# @example Return the % of male viewers of a channel older than 64
|
15
15
|
# channel.viewer_percentages[:male]['65-'] #=> 12.02
|
16
|
+
# @!method viewer_percentage(filters = {})
|
17
|
+
# @return [Float] the percentage of viewer matching the filters.
|
18
|
+
# @param [Hash] filters The type of viewers to be accounted for.
|
19
|
+
# @option filters [Symbol] :gender Either :male or :female.
|
20
|
+
# @example Return the % of male viewers of a video
|
21
|
+
# channel.viewer_percentage(gender: :male) #=> 52.02
|
16
22
|
|
17
|
-
# Defines
|
23
|
+
# Defines two public instance methods to access the viewer percentages of
|
18
24
|
# a resource for a specific metric.
|
19
|
-
# @example Adds +viewer_percentages+ on
|
25
|
+
# @example Adds +viewer_percentages+ and +viewer_percentage+ on Channel.
|
20
26
|
# class Channel < Resource
|
21
27
|
# has_viewer_percentages
|
22
28
|
# end
|
@@ -24,6 +30,7 @@ module Yt
|
|
24
30
|
require 'yt/collections/viewer_percentages'
|
25
31
|
|
26
32
|
define_viewer_percentages_method
|
33
|
+
define_viewer_percentage_method
|
27
34
|
end
|
28
35
|
|
29
36
|
private
|
@@ -34,6 +41,12 @@ module Yt
|
|
34
41
|
@viewer_percentages ||= Collections::ViewerPercentages.of(self).all
|
35
42
|
end
|
36
43
|
end
|
44
|
+
|
45
|
+
def define_viewer_percentage_method
|
46
|
+
define_method :viewer_percentage do |filters = {}|
|
47
|
+
viewer_percentages[filters[:gender]].values.sum.round(2)
|
48
|
+
end
|
49
|
+
end
|
37
50
|
end
|
38
51
|
end
|
39
52
|
end
|
data/lib/yt/version.rb
CHANGED
@@ -259,6 +259,9 @@ describe Yt::Channel, :partner do
|
|
259
259
|
expect(channel.viewer_percentages[:male]['45-54']).to be_a Float
|
260
260
|
expect(channel.viewer_percentages[:male]['55-64']).to be_a Float
|
261
261
|
expect(channel.viewer_percentages[:male]['65-']).to be_a Float
|
262
|
+
|
263
|
+
expect(channel.viewer_percentage(gender: :male)).to be_a Float
|
264
|
+
expect(channel.viewer_percentage(gender: :female)).to be_a Float
|
262
265
|
end
|
263
266
|
end
|
264
267
|
|
@@ -246,6 +246,9 @@ describe Yt::Video, :partner do
|
|
246
246
|
expect(video.viewer_percentages[:male]['45-54']).to be_a Float
|
247
247
|
expect(video.viewer_percentages[:male]['55-64']).to be_a Float
|
248
248
|
expect(video.viewer_percentages[:male]['65-']).to be_a Float
|
249
|
+
|
250
|
+
expect(video.viewer_percentage(gender: :male)).to be_a Float
|
251
|
+
expect(video.viewer_percentage(gender: :female)).to be_a Float
|
249
252
|
end
|
250
253
|
end
|
251
254
|
end
|