yt 0.24.10 → 0.25.0

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: c98cdb00d48f25f00cd745199f5eff7615175a71
4
- data.tar.gz: 0fca3d4e3194b62e72ecd9816e2e75f0cc1673ea
3
+ metadata.gz: c48d92d6630a165285e513cfac2088f1db048ecd
4
+ data.tar.gz: 06daf58ac858adcc4530aa48020d75f54fc2ece9
5
5
  SHA512:
6
- metadata.gz: 1aa68d422315ff7e28ddaffce2ddd6a6d975df106fb4bc7b7373082633587e42539067f4e815c7fd9aa2f2b15798e89e960528778062bc0665f447c667213661
7
- data.tar.gz: 736279c988e54f5f4231cbaafe47dbf678b2c3ce01a553d66f75f00399089e91e9810313ffb5dd2c0ea2ac110e7abbd46623e6460ebfb2fc761c4edd878b7744
6
+ metadata.gz: e884999cfe988df346878d3ddadd92192b13a05f83df035b452baf7ee7ee2f1bc3987ade999138a2a87af71a443beb9ea82ea038a948a95207054b2594d866ff
7
+ data.tar.gz: 80a2a1a53bd6faf28b3f629a4b7a051931e9be437428497237c2fdaa235c8bf3c1750094896aefd3c172277ab10e337b3317e19d243049608312eadf0a547ae8
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.25.0 - 2015-06-29
10
+
11
+ **How to upgrade**
12
+
13
+ If your code expects 10 videos when calling a report `by: :video` or
14
+ `by: :related_video`, beware that those reports now return 25 videos.
15
+ If you only need the first 10, just add `.first(10)` to your result.
16
+ For instance: `channel.views(by: :video).first(10).to_h`.
17
+
18
+ * [ENHANCEMENT] Return 25 results on reports by video / related video.
19
+ * [FEATURE] New `playback_based_cpm` report for channels and videos.
20
+
9
21
  ## 0.24.10 - 2015-06-25
10
22
 
11
23
  * [BUGFIX] Don't break reports `by: :playlist` when trying to fetch their part by limiting to result to 50 playlists.
@@ -111,7 +123,7 @@ If your code expects any of the following method to return Float values, then
111
123
  be aware that they now return Integer. You can still call `to_f` if you do need
112
124
  a Float: views, `comments`, `likes`, `dislikes`, `shares`, `subscribers_gained`,
113
125
  `subscribers_lost`, `favorites_added`, `favorites_removed`, `annotations`,
114
- `impressions`, `monetized_plybacks`, `playlist_starts`.
126
+ `impressions`, `monetized_playbacks`, `playlist_starts`.
115
127
 
116
128
  * [ENHANCEMENT] Return `Integer` values for reports that can never return decimal digits.
117
129
  * [FEATURE] New `by: :range` option for reports, to return a metric without dimensions (that is, for the whole range)
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.24.10'
44
+ gem 'yt', '~> 0.25.0'
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*)
@@ -128,10 +128,15 @@ module Yt
128
128
  params['end-date'] = @days_range.end
129
129
  params['metrics'] = @metrics.keys.join(',').to_s.camelize(:lower)
130
130
  params['dimensions'] = DIMENSIONS[@dimension][:name] unless @dimension == :range
131
- params['max-results'] = 10 if @dimension == :video
132
- params['max-results'] = 50 if @dimension == :playlist
131
+ params['max-results'] = 50 if @dimension.in? [:playlist, :video]
133
132
  params['max-results'] = 25 if @dimension.in? [:embedded_player_location, :related_video, :search_term, :referrer]
134
- params['sort'] = "-#{@metrics.keys.join(',').to_s.camelize(:lower)}" if @dimension.in? [:video, :playlist, :embedded_player_location, :related_video, :search_term, :referrer]
133
+ if @dimension.in? [:video, :playlist, :embedded_player_location, :related_video, :search_term, :referrer]
134
+ if @metrics.keys == [:earnings, :estimated_minutes_watched]
135
+ params['sort'] = '-earnings'
136
+ else
137
+ params['sort'] = "-#{@metrics.keys.join(',').to_s.camelize(:lower)}"
138
+ end
139
+ end
135
140
  params[:filters] = "video==#{@videos.join ','}" if @videos
136
141
  params[:filters] = ((params[:filters] || '').split(';') + ["country==US"]).compact.uniq.join(';') if @dimension == :state && !@state
137
142
  params[:filters] = ((params[:filters] || '').split(';') + ["country==#{@country}"]).compact.uniq.join(';') if @country && !@state
@@ -165,6 +165,9 @@ module Yt
165
165
  # @macro report_by_day_and_country
166
166
  has_report :monetized_playbacks, Integer
167
167
 
168
+ # @macro report_by_day_and_country
169
+ has_report :playback_based_cpm, Float
170
+
168
171
  ### STATISTICS ###
169
172
 
170
173
  has_one :statistics_set
@@ -444,6 +444,9 @@ module Yt
444
444
  # @macro report_by_day_and_country
445
445
  has_report :monetized_playbacks, Integer
446
446
 
447
+ # @macro report_by_day_and_country
448
+ has_report :playback_based_cpm, Float
449
+
447
450
  ### STATISTICS ###
448
451
 
449
452
  has_one :statistics_set
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.24.10'
2
+ VERSION = '0.25.0'
3
3
  end
@@ -196,6 +196,7 @@ describe Yt::Channel, :device_app do
196
196
  expect{channel.earnings}.to raise_error Yt::Errors::Unauthorized
197
197
  expect{channel.impressions}.to raise_error Yt::Errors::Unauthorized
198
198
  expect{channel.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
199
+ expect{channel.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
199
200
 
200
201
  expect{channel.views_on 3.days.ago}.not_to raise_error
201
202
  expect{channel.comments_on 3.days.ago}.not_to raise_error
@@ -302,6 +302,7 @@ describe Yt::Video, :device_app do
302
302
  expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
303
303
  expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
304
304
  expect{video.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
305
+ expect{video.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
305
306
  expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
306
307
 
307
308
  expect{video.views_on 3.days.ago}.not_to raise_error
@@ -19,7 +19,7 @@ describe Yt::Channel, :partner do
19
19
  average_view_percentage: Float, annotation_clicks: Integer,
20
20
  annotation_click_through_rate: Float,
21
21
  annotation_close_rate: Float, earnings: Float, impressions: Integer,
22
- monetized_playbacks: Integer}
22
+ monetized_playbacks: Integer, playback_based_cpm: Float}
23
23
 
24
24
  specify 'by day, and are chronologically sorted' do
25
25
  range = {since: 5.days.ago.to_date, until: 3.days.ago.to_date}
@@ -60,7 +60,7 @@ describe Yt::Channel, :partner do
60
60
  :subscribers_gained, :subscribers_lost, :favorites_added,
61
61
  :favorites_removed, :estimated_minutes_watched, :average_view_duration,
62
62
  :average_view_percentage, :impressions, :monetized_playbacks,
63
- :annotation_clicks, :annotation_click_through_rate,
63
+ :annotation_clicks, :annotation_click_through_rate, :playback_based_cpm,
64
64
  :annotation_close_rate, :earnings].each do |metric|
65
65
  describe "#{metric} can be retrieved for a range of days" do
66
66
  let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
@@ -118,7 +118,7 @@ describe Yt::Channel, :partner do
118
118
  annotation_clicks: Integer, annotation_click_through_rate: Float,
119
119
  favorites_added: Integer, favorites_removed: Integer,
120
120
  average_view_percentage: Float, impressions: Integer,
121
- shares: Integer,
121
+ shares: Integer, playback_based_cpm: Float,
122
122
  monetized_playbacks: Integer, annotation_close_rate: Float,
123
123
  earnings: Float}.each do |metric, type|
124
124
  describe "#{metric} can be retrieved for a specific day" do
@@ -1477,6 +1477,61 @@ describe Yt::Channel, :partner do
1477
1477
  end
1478
1478
  end
1479
1479
 
1480
+ describe 'playback-based CPM can be retrieved for a single country' do
1481
+ let(:country_code) { 'US' }
1482
+ let(:playback_based_cpm) { channel.playback_based_cpm since: date, by: by, in: location }
1483
+ let(:date) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
1484
+
1485
+ context 'and grouped by day' do
1486
+ let(:by) { :day }
1487
+
1488
+ context 'with the :in option set to the country code' do
1489
+ let(:location) { country_code }
1490
+ it { expect(playback_based_cpm.keys.min).to eq date.to_date }
1491
+ end
1492
+
1493
+ context 'with the :in option set to {country: country code}' do
1494
+ let(:location) { {country: country_code} }
1495
+ it { expect(playback_based_cpm.keys.min).to eq date.to_date }
1496
+ end
1497
+ end
1498
+
1499
+ context 'and grouped by country' do
1500
+ let(:by) { :country }
1501
+
1502
+ context 'with the :in option set to the country code' do
1503
+ let(:location) { country_code }
1504
+ it { expect(playback_based_cpm.keys).to eq [country_code] }
1505
+ end
1506
+
1507
+ context 'with the :in option set to {country: country code}' do
1508
+ let(:location) { {country: country_code} }
1509
+ it { expect(playback_based_cpm.keys).to eq [country_code] }
1510
+ end
1511
+ end
1512
+ end
1513
+
1514
+ describe 'playback-based CPM can be grouped by day' do
1515
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1516
+ let(:keys) { range.values }
1517
+
1518
+ specify 'with the :by option set to :day' do
1519
+ playback_based_cpm = channel.playback_based_cpm range.merge by: :day
1520
+ expect(playback_based_cpm.keys).to eq range.values
1521
+ end
1522
+ end
1523
+
1524
+ describe 'playback-based CPM can be grouped by country' do
1525
+ let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
1526
+
1527
+ specify 'with the :by option set to :country' do
1528
+ playbacks = channel.playback_based_cpm range.merge by: :country
1529
+ expect(playbacks.keys).to all(be_a String)
1530
+ expect(playbacks.keys.map(&:length).uniq).to eq [2]
1531
+ expect(playbacks.values).to all(be_a Float)
1532
+ end
1533
+ end
1534
+
1480
1535
  describe 'annotation clicks can be retrieved for a single country' do
1481
1536
  let(:country_code) { 'US' }
1482
1537
  let(:annotation_clicks) { channel.annotation_clicks since: date, by: by, in: location }
@@ -17,7 +17,7 @@ describe Yt::Video, :partner do
17
17
  :subscribers_gained, :subscribers_lost, :favorites_added,
18
18
  :favorites_removed, :estimated_minutes_watched, :average_view_duration,
19
19
  :average_view_percentage, :impressions, :monetized_playbacks,
20
- :annotation_clicks, :annotation_click_through_rate,
20
+ :annotation_clicks, :annotation_click_through_rate, :playback_based_cpm,
21
21
  :annotation_close_rate, :earnings].each do |metric|
22
22
  describe "#{metric} can be retrieved for a range of days" do
23
23
  let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
@@ -924,6 +924,27 @@ describe Yt::Video, :partner do
924
924
  end
925
925
  end
926
926
 
927
+ describe 'playback-based CPM can be grouped by day' do
928
+ let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
929
+ let(:keys) { range.values }
930
+
931
+ specify 'with the :by option set to :day' do
932
+ playback_based_cpm = video.playback_based_cpm range.merge by: :day
933
+ expect(playback_based_cpm.keys).to eq range.values
934
+ end
935
+ end
936
+
937
+ describe 'playback-based CPM can be grouped by country' do
938
+ let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
939
+
940
+ specify 'with the :by option set to :country' do
941
+ playbacks = video.playback_based_cpm range.merge by: :country
942
+ expect(playbacks.keys).to all(be_a String)
943
+ expect(playbacks.keys.map(&:length).uniq).to eq [2]
944
+ expect(playbacks.values).to all(be_a Float)
945
+ end
946
+ end
947
+
927
948
  describe 'annotation clicks can be retrieved for a single US state' do
928
949
  let(:state_code) { 'CA' }
929
950
  let(:clicks) { video.annotation_clicks since: date, by: by, in: location }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.10
4
+ version: 0.25.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-25 00:00:00.000000000 Z
11
+ date: 2015-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport