yt 0.10.1 → 0.10.2

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: b117eddfc2f87b57eb4a4ea124ff8f45e5308deb
4
- data.tar.gz: 72074157314c69230eeb90a8c28e074611d20314
3
+ metadata.gz: bffd4b8b4a58a2b17033305eeeb4e4e3c6e517de
4
+ data.tar.gz: 23c5b423485af978fae17f0aea4fa99412df83ae
5
5
  SHA512:
6
- metadata.gz: 4e7af1b76ea03b99058c314acac896692c4090351f0896b733e9366bf1a7864d51bf17d5c0a7637bd4630fb1ffe4faa56a5a85b1928783d856f314b00c285f27
7
- data.tar.gz: df8230eba2a407722778e30d76c557047967ba1d8f5456f392c186cbd8d9ec8bebebf482dc0775830ced1d0f5bf60ece22d4f8a59734aa8f1bef078b4bcac908
6
+ metadata.gz: a31c789b981109c7821771d861d86c00b69689703269e964770caceddf21c4d734dde0052bb1ac356b43182d5957e3e551ac9afdba09d54673cc56fb4eff39d9
7
+ data.tar.gz: 3618b8c13fb8344c7b26333524fa0fb628b81133435ce73b8fa9559cb4246a95a4a7861f09b727bb865656338f26192b0808b3ee3c209c0e18cb93d4b7257901
@@ -6,6 +6,10 @@ 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.10.2 - 2014-08-11
10
+
11
+ * [FEATURE] Add `MatchPolicy` class with `.update` to change the policy used by an asset
12
+
9
13
  ## 0.10.1 - 2014-08-11
10
14
 
11
15
  * [BUGFIX] Make Yt work on Ruby 1.9.3 / ActiveSupport 3.0 again (was broken by 0.10.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yt (0.10.1)
4
+ yt (0.10.2)
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.10.1'
44
+ gem 'yt', '~> 0.10.2'
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*)
data/lib/yt.rb CHANGED
@@ -3,6 +3,7 @@ require 'yt/models/account'
3
3
  require 'yt/models/channel'
4
4
  require 'yt/models/claim'
5
5
  require 'yt/models/content_owner'
6
+ require 'yt/models/match_policy'
6
7
  require 'yt/models/playlist'
7
8
  require 'yt/models/playlist_item'
8
9
  require 'yt/models/video'
@@ -10,7 +10,7 @@ module Yt
10
10
  def do_modify(params = {})
11
11
  request = Yt::Request.new params
12
12
  response = request.run
13
- yield response.body
13
+ yield response.body if block_given?
14
14
  end
15
15
 
16
16
  def modify_params
@@ -0,0 +1,45 @@
1
+ require 'yt/models/base'
2
+
3
+ module Yt
4
+ module Models
5
+ # Provides methods to interact with YouTube ContentID asset match policies,
6
+ # which YouTube applies to user-uploaded videos that match the asset.
7
+ # @see https://developers.google.com/youtube/partner/docs/v1/assetMatchPolicy
8
+ class MatchPolicy < Base
9
+ def initialize(options = {})
10
+ @asset_id = options[:asset_id]
11
+ @auth = options[:auth]
12
+ end
13
+
14
+ # @note Only policyId can be currently updated, not rules.
15
+ def update(attributes = {})
16
+ underscore_keys! attributes
17
+ do_update body: {policyId: attributes[:policy_id]}
18
+ true
19
+ end
20
+
21
+ private
22
+
23
+ # @return [Hash] the parameters to submit to YouTube to update an asset
24
+ # match policy.
25
+ # @see https://developers.google.com/youtube/partner/docs/v1/assetMatchPolicy/update
26
+ def update_params
27
+ super.tap do |params|
28
+ params[:path] = "/youtube/partner/v1/assets/#{@asset_id}/matchPolicy"
29
+ params[:params] = {onBehalfOfContentOwner: @auth.owner_name}
30
+ params[:expected_response] = Net::HTTPOK
31
+ end
32
+ end
33
+
34
+ # If we dropped support for ActiveSupport 3, then we could simply
35
+ # invoke transform_keys!{|key| key.to_s.underscore.to_sym}
36
+ def underscore_keys!(hash)
37
+ hash.dup.each_key{|key| hash[underscore key] = hash.delete key}
38
+ end
39
+
40
+ def underscore(value)
41
+ value.to_s.underscore.to_sym
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.10.1'
2
+ VERSION = '0.10.2'
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'yt/models/match_policy'
3
+
4
+ describe Yt::MatchPolicy, :partner do
5
+ subject(:match_policy) { Yt::MatchPolicy.new asset_id: asset_id, auth: $content_owner }
6
+
7
+ context 'given an asset managed by the authenticated Content Owner' do
8
+ let(:asset_id) { ENV['YT_TEST_PARTNER_ASSET_ID'] }
9
+
10
+ describe 'the asset match policy can be updated' do
11
+ let(:policy_id) { ENV['YT_TEST_PARTNER_POLICY_ID'] }
12
+
13
+ it { expect(match_policy.update policy_id: policy_id).to be true }
14
+ end
15
+ end
16
+ 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.10.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
@@ -177,6 +177,7 @@ files:
177
177
  - lib/yt/models/id.rb
178
178
  - lib/yt/models/iterator.rb
179
179
  - lib/yt/models/live_streaming_detail.rb
180
+ - lib/yt/models/match_policy.rb
180
181
  - lib/yt/models/playlist.rb
181
182
  - lib/yt/models/playlist_item.rb
182
183
  - lib/yt/models/policy.rb
@@ -241,6 +242,7 @@ files:
241
242
  - spec/requests/as_content_owner/account_spec.rb
242
243
  - spec/requests/as_content_owner/channel_spec.rb
243
244
  - spec/requests/as_content_owner/content_owner_spec.rb
245
+ - spec/requests/as_content_owner/match_policy_spec.rb
244
246
  - spec/requests/as_content_owner/video_spec.rb
245
247
  - spec/requests/as_server_app/channel_spec.rb
246
248
  - spec/requests/as_server_app/playlist_item_spec.rb
@@ -324,6 +326,7 @@ test_files:
324
326
  - spec/requests/as_content_owner/account_spec.rb
325
327
  - spec/requests/as_content_owner/channel_spec.rb
326
328
  - spec/requests/as_content_owner/content_owner_spec.rb
329
+ - spec/requests/as_content_owner/match_policy_spec.rb
327
330
  - spec/requests/as_content_owner/video_spec.rb
328
331
  - spec/requests/as_server_app/channel_spec.rb
329
332
  - spec/requests/as_server_app/playlist_item_spec.rb