yt-andrewroth 0.25.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. data/.gitignore +27 -0
  2. data/.rspec +3 -0
  3. data/.travis.yml +9 -0
  4. data/.yardopts +5 -0
  5. data/CHANGELOG.md +732 -0
  6. data/Gemfile +4 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +489 -0
  9. data/Rakefile +11 -0
  10. data/YOUTUBE_IT.md +835 -0
  11. data/bin/yt +30 -0
  12. data/gemfiles/Gemfile.activesupport-3.x +4 -0
  13. data/gemfiles/Gemfile.activesupport-4.x +4 -0
  14. data/lib/yt.rb +21 -0
  15. data/lib/yt/actions/base.rb +32 -0
  16. data/lib/yt/actions/delete.rb +19 -0
  17. data/lib/yt/actions/delete_all.rb +32 -0
  18. data/lib/yt/actions/insert.rb +42 -0
  19. data/lib/yt/actions/list.rb +139 -0
  20. data/lib/yt/actions/modify.rb +37 -0
  21. data/lib/yt/actions/patch.rb +19 -0
  22. data/lib/yt/actions/update.rb +19 -0
  23. data/lib/yt/associations/has_attribute.rb +55 -0
  24. data/lib/yt/associations/has_authentication.rb +214 -0
  25. data/lib/yt/associations/has_many.rb +22 -0
  26. data/lib/yt/associations/has_one.rb +22 -0
  27. data/lib/yt/associations/has_reports.rb +320 -0
  28. data/lib/yt/collections/advertising_options_sets.rb +34 -0
  29. data/lib/yt/collections/annotations.rb +62 -0
  30. data/lib/yt/collections/assets.rb +58 -0
  31. data/lib/yt/collections/authentications.rb +47 -0
  32. data/lib/yt/collections/base.rb +62 -0
  33. data/lib/yt/collections/channels.rb +31 -0
  34. data/lib/yt/collections/claim_histories.rb +34 -0
  35. data/lib/yt/collections/claims.rb +56 -0
  36. data/lib/yt/collections/content_details.rb +30 -0
  37. data/lib/yt/collections/content_owner_details.rb +34 -0
  38. data/lib/yt/collections/content_owners.rb +32 -0
  39. data/lib/yt/collections/device_flows.rb +23 -0
  40. data/lib/yt/collections/file_details.rb +30 -0
  41. data/lib/yt/collections/ids.rb +27 -0
  42. data/lib/yt/collections/live_streaming_details.rb +30 -0
  43. data/lib/yt/collections/ownerships.rb +34 -0
  44. data/lib/yt/collections/partnered_channels.rb +28 -0
  45. data/lib/yt/collections/players.rb +30 -0
  46. data/lib/yt/collections/playlist_items.rb +53 -0
  47. data/lib/yt/collections/playlists.rb +28 -0
  48. data/lib/yt/collections/policies.rb +28 -0
  49. data/lib/yt/collections/ratings.rb +23 -0
  50. data/lib/yt/collections/references.rb +46 -0
  51. data/lib/yt/collections/related_playlists.rb +43 -0
  52. data/lib/yt/collections/reports.rb +161 -0
  53. data/lib/yt/collections/resources.rb +57 -0
  54. data/lib/yt/collections/resumable_sessions.rb +51 -0
  55. data/lib/yt/collections/snippets.rb +27 -0
  56. data/lib/yt/collections/statistics_sets.rb +30 -0
  57. data/lib/yt/collections/statuses.rb +27 -0
  58. data/lib/yt/collections/subscribed_channels.rb +46 -0
  59. data/lib/yt/collections/subscribers.rb +33 -0
  60. data/lib/yt/collections/subscriptions.rb +50 -0
  61. data/lib/yt/collections/user_infos.rb +36 -0
  62. data/lib/yt/collections/video_categories.rb +35 -0
  63. data/lib/yt/collections/videos.rb +137 -0
  64. data/lib/yt/config.rb +54 -0
  65. data/lib/yt/errors/forbidden.rb +13 -0
  66. data/lib/yt/errors/missing_auth.rb +81 -0
  67. data/lib/yt/errors/no_items.rb +13 -0
  68. data/lib/yt/errors/request_error.rb +74 -0
  69. data/lib/yt/errors/server_error.rb +13 -0
  70. data/lib/yt/errors/unauthorized.rb +50 -0
  71. data/lib/yt/models/account.rb +216 -0
  72. data/lib/yt/models/advertising_options_set.rb +38 -0
  73. data/lib/yt/models/annotation.rb +132 -0
  74. data/lib/yt/models/asset.rb +111 -0
  75. data/lib/yt/models/asset_metadata.rb +38 -0
  76. data/lib/yt/models/asset_snippet.rb +46 -0
  77. data/lib/yt/models/authentication.rb +83 -0
  78. data/lib/yt/models/base.rb +32 -0
  79. data/lib/yt/models/channel.rb +302 -0
  80. data/lib/yt/models/claim.rb +156 -0
  81. data/lib/yt/models/claim_event.rb +67 -0
  82. data/lib/yt/models/claim_history.rb +29 -0
  83. data/lib/yt/models/configuration.rb +70 -0
  84. data/lib/yt/models/content_detail.rb +65 -0
  85. data/lib/yt/models/content_owner.rb +48 -0
  86. data/lib/yt/models/content_owner_detail.rb +18 -0
  87. data/lib/yt/models/description.rb +58 -0
  88. data/lib/yt/models/device_flow.rb +16 -0
  89. data/lib/yt/models/file_detail.rb +21 -0
  90. data/lib/yt/models/id.rb +9 -0
  91. data/lib/yt/models/iterator.rb +16 -0
  92. data/lib/yt/models/live_streaming_detail.rb +23 -0
  93. data/lib/yt/models/match_policy.rb +34 -0
  94. data/lib/yt/models/ownership.rb +75 -0
  95. data/lib/yt/models/player.rb +18 -0
  96. data/lib/yt/models/playlist.rb +218 -0
  97. data/lib/yt/models/playlist_item.rb +112 -0
  98. data/lib/yt/models/policy.rb +36 -0
  99. data/lib/yt/models/policy_rule.rb +124 -0
  100. data/lib/yt/models/rating.rb +37 -0
  101. data/lib/yt/models/reference.rb +172 -0
  102. data/lib/yt/models/resource.rb +136 -0
  103. data/lib/yt/models/resumable_session.rb +52 -0
  104. data/lib/yt/models/right_owner.rb +58 -0
  105. data/lib/yt/models/snippet.rb +50 -0
  106. data/lib/yt/models/statistics_set.rb +26 -0
  107. data/lib/yt/models/status.rb +32 -0
  108. data/lib/yt/models/subscription.rb +38 -0
  109. data/lib/yt/models/timestamp.rb +13 -0
  110. data/lib/yt/models/url.rb +90 -0
  111. data/lib/yt/models/user_info.rb +26 -0
  112. data/lib/yt/models/video.rb +630 -0
  113. data/lib/yt/models/video_category.rb +12 -0
  114. data/lib/yt/request.rb +278 -0
  115. data/lib/yt/version.rb +3 -0
  116. data/spec/collections/claims_spec.rb +30 -0
  117. data/spec/collections/playlist_items_spec.rb +44 -0
  118. data/spec/collections/playlists_spec.rb +27 -0
  119. data/spec/collections/policies_spec.rb +30 -0
  120. data/spec/collections/references_spec.rb +30 -0
  121. data/spec/collections/reports_spec.rb +30 -0
  122. data/spec/collections/subscriptions_spec.rb +25 -0
  123. data/spec/collections/videos_spec.rb +43 -0
  124. data/spec/errors/forbidden_spec.rb +10 -0
  125. data/spec/errors/missing_auth_spec.rb +24 -0
  126. data/spec/errors/no_items_spec.rb +10 -0
  127. data/spec/errors/request_error_spec.rb +44 -0
  128. data/spec/errors/server_error_spec.rb +10 -0
  129. data/spec/errors/unauthorized_spec.rb +10 -0
  130. data/spec/models/account_spec.rb +138 -0
  131. data/spec/models/annotation_spec.rb +180 -0
  132. data/spec/models/asset_spec.rb +20 -0
  133. data/spec/models/channel_spec.rb +127 -0
  134. data/spec/models/claim_event_spec.rb +62 -0
  135. data/spec/models/claim_history_spec.rb +27 -0
  136. data/spec/models/claim_spec.rb +211 -0
  137. data/spec/models/configuration_spec.rb +44 -0
  138. data/spec/models/content_detail_spec.rb +45 -0
  139. data/spec/models/content_owner_detail_spec.rb +6 -0
  140. data/spec/models/description_spec.rb +94 -0
  141. data/spec/models/file_detail_spec.rb +13 -0
  142. data/spec/models/live_streaming_detail_spec.rb +6 -0
  143. data/spec/models/ownership_spec.rb +59 -0
  144. data/spec/models/player_spec.rb +13 -0
  145. data/spec/models/playlist_item_spec.rb +120 -0
  146. data/spec/models/playlist_spec.rb +138 -0
  147. data/spec/models/policy_rule_spec.rb +63 -0
  148. data/spec/models/policy_spec.rb +41 -0
  149. data/spec/models/rating_spec.rb +12 -0
  150. data/spec/models/reference_spec.rb +249 -0
  151. data/spec/models/request_spec.rb +163 -0
  152. data/spec/models/resource_spec.rb +57 -0
  153. data/spec/models/right_owner_spec.rb +71 -0
  154. data/spec/models/snippet_spec.rb +13 -0
  155. data/spec/models/statistics_set_spec.rb +13 -0
  156. data/spec/models/status_spec.rb +13 -0
  157. data/spec/models/subscription_spec.rb +30 -0
  158. data/spec/models/url_spec.rb +78 -0
  159. data/spec/models/video_category_spec.rb +21 -0
  160. data/spec/models/video_spec.rb +669 -0
  161. data/spec/requests/as_account/account_spec.rb +125 -0
  162. data/spec/requests/as_account/authentications_spec.rb +139 -0
  163. data/spec/requests/as_account/channel_spec.rb +259 -0
  164. data/spec/requests/as_account/channels_spec.rb +18 -0
  165. data/spec/requests/as_account/playlist_item_spec.rb +56 -0
  166. data/spec/requests/as_account/playlist_spec.rb +244 -0
  167. data/spec/requests/as_account/resource_spec.rb +18 -0
  168. data/spec/requests/as_account/thumbnail.jpg +0 -0
  169. data/spec/requests/as_account/video.mp4 +0 -0
  170. data/spec/requests/as_account/video_spec.rb +408 -0
  171. data/spec/requests/as_content_owner/account_spec.rb +25 -0
  172. data/spec/requests/as_content_owner/advertising_options_set_spec.rb +15 -0
  173. data/spec/requests/as_content_owner/asset_spec.rb +20 -0
  174. data/spec/requests/as_content_owner/channel_spec.rb +1934 -0
  175. data/spec/requests/as_content_owner/claim_history_spec.rb +20 -0
  176. data/spec/requests/as_content_owner/content_owner_spec.rb +241 -0
  177. data/spec/requests/as_content_owner/match_policy_spec.rb +17 -0
  178. data/spec/requests/as_content_owner/ownership_spec.rb +25 -0
  179. data/spec/requests/as_content_owner/playlist_spec.rb +782 -0
  180. data/spec/requests/as_content_owner/video_spec.rb +1239 -0
  181. data/spec/requests/as_server_app/channel_spec.rb +74 -0
  182. data/spec/requests/as_server_app/playlist_item_spec.rb +30 -0
  183. data/spec/requests/as_server_app/playlist_spec.rb +53 -0
  184. data/spec/requests/as_server_app/video_spec.rb +58 -0
  185. data/spec/requests/as_server_app/videos_spec.rb +40 -0
  186. data/spec/requests/unauthenticated/video_spec.rb +22 -0
  187. data/spec/spec_helper.rb +20 -0
  188. data/spec/support/fail_matcher.rb +15 -0
  189. data/spec/support/global_hooks.rb +48 -0
  190. data/yt.gemspec +32 -0
  191. metadata +416 -0
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/channel'
3
+
4
+ describe Yt::Channel, :server_app do
5
+ subject(:channel) { Yt::Channel.new attrs }
6
+
7
+ context 'given an existing channel ID' do
8
+ let(:attrs) { {id: 'UCxO1tY8h1AhOz0T4ENwmpow'} }
9
+
10
+ it 'returns valid snippet data' do
11
+ expect(channel.snippet).to be_a Yt::Snippet
12
+ expect(channel.title).to be_a String
13
+ expect(channel.description).to be_a Yt::Description
14
+ expect(channel.thumbnail_url).to be_a String
15
+ expect(channel.published_at).to be_a Time
16
+ end
17
+
18
+ it { expect(channel.status).to be_a Yt::Status }
19
+ it { expect(channel.statistics_set).to be_a Yt::StatisticsSet }
20
+ it { expect(channel.videos).to be_a Yt::Collections::Videos }
21
+ it { expect(channel.videos.first).to be_a Yt::Video }
22
+ it { expect(channel.playlists).to be_a Yt::Collections::Playlists }
23
+ it { expect(channel.playlists.first).to be_a Yt::Playlist }
24
+ it { expect(channel.related_playlists).to be_a Yt::Collections::Playlists }
25
+ it { expect(channel.related_playlists.first).to be_a Yt::Playlist }
26
+
27
+ specify 'with a public list of subscriptions' do
28
+ expect(channel.subscribed_channels.first).to be_a Yt::Channel
29
+ end
30
+
31
+ context 'with a hidden list of subscriptions' do
32
+ let(:attrs) { {id: 'UCG0hw7n_v0sr8MXgb6oel6w'} }
33
+ it { expect{channel.subscribed_channels.size}.to raise_error Yt::Errors::Forbidden }
34
+ end
35
+ end
36
+
37
+ context 'given an existing channel URL' do
38
+ let(:attrs) { {url: 'youtube.com/fullscreen'} }
39
+
40
+ specify 'provides access to its data' do
41
+ expect(channel.id).to eq 'UCxO1tY8h1AhOz0T4ENwmpow'
42
+ expect(channel.title).to eq 'Fullscreen'
43
+ expect(channel.privacy_status).to eq 'public'
44
+ end
45
+ end
46
+
47
+ context 'given an unknown channel ID' do
48
+ let(:attrs) { {id: 'not-a-channel-id'} }
49
+
50
+ it { expect{channel.snippet}.to raise_error Yt::Errors::NoItems }
51
+ it { expect{channel.status}.to raise_error Yt::Errors::NoItems }
52
+ it { expect{channel.statistics_set}.to raise_error Yt::Errors::NoItems }
53
+
54
+ describe 'starting with UC' do
55
+ let(:attrs) { {id: 'UC-not-a-channel-id'} }
56
+
57
+ # NOTE: This test is just a reflection of YouTube irrational behavior of
58
+ # returns 0 results if the name of an unknown channel starts with UC, but
59
+ # returning 100,000 results otherwise (ignoring the channel filter).
60
+ it { expect(channel.videos.count).to be_zero }
61
+ it { expect(channel.videos.size).to be_zero }
62
+ end
63
+ end
64
+
65
+ context 'given an unknown channel URL' do
66
+ let(:attrs) { {url: 'youtube.com/--not-a-valid-url--'} }
67
+
68
+ specify 'accessing its data raises an error' do
69
+ expect{channel.id}.to raise_error Yt::Errors::NoItems
70
+ expect{channel.title}.to raise_error Yt::Errors::NoItems
71
+ expect{channel.status}.to raise_error Yt::Errors::NoItems
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/playlist_item'
3
+
4
+ describe Yt::PlaylistItem, :server_app do
5
+ subject(:item) { Yt::PlaylistItem.new id: id }
6
+
7
+ context 'given an existing playlist item' do
8
+ let(:id) { 'PLjW_GNR5Ir0GMlbJzA-aW0UV8TchJFb8p3uzrLNcZKPY' }
9
+
10
+ it 'returns valid snippet data' do
11
+ expect(item.snippet).to be_a Yt::Snippet
12
+ expect(item.title).to be_a String
13
+ expect(item.description).to be_a Yt::Description
14
+ expect(item.thumbnail_url).to be_a String
15
+ expect(item.published_at).to be_a Time
16
+ expect(item.channel_id).to be_a String
17
+ expect(item.channel_title).to be_a String
18
+ expect(item.playlist_id).to be_a String
19
+ expect(item.position).to be_an Integer
20
+ expect(item.video_id).to be_a String
21
+ expect(item.video).to be_a Yt::Models::Video
22
+ end
23
+ end
24
+
25
+ context 'given an unknown playlist item' do
26
+ let(:id) { 'not-a-playlist-item-id' }
27
+
28
+ it { expect{item.snippet}.to raise_error Yt::Errors::RequestError }
29
+ end
30
+ end
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/playlist'
3
+
4
+ describe Yt::Playlist, :server_app do
5
+ subject(:playlist) { Yt::Playlist.new attrs }
6
+
7
+ context 'given an existing playlist ID' do
8
+ let(:attrs) { {id: 'PLSWYkYzOrPMT9pJG5St5G0WDalhRzGkU4'} }
9
+
10
+ it 'returns valid snippet data' do
11
+ expect(playlist.snippet).to be_a Yt::Snippet
12
+ expect(playlist.title).to be_a String
13
+ expect(playlist.description).to be_a Yt::Description
14
+ expect(playlist.thumbnail_url).to be_a String
15
+ expect(playlist.published_at).to be_a Time
16
+ expect(playlist.tags).to be_an Array
17
+ expect(playlist.channel_id).to be_a String
18
+ expect(playlist.channel_title).to be_a String
19
+ end
20
+
21
+ it { expect(playlist.status).to be_a Yt::Status }
22
+ it { expect(playlist.playlist_items).to be_a Yt::Collections::PlaylistItems }
23
+ it { expect(playlist.playlist_items.first).to be_a Yt::PlaylistItem }
24
+ end
25
+
26
+ context 'given an existing playlist URL' do
27
+ let(:attrs) { {url: 'https://www.youtube.com/playlist?list=LLxO1tY8h1AhOz0T4ENwmpow'} }
28
+
29
+ specify 'provides access to its data' do
30
+ expect(playlist.id).to eq 'LLxO1tY8h1AhOz0T4ENwmpow'
31
+ expect(playlist.title).to eq 'Liked videos'
32
+ expect(playlist.privacy_status).to eq 'public'
33
+ end
34
+ end
35
+
36
+ context 'given an unknown playlist' do
37
+ let(:attrs) { {id: 'not-a-playlist-id'} }
38
+
39
+ it { expect{playlist.snippet}.to raise_error Yt::Errors::NoItems }
40
+ it { expect{playlist.status}.to raise_error Yt::Errors::NoItems }
41
+ end
42
+
43
+
44
+ context 'given an unknown playlist URL' do
45
+ let(:attrs) { {url: 'youtube.com/--not-a-valid-url--'} }
46
+
47
+ specify 'accessing its data raises an error' do
48
+ expect{playlist.id}.to raise_error Yt::Errors::NoItems
49
+ expect{playlist.title}.to raise_error Yt::Errors::NoItems
50
+ expect{playlist.status}.to raise_error Yt::Errors::NoItems
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/video'
3
+
4
+ describe Yt::Video, :server_app do
5
+ subject(:video) { Yt::Video.new attrs }
6
+
7
+ context 'given an existing video ID' do
8
+ let(:attrs) { {id: 'MESycYJytkU'} }
9
+
10
+ it { expect(video.content_detail).to be_a Yt::ContentDetail }
11
+
12
+ it 'returns valid snippet data' do
13
+ expect(video.snippet).to be_a Yt::Snippet
14
+ expect(video.title).to be_a String
15
+ expect(video.description).to be_a Yt::Description
16
+ expect(video.thumbnail_url).to be_a String
17
+ expect(video.published_at).to be_a Time
18
+ expect(video.tags).to be_an Array
19
+ expect(video.channel_id).to be_a String
20
+ expect(video.channel_title).to be_a String
21
+ expect(video.category_id).to be_a String
22
+ expect(video.live_broadcast_content).to be_a String
23
+ end
24
+
25
+ it { expect(video.status).to be_a Yt::Status }
26
+ it { expect(video.statistics_set).to be_a Yt::StatisticsSet }
27
+ end
28
+
29
+ context 'given an existing video URL' do
30
+ let(:attrs) { {url: 'https://www.youtube.com/watch?v=MESycYJytkU&list=LLxO1tY8h1AhOz0T4ENwmpow'} }
31
+
32
+ specify 'provides access to its data' do
33
+ expect(video.id).to eq 'MESycYJytkU'
34
+ expect(video.title).to eq 'Fullscreen Creator Platform'
35
+ expect(video.privacy_status).to eq 'public'
36
+ end
37
+ end
38
+
39
+ context 'given an unknown video ID' do
40
+ let(:attrs) { {id: 'not-a-video-id'} }
41
+
42
+ it { expect{video.content_detail}.to raise_error Yt::Errors::NoItems }
43
+ it { expect{video.snippet}.to raise_error Yt::Errors::NoItems }
44
+ it { expect{video.status}.to raise_error Yt::Errors::NoItems }
45
+ it { expect{video.statistics_set}.to raise_error Yt::Errors::NoItems }
46
+ end
47
+
48
+ context 'given an unknown video URL' do
49
+ let(:attrs) { {url: 'youtube.com/--not-a-valid-url--'} }
50
+
51
+ specify 'accessing its data raises an error' do
52
+ expect{video.id}.to raise_error Yt::Errors::NoItems
53
+ expect{video.title}.to raise_error Yt::Errors::NoItems
54
+ expect{video.status}.to raise_error Yt::Errors::NoItems
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+ require 'yt/collections/videos'
4
+
5
+ describe Yt::Collections::Videos, :server_app do
6
+ subject(:videos) { Yt::Collections::Videos.new }
7
+
8
+ specify 'without :where conditions, returns all YouTube videos', :ruby2 do
9
+ expect(videos.size).to be > 100_000
10
+ end
11
+
12
+ specify 'with a query term, only returns some YouTube videos' do
13
+ expect(videos.where(q: 'Fullscreen CreatorPlatform', video_duration: :long).size).to be < 100_000
14
+ end
15
+
16
+ context 'with a list of video IDs, only returns the videos matching those IDs' do
17
+ let(:video_id) { 'MESycYJytkU' }
18
+ let(:videos_by_id) { videos.where id: "#{video_id},invalid" }
19
+
20
+ it { expect(videos_by_id.size).to be 1 }
21
+ it { expect(videos_by_id.first.id).to eq video_id }
22
+ end
23
+
24
+ specify 'with a chart parameter, only returns videos of that chart', :ruby2 do
25
+ expect(videos.where(chart: 'mostPopular').size).to be 30
26
+ end
27
+
28
+ context 'with a list of parts' do
29
+ let(:video_id) { 'MESycYJytkU' }
30
+ let(:part) { 'statistics,contentDetails' }
31
+ let(:video) { videos.where(id: 'MESycYJytkU', part: part).first }
32
+
33
+ specify 'load ONLY the specified parts of the videos' do
34
+ expect(video.instance_variable_defined? :@snippet).to be false
35
+ expect(video.instance_variable_defined? :@status).to be false
36
+ expect(video.instance_variable_defined? :@statistics_set).to be true
37
+ expect(video.instance_variable_defined? :@content_detail).to be true
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/video'
3
+
4
+ describe Yt::Video do
5
+ subject(:video) { Yt::Video.new id: id }
6
+
7
+ context 'given a public video with annotations' do
8
+ let(:id) { 'MESycYJytkU' }
9
+
10
+ it { expect(video.annotations).to be_a Yt::Collections::Annotations }
11
+ it { expect(video.annotations.first).to be_a Yt::Annotation }
12
+ it { expect(video.annotations.size).to be > 0 }
13
+ end
14
+
15
+ context 'given a private video' do
16
+ let(:id) { 'JzDEc54FVTc' }
17
+
18
+ it { expect(video.annotations).to be_a Yt::Collections::Annotations }
19
+ it { expect(video.annotations.count).to be_zero }
20
+ it { expect(video.annotations.size).to be_zero }
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start
9
+
10
+ Dir['./spec/support/**/*.rb'].each {|f| require f}
11
+
12
+ RSpec.configure do |config|
13
+ config.order = 'random'
14
+ config.run_all_when_everything_filtered = false
15
+ # @note: Some tests might take too long to run on Ruby 1.9.3 which does not
16
+ # support "size" for Enumerator, so we are better off skipping them.
17
+ config.filter_run_excluding ruby2: true if RUBY_VERSION < '2'
18
+ # @note: See https://github.com/Fullscreen/yt/issues/103
19
+ config.filter_run_excluding ruby21: true if RUBY_VERSION < '2.1'
20
+ end
@@ -0,0 +1,15 @@
1
+ RSpec::Matchers.define :fail do
2
+ supports_block_expectations
3
+ match do |block|
4
+ begin
5
+ block.call
6
+ false
7
+ rescue Yt::Error => error
8
+ @reason ? error.reasons.include?(@reason) : true
9
+ end
10
+ end
11
+
12
+ chain :with do |reason|
13
+ @reason = reason
14
+ end
15
+ end
@@ -0,0 +1,48 @@
1
+ require 'yt/config'
2
+ require 'yt/models/account'
3
+ require 'yt/models/content_owner'
4
+
5
+ RSpec.configure do |config|
6
+ # Create one global test account to avoid having to refresh the access token
7
+ # at every request
8
+ config.before :all do
9
+ attrs = {refresh_token: ENV['YT_TEST_DEVICE_REFRESH_TOKEN']}
10
+ $account = Yt::Account.new attrs
11
+ end
12
+
13
+ # Don't use authentication from env variables unless specified with a tag
14
+ config.before :all do
15
+ Yt.configure do |config|
16
+ config.client_id = nil
17
+ config.client_secret = nil
18
+ config.api_key = nil
19
+ end
20
+ end
21
+
22
+ config.before :all, device_app: true do
23
+ Yt.configure do |config|
24
+ config.client_id = ENV['YT_TEST_DEVICE_CLIENT_ID']
25
+ config.client_secret = ENV['YT_TEST_DEVICE_CLIENT_SECRET']
26
+ config.log_level = ENV['YT_LOG_LEVEL']
27
+ end
28
+ end
29
+
30
+ config.before :all, server_app: true do
31
+ Yt.configure do |config|
32
+ config.api_key = ENV['YT_TEST_SERVER_API_KEY']
33
+ config.log_level = ENV['YT_LOG_LEVEL']
34
+ end
35
+ end
36
+
37
+ config.before :all, partner: true do
38
+ Yt.configure do |config|
39
+ config.client_id = ENV['YT_TEST_PARTNER_CLIENT_ID']
40
+ config.client_secret = ENV['YT_TEST_PARTNER_CLIENT_SECRET']
41
+ config.log_level = ENV['YT_LOG_LEVEL']
42
+ end
43
+ # Create one Youtube Partner channel, authenticated as the content owner
44
+ attrs = {refresh_token: ENV['YT_TEST_CONTENT_OWNER_REFRESH_TOKEN']}
45
+ attrs[:owner_name] = ENV['YT_TEST_CONTENT_OWNER_NAME']
46
+ $content_owner = Yt::ContentOwner.new attrs
47
+ end
48
+ end
data/yt.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'yt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "yt-andrewroth"
8
+ spec.version = Yt::VERSION
9
+ spec.authors = ["Claudio Baccigalupo"]
10
+ spec.email = ["claudio@fullscreen.net"]
11
+ spec.description = %q{Youtube V3 API client.}
12
+ spec.summary = %q{Yt makes it easy to interact with Youtube V3 API by
13
+ providing a modular, intuitive and tested Ruby-style API.}
14
+ spec.homepage = "http://github.com/Fullscreen/yt"
15
+ spec.license = "MIT"
16
+
17
+ spec.required_ruby_version = '>= 1.9.3'
18
+
19
+ spec.files = `git ls-files`.split($/)
20
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency 'activesupport' # '3 (Ruby 1.9) or 4 (Ruby 2)'
25
+
26
+ # For development / Code coverage / Documentation
27
+ spec.add_development_dependency 'bundler' #, '~> 1.0'
28
+ spec.add_development_dependency 'rspec' #, '~> 2.0'
29
+ spec.add_development_dependency 'rake' #, '~> 10.0'
30
+ spec.add_development_dependency 'yard' #, '~> 0.8.0'
31
+ spec.add_development_dependency 'coveralls' #, '~> 0.7.0'
32
+ end
metadata ADDED
@@ -0,0 +1,416 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yt-andrewroth
3
+ version: !ruby/object:Gem::Version
4
+ hash: 145
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 25
9
+ - 5
10
+ - 1
11
+ version: 0.25.5.1
12
+ platform: ruby
13
+ authors:
14
+ - Claudio Baccigalupo
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2015-08-13 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: activesupport
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: bundler
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 3
45
+ segments:
46
+ - 0
47
+ version: "0"
48
+ type: :development
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ type: :development
63
+ version_requirements: *id003
64
+ - !ruby/object:Gem::Dependency
65
+ name: rake
66
+ prerelease: false
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ type: :development
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
79
+ name: yard
80
+ prerelease: false
81
+ requirement: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ type: :development
91
+ version_requirements: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: coveralls
94
+ prerelease: false
95
+ requirement: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ type: :development
105
+ version_requirements: *id006
106
+ description: Youtube V3 API client.
107
+ email:
108
+ - claudio@fullscreen.net
109
+ executables:
110
+ - yt
111
+ extensions: []
112
+
113
+ extra_rdoc_files: []
114
+
115
+ files:
116
+ - .gitignore
117
+ - .rspec
118
+ - .travis.yml
119
+ - .yardopts
120
+ - CHANGELOG.md
121
+ - Gemfile
122
+ - MIT-LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - YOUTUBE_IT.md
126
+ - bin/yt
127
+ - gemfiles/Gemfile.activesupport-3.x
128
+ - gemfiles/Gemfile.activesupport-4.x
129
+ - lib/yt.rb
130
+ - lib/yt/actions/base.rb
131
+ - lib/yt/actions/delete.rb
132
+ - lib/yt/actions/delete_all.rb
133
+ - lib/yt/actions/insert.rb
134
+ - lib/yt/actions/list.rb
135
+ - lib/yt/actions/modify.rb
136
+ - lib/yt/actions/patch.rb
137
+ - lib/yt/actions/update.rb
138
+ - lib/yt/associations/has_attribute.rb
139
+ - lib/yt/associations/has_authentication.rb
140
+ - lib/yt/associations/has_many.rb
141
+ - lib/yt/associations/has_one.rb
142
+ - lib/yt/associations/has_reports.rb
143
+ - lib/yt/collections/advertising_options_sets.rb
144
+ - lib/yt/collections/annotations.rb
145
+ - lib/yt/collections/assets.rb
146
+ - lib/yt/collections/authentications.rb
147
+ - lib/yt/collections/base.rb
148
+ - lib/yt/collections/channels.rb
149
+ - lib/yt/collections/claim_histories.rb
150
+ - lib/yt/collections/claims.rb
151
+ - lib/yt/collections/content_details.rb
152
+ - lib/yt/collections/content_owner_details.rb
153
+ - lib/yt/collections/content_owners.rb
154
+ - lib/yt/collections/device_flows.rb
155
+ - lib/yt/collections/file_details.rb
156
+ - lib/yt/collections/ids.rb
157
+ - lib/yt/collections/live_streaming_details.rb
158
+ - lib/yt/collections/ownerships.rb
159
+ - lib/yt/collections/partnered_channels.rb
160
+ - lib/yt/collections/players.rb
161
+ - lib/yt/collections/playlist_items.rb
162
+ - lib/yt/collections/playlists.rb
163
+ - lib/yt/collections/policies.rb
164
+ - lib/yt/collections/ratings.rb
165
+ - lib/yt/collections/references.rb
166
+ - lib/yt/collections/related_playlists.rb
167
+ - lib/yt/collections/reports.rb
168
+ - lib/yt/collections/resources.rb
169
+ - lib/yt/collections/resumable_sessions.rb
170
+ - lib/yt/collections/snippets.rb
171
+ - lib/yt/collections/statistics_sets.rb
172
+ - lib/yt/collections/statuses.rb
173
+ - lib/yt/collections/subscribed_channels.rb
174
+ - lib/yt/collections/subscribers.rb
175
+ - lib/yt/collections/subscriptions.rb
176
+ - lib/yt/collections/user_infos.rb
177
+ - lib/yt/collections/video_categories.rb
178
+ - lib/yt/collections/videos.rb
179
+ - lib/yt/config.rb
180
+ - lib/yt/errors/forbidden.rb
181
+ - lib/yt/errors/missing_auth.rb
182
+ - lib/yt/errors/no_items.rb
183
+ - lib/yt/errors/request_error.rb
184
+ - lib/yt/errors/server_error.rb
185
+ - lib/yt/errors/unauthorized.rb
186
+ - lib/yt/models/account.rb
187
+ - lib/yt/models/advertising_options_set.rb
188
+ - lib/yt/models/annotation.rb
189
+ - lib/yt/models/asset.rb
190
+ - lib/yt/models/asset_metadata.rb
191
+ - lib/yt/models/asset_snippet.rb
192
+ - lib/yt/models/authentication.rb
193
+ - lib/yt/models/base.rb
194
+ - lib/yt/models/channel.rb
195
+ - lib/yt/models/claim.rb
196
+ - lib/yt/models/claim_event.rb
197
+ - lib/yt/models/claim_history.rb
198
+ - lib/yt/models/configuration.rb
199
+ - lib/yt/models/content_detail.rb
200
+ - lib/yt/models/content_owner.rb
201
+ - lib/yt/models/content_owner_detail.rb
202
+ - lib/yt/models/description.rb
203
+ - lib/yt/models/device_flow.rb
204
+ - lib/yt/models/file_detail.rb
205
+ - lib/yt/models/id.rb
206
+ - lib/yt/models/iterator.rb
207
+ - lib/yt/models/live_streaming_detail.rb
208
+ - lib/yt/models/match_policy.rb
209
+ - lib/yt/models/ownership.rb
210
+ - lib/yt/models/player.rb
211
+ - lib/yt/models/playlist.rb
212
+ - lib/yt/models/playlist_item.rb
213
+ - lib/yt/models/policy.rb
214
+ - lib/yt/models/policy_rule.rb
215
+ - lib/yt/models/rating.rb
216
+ - lib/yt/models/reference.rb
217
+ - lib/yt/models/resource.rb
218
+ - lib/yt/models/resumable_session.rb
219
+ - lib/yt/models/right_owner.rb
220
+ - lib/yt/models/snippet.rb
221
+ - lib/yt/models/statistics_set.rb
222
+ - lib/yt/models/status.rb
223
+ - lib/yt/models/subscription.rb
224
+ - lib/yt/models/timestamp.rb
225
+ - lib/yt/models/url.rb
226
+ - lib/yt/models/user_info.rb
227
+ - lib/yt/models/video.rb
228
+ - lib/yt/models/video_category.rb
229
+ - lib/yt/request.rb
230
+ - lib/yt/version.rb
231
+ - spec/collections/claims_spec.rb
232
+ - spec/collections/playlist_items_spec.rb
233
+ - spec/collections/playlists_spec.rb
234
+ - spec/collections/policies_spec.rb
235
+ - spec/collections/references_spec.rb
236
+ - spec/collections/reports_spec.rb
237
+ - spec/collections/subscriptions_spec.rb
238
+ - spec/collections/videos_spec.rb
239
+ - spec/errors/forbidden_spec.rb
240
+ - spec/errors/missing_auth_spec.rb
241
+ - spec/errors/no_items_spec.rb
242
+ - spec/errors/request_error_spec.rb
243
+ - spec/errors/server_error_spec.rb
244
+ - spec/errors/unauthorized_spec.rb
245
+ - spec/models/account_spec.rb
246
+ - spec/models/annotation_spec.rb
247
+ - spec/models/asset_spec.rb
248
+ - spec/models/channel_spec.rb
249
+ - spec/models/claim_event_spec.rb
250
+ - spec/models/claim_history_spec.rb
251
+ - spec/models/claim_spec.rb
252
+ - spec/models/configuration_spec.rb
253
+ - spec/models/content_detail_spec.rb
254
+ - spec/models/content_owner_detail_spec.rb
255
+ - spec/models/description_spec.rb
256
+ - spec/models/file_detail_spec.rb
257
+ - spec/models/live_streaming_detail_spec.rb
258
+ - spec/models/ownership_spec.rb
259
+ - spec/models/player_spec.rb
260
+ - spec/models/playlist_item_spec.rb
261
+ - spec/models/playlist_spec.rb
262
+ - spec/models/policy_rule_spec.rb
263
+ - spec/models/policy_spec.rb
264
+ - spec/models/rating_spec.rb
265
+ - spec/models/reference_spec.rb
266
+ - spec/models/request_spec.rb
267
+ - spec/models/resource_spec.rb
268
+ - spec/models/right_owner_spec.rb
269
+ - spec/models/snippet_spec.rb
270
+ - spec/models/statistics_set_spec.rb
271
+ - spec/models/status_spec.rb
272
+ - spec/models/subscription_spec.rb
273
+ - spec/models/url_spec.rb
274
+ - spec/models/video_category_spec.rb
275
+ - spec/models/video_spec.rb
276
+ - spec/requests/as_account/account_spec.rb
277
+ - spec/requests/as_account/authentications_spec.rb
278
+ - spec/requests/as_account/channel_spec.rb
279
+ - spec/requests/as_account/channels_spec.rb
280
+ - spec/requests/as_account/playlist_item_spec.rb
281
+ - spec/requests/as_account/playlist_spec.rb
282
+ - spec/requests/as_account/resource_spec.rb
283
+ - spec/requests/as_account/thumbnail.jpg
284
+ - spec/requests/as_account/video.mp4
285
+ - spec/requests/as_account/video_spec.rb
286
+ - spec/requests/as_content_owner/account_spec.rb
287
+ - spec/requests/as_content_owner/advertising_options_set_spec.rb
288
+ - spec/requests/as_content_owner/asset_spec.rb
289
+ - spec/requests/as_content_owner/channel_spec.rb
290
+ - spec/requests/as_content_owner/claim_history_spec.rb
291
+ - spec/requests/as_content_owner/content_owner_spec.rb
292
+ - spec/requests/as_content_owner/match_policy_spec.rb
293
+ - spec/requests/as_content_owner/ownership_spec.rb
294
+ - spec/requests/as_content_owner/playlist_spec.rb
295
+ - spec/requests/as_content_owner/video_spec.rb
296
+ - spec/requests/as_server_app/channel_spec.rb
297
+ - spec/requests/as_server_app/playlist_item_spec.rb
298
+ - spec/requests/as_server_app/playlist_spec.rb
299
+ - spec/requests/as_server_app/video_spec.rb
300
+ - spec/requests/as_server_app/videos_spec.rb
301
+ - spec/requests/unauthenticated/video_spec.rb
302
+ - spec/spec_helper.rb
303
+ - spec/support/fail_matcher.rb
304
+ - spec/support/global_hooks.rb
305
+ - yt.gemspec
306
+ has_rdoc: true
307
+ homepage: http://github.com/Fullscreen/yt
308
+ licenses:
309
+ - MIT
310
+ post_install_message:
311
+ rdoc_options: []
312
+
313
+ require_paths:
314
+ - lib
315
+ required_ruby_version: !ruby/object:Gem::Requirement
316
+ none: false
317
+ requirements:
318
+ - - ">="
319
+ - !ruby/object:Gem::Version
320
+ hash: 53
321
+ segments:
322
+ - 1
323
+ - 9
324
+ - 3
325
+ version: 1.9.3
326
+ required_rubygems_version: !ruby/object:Gem::Requirement
327
+ none: false
328
+ requirements:
329
+ - - ">="
330
+ - !ruby/object:Gem::Version
331
+ hash: 3
332
+ segments:
333
+ - 0
334
+ version: "0"
335
+ requirements: []
336
+
337
+ rubyforge_project:
338
+ rubygems_version: 1.5.3
339
+ signing_key:
340
+ specification_version: 3
341
+ summary: Yt makes it easy to interact with Youtube V3 API by providing a modular, intuitive and tested Ruby-style API.
342
+ test_files:
343
+ - spec/collections/claims_spec.rb
344
+ - spec/collections/playlist_items_spec.rb
345
+ - spec/collections/playlists_spec.rb
346
+ - spec/collections/policies_spec.rb
347
+ - spec/collections/references_spec.rb
348
+ - spec/collections/reports_spec.rb
349
+ - spec/collections/subscriptions_spec.rb
350
+ - spec/collections/videos_spec.rb
351
+ - spec/errors/forbidden_spec.rb
352
+ - spec/errors/missing_auth_spec.rb
353
+ - spec/errors/no_items_spec.rb
354
+ - spec/errors/request_error_spec.rb
355
+ - spec/errors/server_error_spec.rb
356
+ - spec/errors/unauthorized_spec.rb
357
+ - spec/models/account_spec.rb
358
+ - spec/models/annotation_spec.rb
359
+ - spec/models/asset_spec.rb
360
+ - spec/models/channel_spec.rb
361
+ - spec/models/claim_event_spec.rb
362
+ - spec/models/claim_history_spec.rb
363
+ - spec/models/claim_spec.rb
364
+ - spec/models/configuration_spec.rb
365
+ - spec/models/content_detail_spec.rb
366
+ - spec/models/content_owner_detail_spec.rb
367
+ - spec/models/description_spec.rb
368
+ - spec/models/file_detail_spec.rb
369
+ - spec/models/live_streaming_detail_spec.rb
370
+ - spec/models/ownership_spec.rb
371
+ - spec/models/player_spec.rb
372
+ - spec/models/playlist_item_spec.rb
373
+ - spec/models/playlist_spec.rb
374
+ - spec/models/policy_rule_spec.rb
375
+ - spec/models/policy_spec.rb
376
+ - spec/models/rating_spec.rb
377
+ - spec/models/reference_spec.rb
378
+ - spec/models/request_spec.rb
379
+ - spec/models/resource_spec.rb
380
+ - spec/models/right_owner_spec.rb
381
+ - spec/models/snippet_spec.rb
382
+ - spec/models/statistics_set_spec.rb
383
+ - spec/models/status_spec.rb
384
+ - spec/models/subscription_spec.rb
385
+ - spec/models/url_spec.rb
386
+ - spec/models/video_category_spec.rb
387
+ - spec/models/video_spec.rb
388
+ - spec/requests/as_account/account_spec.rb
389
+ - spec/requests/as_account/authentications_spec.rb
390
+ - spec/requests/as_account/channel_spec.rb
391
+ - spec/requests/as_account/channels_spec.rb
392
+ - spec/requests/as_account/playlist_item_spec.rb
393
+ - spec/requests/as_account/playlist_spec.rb
394
+ - spec/requests/as_account/resource_spec.rb
395
+ - spec/requests/as_account/thumbnail.jpg
396
+ - spec/requests/as_account/video.mp4
397
+ - spec/requests/as_account/video_spec.rb
398
+ - spec/requests/as_content_owner/account_spec.rb
399
+ - spec/requests/as_content_owner/advertising_options_set_spec.rb
400
+ - spec/requests/as_content_owner/asset_spec.rb
401
+ - spec/requests/as_content_owner/channel_spec.rb
402
+ - spec/requests/as_content_owner/claim_history_spec.rb
403
+ - spec/requests/as_content_owner/content_owner_spec.rb
404
+ - spec/requests/as_content_owner/match_policy_spec.rb
405
+ - spec/requests/as_content_owner/ownership_spec.rb
406
+ - spec/requests/as_content_owner/playlist_spec.rb
407
+ - spec/requests/as_content_owner/video_spec.rb
408
+ - spec/requests/as_server_app/channel_spec.rb
409
+ - spec/requests/as_server_app/playlist_item_spec.rb
410
+ - spec/requests/as_server_app/playlist_spec.rb
411
+ - spec/requests/as_server_app/video_spec.rb
412
+ - spec/requests/as_server_app/videos_spec.rb
413
+ - spec/requests/unauthenticated/video_spec.rb
414
+ - spec/spec_helper.rb
415
+ - spec/support/fail_matcher.rb
416
+ - spec/support/global_hooks.rb