bbc_redux 0.4.0.pre → 0.4.3.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/bbc/redux/asset.rb +20 -1
- data/lib/bbc/redux/client.rb +1 -1
- data/lib/bbc/redux/crid.rb +41 -0
- data/lib/bbc/redux/serializers.rb +12 -0
- data/lib/bbc/redux/version.rb +1 -1
- data/lib/bbc/redux.rb +1 -0
- data/spec/bbc/redux/asset_spec.rb +10 -0
- data/spec/bbc/redux/client_spec.rb +2 -2
- data/spec/fixtures/asset.json +33 -21
- data/spec/integration/bbc_redux_spec.rb +14 -0
- metadata +6 -2
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# THIS IS PRE RELEASE, DON'T USE IT AS IT PROBABLY WON'T WORK!
|
2
|
+
|
1
3
|
# Redux
|
2
4
|
|
3
5
|
A gem to help navigate the Redux API's and to screen scrape where an API does
|
@@ -59,7 +61,9 @@ to message us.
|
|
59
61
|
asset.duration #=> Integer
|
60
62
|
asset.key #=> BBC::Redux::Key
|
61
63
|
asset.name #=> String
|
64
|
+
asset.pcrid #=> BBC::Redux::Crid
|
62
65
|
asset.reference #=> String
|
66
|
+
asset.scrid #=> BBC::Redux::Crid
|
63
67
|
asset.start #=> DateTime
|
64
68
|
asset.uuid #=> String
|
65
69
|
|
data/lib/bbc/redux/asset.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'virtus'
|
2
2
|
require_relative 'channel'
|
3
|
+
require_relative 'crid'
|
3
4
|
require_relative 'key'
|
4
5
|
require_relative 'media_url'
|
5
6
|
|
@@ -17,7 +18,9 @@ module BBC
|
|
17
18
|
# asset.duration #=> Integer
|
18
19
|
# asset.key #=> BBC::Redux::Key
|
19
20
|
# asset.name #=> String
|
21
|
+
# asset.pcrid #=> BBC::Redux::Crid
|
20
22
|
# asset.reference #=> String
|
23
|
+
# asset.scrid #=> BBC::Redux::Crid
|
21
24
|
# asset.start #=> DateTime
|
22
25
|
# asset.uuid #=> String
|
23
26
|
#
|
@@ -71,15 +74,31 @@ module BBC
|
|
71
74
|
alias :title :name
|
72
75
|
|
73
76
|
# @!attribute [r] uuid
|
74
|
-
# @return [String] the
|
77
|
+
# @return [String] the assets's uuid
|
75
78
|
attribute :uuid, String
|
76
79
|
|
80
|
+
# @!attribute [r] crids
|
81
|
+
# @return [String] the assets's crids
|
82
|
+
attribute :crids, Array[BBC::Redux::Crid], :default => [ ]
|
83
|
+
|
77
84
|
# @!attribute [r] key
|
78
85
|
# @return [Key] the asset's access key object
|
79
86
|
def key
|
80
87
|
@key ||= Key.new(access_key)
|
81
88
|
end
|
82
89
|
|
90
|
+
# @!attribute [r] pcrid
|
91
|
+
# @return [Key] the asset's programme crid
|
92
|
+
def pcrid
|
93
|
+
@pcrid ||= crids.find { |c| c.description =~ /programme/ }
|
94
|
+
end
|
95
|
+
|
96
|
+
# @!attribute [r] scrid
|
97
|
+
# @return [Key] the asset's series crid
|
98
|
+
def scrid
|
99
|
+
@scrid ||= crids.find { |c| c.description =~ /series/ }
|
100
|
+
end
|
101
|
+
|
83
102
|
private
|
84
103
|
|
85
104
|
def self.has_media_url(type)
|
data/lib/bbc/redux/client.rb
CHANGED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
require_relative 'channel'
|
3
|
+
require_relative 'key'
|
4
|
+
require_relative 'media_url'
|
5
|
+
|
6
|
+
module BBC
|
7
|
+
module Redux
|
8
|
+
|
9
|
+
# Redux Crid Object
|
10
|
+
#
|
11
|
+
# @example Properties of the crid object
|
12
|
+
#
|
13
|
+
# crid = redux_client.asset('5966413090093319525').pcrid
|
14
|
+
#
|
15
|
+
# crid.content #=> String
|
16
|
+
# crid.description #=> String
|
17
|
+
# crid.type #=> String
|
18
|
+
#
|
19
|
+
# @author Matt Haynes <matt.haynes@bbc.co.uk>
|
20
|
+
class Crid
|
21
|
+
|
22
|
+
include Virtus.value_object
|
23
|
+
|
24
|
+
# @!attribute [r] content
|
25
|
+
# @return [String] the crids content, e.g. crid://fp.bbc.co.uk/LYRJ9T
|
26
|
+
attribute :content, String
|
27
|
+
|
28
|
+
alias :to_s :content
|
29
|
+
|
30
|
+
# @!attribute [r] description
|
31
|
+
# @return [String] the crid's description, e.g. "DTG series CRID"
|
32
|
+
attribute :description, String
|
33
|
+
|
34
|
+
# @!attribute [r] type
|
35
|
+
# @return [String] the crid's type byte value, e.g. "0x32"
|
36
|
+
attribute :type, String
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -28,6 +28,18 @@ module BBC
|
|
28
28
|
property :name
|
29
29
|
property :display_name
|
30
30
|
end
|
31
|
+
|
32
|
+
# NB, special compensation for api returning crids: nil not crids: []
|
33
|
+
crid_reader = lambda { |doc, args|
|
34
|
+
self.crids = (doc['crids'] || []).map {|c| BBC::Redux::Crid.new(c) }
|
35
|
+
}
|
36
|
+
|
37
|
+
collection :crids, :reader => crid_reader do
|
38
|
+
property :content
|
39
|
+
property :description
|
40
|
+
property :type
|
41
|
+
end
|
42
|
+
|
31
43
|
end
|
32
44
|
|
33
45
|
class Channel < Representable::Decorator
|
data/lib/bbc/redux/version.rb
CHANGED
data/lib/bbc/redux.rb
CHANGED
@@ -2,6 +2,7 @@ require_relative 'redux/asset'
|
|
2
2
|
require_relative 'redux/channel'
|
3
3
|
require_relative 'redux/channel_category'
|
4
4
|
require_relative 'redux/client'
|
5
|
+
require_relative 'redux/crid'
|
5
6
|
require_relative 'redux/end_points'
|
6
7
|
require_relative 'redux/key'
|
7
8
|
require_relative 'redux/media_url'
|
@@ -16,6 +16,16 @@ describe BBC::Redux::Asset do
|
|
16
16
|
'channel.class' => BBC::Redux::Channel,
|
17
17
|
'channel.display_name' => 'CBeebies',
|
18
18
|
'channel.name' => 'cbeebies',
|
19
|
+
'pcrid.class' => BBC::Redux::Crid,
|
20
|
+
'pcrid.content' => 'crid://fp.bbc.co.uk/4CBRMV',
|
21
|
+
'pcrid.description' => 'DTG programme CRID',
|
22
|
+
'pcrid.to_s' => 'crid://fp.bbc.co.uk/4CBRMV',
|
23
|
+
'pcrid.type' => '0x31',
|
24
|
+
'scrid.class' => BBC::Redux::Crid,
|
25
|
+
'scrid.content' => 'crid://fp.bbc.co.uk/LYRJ9T',
|
26
|
+
'scrid.description' => 'DTG series CRID',
|
27
|
+
'scrid.to_s' => 'crid://fp.bbc.co.uk/LYRJ9T',
|
28
|
+
'scrid.type' => '0x32',
|
19
29
|
:access_key => '1-1397227462-ba632af7af1ad',
|
20
30
|
:description => 'Animated adventures of Pingu. [S]',
|
21
31
|
:disk_reference => '5966413090093319525',
|
@@ -92,7 +92,7 @@ describe BBC::Redux::Client do
|
|
92
92
|
|
93
93
|
it 'takes json from the backend HTTP API and generates an asset object' do
|
94
94
|
expect(http_client).to \
|
95
|
-
receive(:post).with('https://i.bbcredux.com/asset/details', {
|
95
|
+
receive(:post).with('https://i.bbcredux.com/asset/details/extended', {
|
96
96
|
:body => { :reference => reference, :token => token },
|
97
97
|
:followlocation => true,
|
98
98
|
}).and_return(resp)
|
@@ -104,7 +104,7 @@ describe BBC::Redux::Client do
|
|
104
104
|
|
105
105
|
it 'works when given a UUID rather than a disk reference' do
|
106
106
|
expect(http_client).to \
|
107
|
-
receive(:post).with('https://i.bbcredux.com/asset/details', {
|
107
|
+
receive(:post).with('https://i.bbcredux.com/asset/details/extended', {
|
108
108
|
:body => { :uuid => uuid, :token => token },
|
109
109
|
:followlocation => true,
|
110
110
|
}).and_return(resp)
|
data/spec/fixtures/asset.json
CHANGED
@@ -1,24 +1,36 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
2
|
+
"crids" : [
|
3
|
+
{
|
4
|
+
"content" : "crid://fp.bbc.co.uk/LYRJ9T",
|
5
|
+
"type" : "0x32",
|
6
|
+
"description" : "DTG series CRID"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"content" : "crid://fp.bbc.co.uk/4CBRMV",
|
10
|
+
"type" : "0x31",
|
11
|
+
"description" : "DTG programme CRID"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"name" : "Pingu",
|
15
|
+
"channel" : {
|
16
|
+
"name" : "cbeebies",
|
17
|
+
"display_name" : "CBeebies"
|
18
|
+
},
|
19
|
+
"uuid" : "26a141fc-8511-4fef-aa2b-af1d1de5a75a",
|
20
|
+
"description" : "Animated adventures of Pingu. [S]",
|
21
|
+
"tags" : [
|
22
|
+
{
|
23
|
+
"text" : "penguin"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"text" : "not_stoat"
|
27
|
+
}
|
28
|
+
],
|
29
|
+
"key" : "1-1397227462-ba632af7af1ad",
|
30
|
+
"timing" : {
|
31
|
+
"duration" : 300,
|
32
|
+
"start" : "2014-01-08 06:50:00 +0000"
|
33
|
+
},
|
34
|
+
"reference" : 5966413090093319525
|
23
35
|
}
|
24
36
|
|
@@ -30,6 +30,20 @@ describe BBC::Redux do
|
|
30
30
|
expect(asset.start).to eq(DateTime.parse('2014-01-08 06:50:00 +0000'))
|
31
31
|
expect(asset.uuid).to eq('26a141fc-8511-4fef-aa2b-af1d1de5a75a')
|
32
32
|
|
33
|
+
# Test crids
|
34
|
+
expect(asset.pcrid.class).to eq(BBC::Redux::Crid)
|
35
|
+
expect(asset.pcrid.content).to eq('crid://fp.bbc.co.uk/4CBRMV')
|
36
|
+
expect(asset.pcrid.description).to eq('DTG programme CRID')
|
37
|
+
expect(asset.pcrid.type).to eq('0x31')
|
38
|
+
|
39
|
+
expect(asset.scrid.class).to eq(BBC::Redux::Crid)
|
40
|
+
expect(asset.scrid.content).to eq('crid://fp.bbc.co.uk/LYRJ9T')
|
41
|
+
expect(asset.scrid.description).to eq('DTG series CRID')
|
42
|
+
expect(asset.scrid.type).to eq('0x32')
|
43
|
+
|
44
|
+
# Special test for broken crid response
|
45
|
+
expect(client.asset('5203338276492306280').crids).to eq([])
|
46
|
+
|
33
47
|
# Test media url
|
34
48
|
resp = client.http.head(asset.flv_url)
|
35
49
|
expect(resp.code).to eq(200)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbc_redux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3.pre
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-04-
|
14
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- lib/bbc/redux/channel.rb
|
160
160
|
- lib/bbc/redux/channel_category.rb
|
161
161
|
- lib/bbc/redux/client.rb
|
162
|
+
- lib/bbc/redux/crid.rb
|
162
163
|
- lib/bbc/redux/end_points.rb
|
163
164
|
- lib/bbc/redux/key.rb
|
164
165
|
- lib/bbc/redux/media_url.rb
|
@@ -195,6 +196,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
196
|
- - ! '>='
|
196
197
|
- !ruby/object:Gem::Version
|
197
198
|
version: '0'
|
199
|
+
segments:
|
200
|
+
- 0
|
201
|
+
hash: 1134618896184121202
|
198
202
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
199
203
|
none: false
|
200
204
|
requirements:
|