poms 2.6.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.rubocop.yml +5 -3
- data/CHANGELOG.md +4 -0
- data/lib/poms/api/auth.rb +1 -0
- data/lib/poms/api/drivers/net_http.rb +2 -2
- data/lib/poms/api/pagination_client.rb +2 -1
- data/lib/poms/api/request.rb +6 -6
- data/lib/poms/api/search.rb +1 -0
- data/lib/poms/configuration.rb +5 -4
- data/lib/poms/fields/details.rb +2 -0
- data/lib/poms/fields/media.rb +2 -0
- data/lib/poms/fields/schedule.rb +7 -1
- data/lib/poms/timestamp.rb +2 -0
- data/lib/poms/version.rb +1 -1
- data/lib/poms.rb +21 -21
- data/poms.gemspec +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94b59c21b3b95931b03b4b04739cb8dc7b623c26f5d633455221678223b6f625
|
4
|
+
data.tar.gz: ffcf48dabbbdc935e457457fe98eefce1fb04e7e4152f34e466c0b83a5e525e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdd4c961aa0bedf9dc01bd4c901c43dbe2156ad24bfe6488bfc9340fdcae3788ff22fd237bf0b82f0952e2c4e8ad51adc65e723a98e5c2879377a30810bbe893
|
7
|
+
data.tar.gz: 20899c206ed27d38126e42236f29b1f9f08b62aa568dfcc266483f2802e727ce6c63078f55d94f2484c3870b806aec16410753965451add9bb822bb0503a3c11
|
data/.circleci/config.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -8,6 +8,8 @@ AllCops:
|
|
8
8
|
- bin/*
|
9
9
|
- poms.gemspec
|
10
10
|
- vendor/**/*
|
11
|
+
NewCops: enable
|
12
|
+
TargetRubyVersion: 3.2.0
|
11
13
|
|
12
14
|
Style/Documentation:
|
13
15
|
Exclude:
|
@@ -40,16 +42,16 @@ ModuleLength:
|
|
40
42
|
RSpec/ExampleLength:
|
41
43
|
Max: 15
|
42
44
|
|
43
|
-
Layout/
|
45
|
+
Layout/ParameterAlignment:
|
44
46
|
EnforcedStyle: with_fixed_indentation
|
45
47
|
|
46
48
|
Layout/FirstParameterIndentation:
|
47
49
|
EnforcedStyle: consistent
|
48
50
|
|
49
|
-
Layout/
|
51
|
+
Layout/FirstArrayElementIndentation:
|
50
52
|
EnforcedStyle: consistent
|
51
53
|
|
52
|
-
Layout/
|
54
|
+
Layout/FirstHashElementIndentation:
|
53
55
|
EnforcedStyle: consistent
|
54
56
|
|
55
57
|
Layout/MultilineMethodCallIndentation:
|
data/CHANGELOG.md
CHANGED
data/lib/poms/api/auth.rb
CHANGED
@@ -41,7 +41,7 @@ module Poms
|
|
41
41
|
end
|
42
42
|
rescue *NET_HTTP_ERRORS => e
|
43
43
|
raise Errors::HttpError,
|
44
|
-
|
44
|
+
"An error (#{e.class}) occured while processing your request."
|
45
45
|
end
|
46
46
|
|
47
47
|
def prepare_request(request_description)
|
@@ -65,7 +65,7 @@ module Poms
|
|
65
65
|
end
|
66
66
|
|
67
67
|
private_class_method :attempt_request, :prepare_request,
|
68
|
-
|
68
|
+
:request_to_net_http_request
|
69
69
|
end
|
70
70
|
end
|
71
71
|
end
|
@@ -15,6 +15,7 @@ module Poms
|
|
15
15
|
page.execute { |page_uri| client_execute(request, page_uri) }
|
16
16
|
page.items.each { |item| yielder << item }
|
17
17
|
raise StopIteration if page.final?
|
18
|
+
|
18
19
|
page = page.next_page
|
19
20
|
end
|
20
21
|
end.lazy
|
@@ -29,7 +30,7 @@ module Poms
|
|
29
30
|
# Keep track of number of items and how many have been retrieved
|
30
31
|
class Page
|
31
32
|
def initialize(uri, offset = 0)
|
32
|
-
uri.query_values = { offset:
|
33
|
+
uri.query_values = { offset: }
|
33
34
|
@uri = uri
|
34
35
|
end
|
35
36
|
|
data/lib/poms/api/request.rb
CHANGED
@@ -21,16 +21,16 @@ module Poms
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def merge(new_attributes)
|
24
|
-
self.class.new(attributes.merge(new_attributes))
|
24
|
+
self.class.new(**attributes.merge(new_attributes))
|
25
25
|
end
|
26
26
|
|
27
27
|
def attributes
|
28
28
|
{
|
29
|
-
method
|
30
|
-
uri
|
31
|
-
body
|
32
|
-
headers
|
33
|
-
credentials:
|
29
|
+
method:,
|
30
|
+
uri:,
|
31
|
+
body:,
|
32
|
+
headers:,
|
33
|
+
credentials:
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
data/lib/poms/api/search.rb
CHANGED
data/lib/poms/configuration.rb
CHANGED
@@ -23,7 +23,7 @@ module Poms
|
|
23
23
|
reset
|
24
24
|
yield self if block_given?
|
25
25
|
validate
|
26
|
-
@credentials =
|
26
|
+
@credentials = Struct.new(:key, :origin, :secret, :base_uri).new(key, origin, secret, nil)
|
27
27
|
freeze
|
28
28
|
end
|
29
29
|
|
@@ -37,6 +37,7 @@ module Poms
|
|
37
37
|
def assert_credentials
|
38
38
|
REQUIRED_CREDENTIAL_KEYS.each do |key|
|
39
39
|
next if send(key).present?
|
40
|
+
|
40
41
|
raise Errors::AuthenticationError, "#{key} must be supplied"
|
41
42
|
end
|
42
43
|
end
|
@@ -48,9 +49,9 @@ module Poms
|
|
48
49
|
|
49
50
|
def reset
|
50
51
|
@credentials = nil
|
51
|
-
self.key = ENV
|
52
|
-
self.origin = ENV
|
53
|
-
self.secret = ENV
|
52
|
+
self.key = ENV.fetch('POMS_KEY', nil)
|
53
|
+
self.origin = ENV.fetch('POMS_ORIGIN', nil)
|
54
|
+
self.secret = ENV.fetch('POMS_SECRET', nil)
|
54
55
|
self.base_uri = Addressable::URI.parse(
|
55
56
|
ENV.fetch('POMS_BASE_URI', DEFAULT_BASE_URI)
|
56
57
|
)
|
data/lib/poms/fields/details.rb
CHANGED
@@ -88,8 +88,10 @@ module Poms
|
|
88
88
|
# @param type The type to select
|
89
89
|
def value_of_type(item, key, type)
|
90
90
|
return unless item && item[key]
|
91
|
+
|
91
92
|
res = item[key].find { |value| value['type'] == type }
|
92
93
|
return unless res
|
94
|
+
|
93
95
|
res['value']
|
94
96
|
end
|
95
97
|
private_class_method :value_of_type
|
data/lib/poms/fields/media.rb
CHANGED
@@ -17,6 +17,7 @@ module Poms
|
|
17
17
|
# Expects a hash of just an image from POMS
|
18
18
|
def image_id(image)
|
19
19
|
return unless image['imageUri']
|
20
|
+
|
20
21
|
image['imageUri'].split(':').last
|
21
22
|
end
|
22
23
|
|
@@ -27,6 +28,7 @@ module Poms
|
|
27
28
|
# Returns the id of the first image or nil if there are none.
|
28
29
|
def first_image_id(item)
|
29
30
|
return unless images(item)
|
31
|
+
|
30
32
|
image_id(images(item).first)
|
31
33
|
end
|
32
34
|
end
|
data/lib/poms/fields/schedule.rb
CHANGED
@@ -13,9 +13,10 @@ module Poms
|
|
13
13
|
def odi_streams(item)
|
14
14
|
locations = item['locations']
|
15
15
|
return [] if locations.nil? || locations.empty?
|
16
|
+
|
16
17
|
odi_streams = locations.select { |l| l['programUrl'].match(/^odi/) }
|
17
18
|
streams = odi_streams.map do |l|
|
18
|
-
l['programUrl'].match(%r{^[\w+]
|
19
|
+
l['programUrl'].match(%r{^[\w+]+://[\w.]+/video/(\w+)/\w+})[1]
|
19
20
|
end
|
20
21
|
streams.uniq
|
21
22
|
end
|
@@ -36,6 +37,7 @@ module Poms
|
|
36
37
|
# INTERNETVOD and is PUBLISHED and does not have owner NEBO.
|
37
38
|
def publication(poms_item)
|
38
39
|
return if poms_item.fetch('locations', nil).blank?
|
40
|
+
|
39
41
|
poms_item.fetch('locations', []).find do |item|
|
40
42
|
item.fetch('platform', '') == 'INTERNETVOD' &&
|
41
43
|
item.fetch('workflow', '') == 'PUBLISHED' &&
|
@@ -47,6 +49,7 @@ module Poms
|
|
47
49
|
def publish_stop(poms_item)
|
48
50
|
published_item = publication(poms_item)
|
49
51
|
return unless published_item
|
52
|
+
|
50
53
|
Timestamp.to_datetime(published_item['publishStop'])
|
51
54
|
end
|
52
55
|
|
@@ -54,15 +57,18 @@ module Poms
|
|
54
57
|
def publish_start(poms_item)
|
55
58
|
published_item = publication(poms_item)
|
56
59
|
return unless published_item
|
60
|
+
|
57
61
|
Timestamp.to_datetime(published_item['publishStart'])
|
58
62
|
end
|
59
63
|
|
60
64
|
# Returns the enddate of the publication of an internet vod if present.
|
61
65
|
def available_until(item)
|
62
66
|
return if item['predictions'].blank?
|
67
|
+
|
63
68
|
internetvod = item['predictions']
|
64
69
|
.find { |p| p['platform'] == 'INTERNETVOD' }
|
65
70
|
return unless internetvod
|
71
|
+
|
66
72
|
Timestamp.to_datetime(internetvod['publishStop'])
|
67
73
|
end
|
68
74
|
|
data/lib/poms/timestamp.rb
CHANGED
@@ -6,12 +6,14 @@ module Poms
|
|
6
6
|
# Convert unix timestamp in milliseconds to datetime
|
7
7
|
def to_datetime(timestamp)
|
8
8
|
return unless timestamp
|
9
|
+
|
9
10
|
Time.at(timestamp / 1000).to_datetime
|
10
11
|
end
|
11
12
|
|
12
13
|
# Convert to unix timestamp in milliseconds
|
13
14
|
def to_unix_ms(datetime)
|
14
15
|
return unless datetime
|
16
|
+
|
15
17
|
datetime.to_i * 1000
|
16
18
|
end
|
17
19
|
end
|
data/lib/poms/version.rb
CHANGED
data/lib/poms.rb
CHANGED
@@ -43,32 +43,32 @@ module Poms
|
|
43
43
|
# @raise Api::Client::HttpMissingError
|
44
44
|
def first!(mid)
|
45
45
|
Api::JsonClient.execute(build_request(
|
46
|
-
|
47
|
-
|
46
|
+
uri: Api::Uris::Media.single(config.base_uri, mid)
|
47
|
+
))
|
48
48
|
end
|
49
49
|
|
50
50
|
def fetch(arg)
|
51
51
|
Api::JsonClient.execute(build_request(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
method: :post,
|
53
|
+
uri: Api::Uris::Media.multiple(config.base_uri),
|
54
|
+
body: Array(arg)
|
55
|
+
))
|
56
56
|
end
|
57
57
|
|
58
58
|
def descendants(mid, search_params = {})
|
59
59
|
Api::PaginationClient.execute(build_request(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
method: :post,
|
61
|
+
uri: Api::Uris::Media.descendants(config.base_uri, mid),
|
62
|
+
body: Api::Search.build(search_params)
|
63
|
+
))
|
64
64
|
end
|
65
65
|
|
66
66
|
def members(mid)
|
67
67
|
Api::PaginationClient.execute(build_request(
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
method: :post,
|
69
|
+
uri: Api::Uris::Media.members(config.base_uri, mid),
|
70
|
+
body: Api::Search.empty
|
71
|
+
))
|
72
72
|
end
|
73
73
|
|
74
74
|
# Gets the merged serie mids as a hash. Expects a JSON response from
|
@@ -77,8 +77,8 @@ module Poms
|
|
77
77
|
# @return [Hash] a hash with old_mid => new_mid pairs
|
78
78
|
def merged_series
|
79
79
|
Api::JsonClient.execute(build_request(
|
80
|
-
|
81
|
-
|
80
|
+
uri: Api::Uris::Media.redirects(config.base_uri)
|
81
|
+
)).fetch('map')
|
82
82
|
end
|
83
83
|
|
84
84
|
# Fetches the event for current broadcast on the given channel
|
@@ -86,8 +86,8 @@ module Poms
|
|
86
86
|
# @param channel The channel name
|
87
87
|
def scheduled_now(channel)
|
88
88
|
Api::JsonClient.execute(build_request(
|
89
|
-
|
90
|
-
|
89
|
+
uri: Api::Uris::Schedule.now(config.base_uri, channel)
|
90
|
+
)).fetch('items').first
|
91
91
|
end
|
92
92
|
|
93
93
|
# Fetches the event for the next broadcast on a given channel
|
@@ -95,8 +95,8 @@ module Poms
|
|
95
95
|
# @param channel The channel name
|
96
96
|
def scheduled_next(channel)
|
97
97
|
Api::JsonClient.execute(build_request(
|
98
|
-
|
99
|
-
|
98
|
+
uri: Api::Uris::Schedule.next(config.base_uri, channel)
|
99
|
+
)).fetch('items').first
|
100
100
|
end
|
101
101
|
|
102
102
|
def reset_config
|
@@ -108,7 +108,7 @@ module Poms
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def build_request(attributes)
|
111
|
-
Api::Request.new(attributes.merge(credentials: config.credentials))
|
111
|
+
Api::Request.new(**attributes.merge(credentials: config.credentials))
|
112
112
|
end
|
113
113
|
|
114
114
|
private_class_method :config, :build_request
|
data/poms.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_development_dependency 'rake'
|
25
25
|
spec.add_development_dependency 'rspec'
|
26
26
|
spec.add_development_dependency 'rubocop-rspec', '~> 1.20.0'
|
27
|
-
spec.add_development_dependency 'rubocop', '~>
|
27
|
+
spec.add_development_dependency 'rubocop', '~> 1.0'
|
28
28
|
spec.add_development_dependency 'simplecov'
|
29
29
|
spec.add_development_dependency 'timecop'
|
30
30
|
spec.add_development_dependency 'vcr'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Kruijsen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
131
|
+
version: '1.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: '1.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: simplecov
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,7 +238,7 @@ homepage: https://github.com/brightin/poms
|
|
238
238
|
licenses:
|
239
239
|
- MIT
|
240
240
|
metadata: {}
|
241
|
-
post_install_message:
|
241
|
+
post_install_message:
|
242
242
|
rdoc_options: []
|
243
243
|
require_paths:
|
244
244
|
- lib
|
@@ -253,8 +253,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
253
|
- !ruby/object:Gem::Version
|
254
254
|
version: '0'
|
255
255
|
requirements: []
|
256
|
-
rubygems_version: 3.
|
257
|
-
signing_key:
|
256
|
+
rubygems_version: 3.1.6
|
257
|
+
signing_key:
|
258
258
|
specification_version: 4
|
259
259
|
summary: Interface to POMS CouchDB API
|
260
260
|
test_files: []
|