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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d59d615fd8bb939c84404f9cda73c12135b8ca68
4
- data.tar.gz: dc7a6b4c8421c86f2b568263c408876957f7907d
3
+ metadata.gz: f68323942ee8bbe17cfaee4597c9e608f33c118d
4
+ data.tar.gz: 745a59c51f7ab201a9fa01f14ddf1613ccf0c8fd
5
5
  SHA512:
6
- metadata.gz: d08d0ca9a0bb9beeb223f1f26739dbdff3226a969a6d7a1060b6038c8c9a79ae1c969535555994166cd23c367816e399a53a31830868e443fc834f203623df5d
7
- data.tar.gz: 2d30fd95cc78bc93b838bf165c2546298de4f192944ead0330d1a20be923e0c470f41a3edce61624565f407d562125917f32eac98e44bba109fd240351ab3977
6
+ metadata.gz: 470da624d81c6433c66346e55a4d375fec56bf6f10d7d1e730e20956f6afcde80719c95656a0809c4b27e39325e701886076c7c0f5617bd6311dc1e5b06e338d
7
+ data.tar.gz: fa26426355b8cb643494e483cb1e729d09c1413e5ba78c2d67bee1121a036e5c53ac4031dc86c257e3228c060fe7869ed67580dcd94fdbff48719d357d941076
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.7.10)
4
+ yt (0.7.11)
5
5
  activesupport
6
6
 
7
7
  GEM
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.10'
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 a public instance methods to access the viewer percentages of
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 a Channel resource.
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
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.7.10'
2
+ VERSION = '0.7.11'
3
3
  end
@@ -102,6 +102,7 @@ describe Yt::Channel, :device_app do
102
102
 
103
103
  it 'returns valid reports for channel-related demographics' do
104
104
  expect{channel.viewer_percentages}.not_to raise_error
105
+ expect{channel.viewer_percentage}.not_to raise_error
105
106
  end
106
107
  end
107
108
 
@@ -101,6 +101,7 @@ describe Yt::Video, :device_app do
101
101
 
102
102
  it 'returns valid reports for video-related demographics' do
103
103
  expect{video.viewer_percentages}.not_to raise_error
104
+ expect{video.viewer_percentage}.not_to raise_error
104
105
  end
105
106
  end
106
107
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo