yt 0.30.1 → 0.31.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85dc2f5c2b7be22fbac90192e295572b04c55a42
4
- data.tar.gz: 4936ddb4ad8fecf00ea6da4a50816543ffae0e13
3
+ metadata.gz: a91b5314ec281538331cb88409f06f7f40c35480
4
+ data.tar.gz: f1efe786ae1b22c549374e7cf9530c02066e9864
5
5
  SHA512:
6
- metadata.gz: 0b13072d264a684c8985a4c992546b6f6656ad63658378a735b640384838b51cd33230f1480a49af385a94ead440d9f9fd4a70817eae2faa8f40dd8d3a13484b
7
- data.tar.gz: 863c77c4356e5da31f0ab40dbd3ce6bf1d56ac7225a359a1cccf05733b2dfb1b5176b5087de7fecbdf22ef3c2766b5dcc918a308ceae9d856930e4fd4bbe074a
6
+ metadata.gz: 296e9759c4daefafb703eaa4522a4171a026997acbbc643c6b758fbfca35b75073377fdc92cfc178b27a29b010b7a3ffea3cbc5cc91dadcc3ef7efc7d8b13149
7
+ data.tar.gz: 83eea64183b8516e94050821269a0f444698c5c0e75f32d0f8d5e9f93e43987c7116175ec02619fb774183e87e7d551c319b7dc8cc8543a11c7004e0121959d2
data/CHANGELOG.md CHANGED
@@ -6,6 +6,21 @@ 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.31.1 - 2017-06-03
10
+
11
+ * [FEATURE] Add `by: :youtube_product` option for reports.
12
+ * [FEATURE] Add `Yt::Collections::Reports::YOUTUBE_PRODUCTS` to list all YouTube products (KIDS, GAMING, etc) supported by YouTube Analytics API.
13
+ * [FEATURE] Add more operating system dimensions to `Yt::Collections::Reports::OPERATING_SYSTEMS`.
14
+
15
+ ## 0.31.0 - 2017-06-02
16
+
17
+ **How to upgrade**
18
+
19
+ If your code calls `.uniques` it should be removed because this metric has been
20
+ no longer supported by YouTube API as of [October 31, 2016](https://developers.google.com/youtube/analytics/revision_history#september-27-2016).
21
+
22
+ * [REMOVAL] Remove `#uniques` method for channels, videos and video groups.
23
+
9
24
  ## 0.30.1 - 2017-04-14
10
25
 
11
26
  * [IMPROVEMENT] Retry 3 times if YouTube responds with 503 Backend Error
@@ -44,7 +59,7 @@ Finally note that this also remove the class `Yt::Description`. This class
44
59
  was private API, so this change should not affect developers.
45
60
 
46
61
  * [REMOVAL] Remove the option to initialize resources by URL.
47
- * [REMOVAL] Remove 'Yt::Resource.username`
62
+ * [REMOVAL] Remove `Yt::Resource.username`
48
63
  * [REMOVAL] Remove `Yt::URL` (extracted into separate gem)
49
64
  * [REMOVAL] Remove `Yt::Description` (now simply a String).
50
65
 
@@ -243,7 +243,7 @@ module Yt
243
243
 
244
244
  only = options.fetch :only, []
245
245
  reports = Collections::Reports.of(self).tap do |reports|
246
- reports.metrics = self.class.instance_variable_get(:@metrics).select{|k, v| k.in? only}
246
+ reports.metrics = self.class.instance_variable_get(:@metrics).select{|k, v| k.in? only}
247
247
  end
248
248
  reports.within date_range, country, state, dimension, videos
249
249
  end unless defined?(reports)
@@ -310,4 +310,4 @@ module Yt
310
310
  end
311
311
  end
312
312
  end
313
- end
313
+ end
@@ -19,6 +19,7 @@ module Yt
19
19
  hash[:playlist] = {name: 'playlist', parse: ->(playlist_id, *values) { @metrics.keys.zip(values.map{|v| {playlist_id => v}}).to_h} }
20
20
  hash[:device_type] = {name: 'deviceType', parse: ->(type, *values) {@metrics.keys.zip(values.map{|v| {DEVICE_TYPES.key(type) => v}}).to_h} }
21
21
  hash[:operating_system] = {name: 'operatingSystem', parse: ->(os, *values) {@metrics.keys.zip(values.map{|v| {OPERATING_SYSTEMS.key(os) => v}}).to_h} }
22
+ hash[:youtube_product] = {name: 'youtubeProduct', parse: ->(product, *values) {@metrics.keys.zip(values.map{|v| {YOUTUBE_PRODUCTS.key(product) => v}}).to_h} }
22
23
  hash[:country] = {name: 'country', parse: ->(country_code, *values) { @metrics.keys.zip(values.map{|v| {country_code => v}}).to_h} }
23
24
  hash[:state] = {name: 'province', parse: ->(country_and_state_code, *values) { @metrics.keys.zip(values.map{|v| {country_and_state_code[3..-1] => v}}).to_h} }
24
25
  hash[:gender_age_group] = {name: 'gender,ageGroup', parse: ->(gender, *values) { [gender.downcase.to_sym, *values] }}
@@ -68,6 +69,14 @@ module Yt
68
69
  unsubscribed: 'UNSUBSCRIBED'
69
70
  }
70
71
 
72
+ # @see https://developers.google.com/youtube/analytics/v1/dimsmets/dims#youtubeProduct
73
+ YOUTUBE_PRODUCTS = {
74
+ core: 'CORE',
75
+ gaming: 'GAMING',
76
+ kids: 'KIDS',
77
+ unknown: 'UNKNOWN'
78
+ }
79
+
71
80
  # @see https://developers.google.com/youtube/analytics/v1/dimsmets/dims#Device_Dimensions
72
81
  DEVICE_TYPES = {
73
82
  desktop: 'DESKTOP',
@@ -85,6 +94,7 @@ module Yt
85
94
  blackberry: 'BLACKBERRY',
86
95
  chromecast: 'CHROMECAST',
87
96
  docomo: 'DOCOMO',
97
+ firefox: 'FIREFOX',
88
98
  hiptop: 'HIPTOP',
89
99
  ios: 'IOS',
90
100
  linux: 'LINUX',
@@ -94,8 +104,10 @@ module Yt
94
104
  other: 'OTHER',
95
105
  playstation: 'PLAYSTATION',
96
106
  playstation_vita: 'PLAYSTATION_VITA',
107
+ realmedia: 'REALMEDIA',
97
108
  smart_tv: 'SMART_TV',
98
109
  symbian: 'SYMBIAN',
110
+ tizen: 'TIZEN',
99
111
  webos: 'WEBOS',
100
112
  wii: 'WII',
101
113
  windows: 'WINDOWS',
@@ -107,9 +119,9 @@ module Yt
107
119
 
108
120
  def within(days_range, country, state, dimension, videos, max_retries = 3)
109
121
  @days_range = days_range
110
- @dimension = dimension
111
122
  @country = country
112
123
  @state = state
124
+ @dimension = dimension
113
125
  @videos = videos
114
126
  if dimension == :gender_age_group # array of array
115
127
  Hash.new{|h,k| h[k] = Hash.new 0.0}.tap do |hash|
@@ -114,9 +114,6 @@ module Yt
114
114
  # @macro report_by_channel_dimensions
115
115
  has_report :views, Integer
116
116
 
117
- # @macro report_by_day
118
- has_report :uniques, Integer
119
-
120
117
  # @macro report_by_channel_dimensions
121
118
  has_report :estimated_minutes_watched, Integer
122
119
 
@@ -317,4 +314,4 @@ module Yt
317
314
  end
318
315
  end
319
316
  end
320
- end
317
+ end
@@ -402,9 +402,6 @@ module Yt
402
402
  # @macro report_by_video_dimensions
403
403
  has_report :views, Integer
404
404
 
405
- # @macro report_by_day
406
- has_report :uniques, Integer
407
-
408
405
  # @macro report_by_video_dimensions
409
406
  has_report :estimated_minutes_watched, Integer
410
407
 
@@ -37,9 +37,6 @@ module Yt
37
37
  # @macro report_by_video_dimensions
38
38
  has_report :views, Integer
39
39
 
40
- # @macro report_by_day
41
- has_report :uniques, Integer
42
-
43
40
  # @macro report_by_video_dimensions
44
41
  has_report :estimated_minutes_watched, Integer
45
42
 
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.30.1'
2
+ VERSION = '0.31.1'
3
3
  end
@@ -11,7 +11,7 @@ describe Yt::Channel, :partner do
11
11
  let(:id) { ENV['YT_TEST_PARTNER_CHANNEL_ID'] }
12
12
 
13
13
  describe 'multiple reports can be retrieved at once' do
14
- metrics = {views: Integer, uniques: Integer,
14
+ metrics = {views: Integer,
15
15
  estimated_minutes_watched: Integer, comments: Integer, likes: Integer,
16
16
  dislikes: Integer, shares: Integer, subscribers_gained: Integer,
17
17
  subscribers_lost: Integer,
@@ -59,7 +59,7 @@ describe Yt::Channel, :partner do
59
59
  end
60
60
  end
61
61
 
62
- [:views, :uniques, :comments, :likes, :dislikes, :shares,
62
+ [:views, :comments, :likes, :dislikes, :shares,
63
63
  :subscribers_gained, :subscribers_lost,
64
64
  :videos_added_to_playlists, :videos_removed_from_playlists,
65
65
  :estimated_minutes_watched, :average_view_duration,
@@ -487,56 +487,6 @@ describe Yt::Channel, :partner do
487
487
  end
488
488
  end
489
489
 
490
- describe 'uniques can be retrieved for a single country' do
491
- let(:country_code) { 'US' }
492
- let(:uniques) { channel.uniques since: date, by: by, in: location }
493
- let(:date) { 4.days.ago }
494
-
495
- context 'and grouped by day' do
496
- let(:by) { :day }
497
-
498
- context 'with the :in option set to the country code' do
499
- let(:location) { country_code }
500
- it { expect(uniques.keys.min).to eq date.to_date }
501
- end
502
-
503
- context 'with the :in option set to {country: country code}' do
504
- let(:location) { {country: country_code} }
505
- it { expect(uniques.keys.min).to eq date.to_date }
506
- end
507
- end
508
- end
509
-
510
- describe 'uniques can be retrieved for a single US state' do
511
- let(:state_code) { 'NY' }
512
- let(:result) { channel.uniques since: date, by: by, in: location }
513
- let(:date) { 4.days.ago }
514
-
515
- context 'and grouped by day' do
516
- let(:by) { :day }
517
-
518
- context 'with the :in option set to {state: state code}' do
519
- let(:location) { {state: state_code} }
520
- it { expect(result.keys.min).to eq date.to_date }
521
- end
522
-
523
- context 'with the :in option set to {country: "US", state: state code}' do
524
- let(:location) { {country: 'US', state: state_code} }
525
- it { expect(result.keys.min).to eq date.to_date }
526
- end
527
- end
528
- end
529
-
530
- describe 'uniques can be grouped by day' do
531
- let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
532
- let(:keys) { range.values }
533
-
534
- specify 'with the :by option set to :day' do
535
- uniques = channel.uniques range.merge by: :day
536
- expect(uniques.keys).to eq range.values
537
- end
538
- end
539
-
540
490
  describe 'comments can be retrieved for a single country' do
541
491
  let(:country_code) { 'US' }
542
492
  let(:comments) { channel.comments since: date, by: by, in: location }
@@ -62,7 +62,7 @@ describe Yt::VideoGroup, :partner do
62
62
  end
63
63
 
64
64
  describe 'multiple reports can be retrieved at once' do
65
- metrics = {views: Integer, uniques: Integer,
65
+ metrics = {views: Integer,
66
66
  estimated_minutes_watched: Integer, comments: Integer, likes: Integer,
67
67
  dislikes: Integer, shares: Integer, subscribers_gained: Integer,
68
68
  subscribers_lost: Integer,
@@ -13,7 +13,7 @@ describe Yt::Video, :partner do
13
13
  it { expect{video.advertising_options_set}.not_to raise_error }
14
14
  end
15
15
 
16
- [:views, :uniques, :comments, :likes, :dislikes, :shares,
16
+ [:views, :comments, :likes, :dislikes, :shares,
17
17
  :subscribers_gained, :subscribers_lost,
18
18
  :videos_added_to_playlists, :videos_removed_from_playlists,
19
19
  :estimated_minutes_watched, :average_view_duration,
@@ -174,7 +174,7 @@ describe Yt::Video, :partner do
174
174
  end
175
175
 
176
176
  describe 'multiple reports can be retrieved at once' do
177
- metrics = {views: Integer, uniques: Integer,
177
+ metrics = {views: Integer,
178
178
  estimated_minutes_watched: Integer, comments: Integer, likes: Integer,
179
179
  dislikes: Integer, shares: Integer, subscribers_gained: Integer,
180
180
  subscribers_lost: Integer,
@@ -369,6 +369,16 @@ describe Yt::Video, :partner do
369
369
  end
370
370
  end
371
371
 
372
+ describe 'views can be grouped by YouTube product' do
373
+ let(:keys) { Yt::Collections::Reports::YOUTUBE_PRODUCTS.keys }
374
+
375
+ specify 'with the :by option set to :youtube_product' do
376
+ views = video.views by: :youtube_product
377
+ expect(views.keys - keys).to be_empty
378
+ expect(views.values).to all(be_an Integer)
379
+ end
380
+ end
381
+
372
382
  describe 'views can be grouped by country' do
373
383
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
374
384
 
@@ -412,36 +422,6 @@ describe Yt::Video, :partner do
412
422
  end
413
423
  end
414
424
 
415
- describe 'uniques can be retrieved for a single US state' do
416
- let(:state_code) { 'NY' }
417
- let(:result) { video.uniques since: date, by: by, in: location }
418
- let(:date) { 4.days.ago }
419
-
420
- context 'and grouped by day' do
421
- let(:by) { :day }
422
-
423
- context 'with the :in option set to {state: state code}' do
424
- let(:location) { {state: state_code} }
425
- it { expect(result.keys.min).to eq date.to_date }
426
- end
427
-
428
- context 'with the :in option set to {country: "US", state: state code}' do
429
- let(:location) { {country: 'US', state: state_code} }
430
- it { expect(result.keys.min).to eq date.to_date }
431
- end
432
- end
433
- end
434
-
435
- describe 'uniques can be grouped by day' do
436
- let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
437
- let(:keys) { range.values }
438
-
439
- specify 'with the :by option set to :day' do
440
- uniques = video.uniques range.merge by: :day
441
- expect(uniques.keys).to eq range.values
442
- end
443
- end
444
-
445
425
  describe 'comments can be grouped by day' do
446
426
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
447
427
  let(:keys) { range.values }
data/yt.gemspec CHANGED
@@ -30,4 +30,4 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'rake' #, '~> 10.0'
31
31
  spec.add_development_dependency 'yard' #, '~> 0.8.0'
32
32
  spec.add_development_dependency 'coveralls' #, '~> 0.7.0'
33
- end
33
+ end
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.30.1
4
+ version: 0.31.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-14 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport