poms 2.5.1 → 3.0.0

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
  SHA256:
3
- metadata.gz: 9703e39549b604585b1a9089b86b543426024350e7a77b243fc135ff262955a6
4
- data.tar.gz: 0706bfb103c8f75864bef989a1982005dc302f048fd833bd5d269dc8a6dae7db
3
+ metadata.gz: 94b59c21b3b95931b03b4b04739cb8dc7b623c26f5d633455221678223b6f625
4
+ data.tar.gz: ffcf48dabbbdc935e457457fe98eefce1fb04e7e4152f34e466c0b83a5e525e4
5
5
  SHA512:
6
- metadata.gz: 7b25d5c5bc019d04f224e47e09354baa13c8f82a70f59f4de67f195d542448d5e5ff98215b181ed0edb2198b75e064392b89b61952dea65cf276e2f813030ed9
7
- data.tar.gz: bfbe8ce2fb202dc209a9037d2fefecca1627cd3ab91bca847ba7e4120a4b5bd331a456f98e0bddd4bda1371783559906ae6a55c99eacf197698e8e666995a447
6
+ metadata.gz: cdd4c961aa0bedf9dc01bd4c901c43dbe2156ad24bfe6488bfc9340fdcae3788ff22fd237bf0b82f0952e2c4e8ad51adc65e723a98e5c2879377a30810bbe893
7
+ data.tar.gz: 20899c206ed27d38126e42236f29b1f9f08b62aa568dfcc266483f2802e727ce6c63078f55d94f2484c3870b806aec16410753965451add9bb822bb0503a3c11
data/.circleci/config.yml CHANGED
@@ -2,7 +2,7 @@ version: 2
2
2
  jobs:
3
3
  build:
4
4
  docker:
5
- - image: circleci/ruby:2.3.4-node-browsers
5
+ - image: cimg/ruby:3.2.0-browsers
6
6
  environment:
7
7
  POMS_KEY: key
8
8
  POMS_ORIGIN: origin
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/AlignParameters:
45
+ Layout/ParameterAlignment:
44
46
  EnforcedStyle: with_fixed_indentation
45
47
 
46
48
  Layout/FirstParameterIndentation:
47
49
  EnforcedStyle: consistent
48
50
 
49
- Layout/IndentArray:
51
+ Layout/FirstArrayElementIndentation:
50
52
  EnforcedStyle: consistent
51
53
 
52
- Layout/IndentHash:
54
+ Layout/FirstHashElementIndentation:
53
55
  EnforcedStyle: consistent
54
56
 
55
57
  Layout/MultilineMethodCallIndentation:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Poms Release notes
2
2
 
3
+ ## 3.0.0
4
+
5
+ * Support Ruby 3.2.0.
6
+
7
+ ## 2.6.0
8
+
9
+ * Include `Poms::Fields` in the main library file.
10
+
3
11
  ## 2.5.1
4
12
 
5
13
  * Actually filter out publications with `owner` `NEBO`.
data/lib/poms/api/auth.rb CHANGED
@@ -49,6 +49,7 @@ module Poms
49
49
  # Convert a hash of parameters to the format expected by the message
50
50
  def params_string(params)
51
51
  return unless params
52
+
52
53
  params.map { |key, value| "#{key}:#{value}" }.sort.join(',')
53
54
  end
54
55
 
@@ -41,7 +41,7 @@ module Poms
41
41
  end
42
42
  rescue *NET_HTTP_ERRORS => e
43
43
  raise Errors::HttpError,
44
- "An error (#{e.class}) occured while processing your request."
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
- :request_to_net_http_request
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: offset }
33
+ uri.query_values = { offset: }
33
34
  @uri = uri
34
35
  end
35
36
 
@@ -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: method,
30
- uri: uri,
31
- body: body,
32
- headers: headers,
33
- credentials: credentials
29
+ method:,
30
+ uri:,
31
+ body:,
32
+ headers:,
33
+ credentials:
34
34
  }
35
35
  end
36
36
 
@@ -18,6 +18,7 @@ module Poms
18
18
 
19
19
  def build(options)
20
20
  return {} if options.empty?
21
+
21
22
  all = options.map do |key, value|
22
23
  case key
23
24
  when :starts_at, :ends_at
@@ -23,7 +23,7 @@ module Poms
23
23
  reset
24
24
  yield self if block_given?
25
25
  validate
26
- @credentials = OpenStruct.new(key: key, origin: origin, secret: secret)
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['POMS_KEY']
52
- self.origin = ENV['POMS_ORIGIN']
53
- self.secret = ENV['POMS_SECRET']
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
  )
@@ -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
@@ -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
@@ -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+]+\:\/\/[\w\.]+\/video\/(\w+)\/\w+})[1]
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
 
@@ -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
@@ -1,4 +1,4 @@
1
1
  # The version
2
2
  module Poms
3
- VERSION = '2.5.1'.freeze
3
+ VERSION = '3.0.0'.freeze
4
4
  end
data/lib/poms.rb CHANGED
@@ -6,6 +6,7 @@ require 'poms/api/request'
6
6
  require 'poms/errors'
7
7
  require 'poms/api/search'
8
8
  require 'poms/configuration'
9
+ require 'poms/fields'
9
10
  require 'json'
10
11
 
11
12
  # Main interface for the POMS gem
@@ -42,32 +43,32 @@ module Poms
42
43
  # @raise Api::Client::HttpMissingError
43
44
  def first!(mid)
44
45
  Api::JsonClient.execute(build_request(
45
- uri: Api::Uris::Media.single(config.base_uri, mid)
46
- ))
46
+ uri: Api::Uris::Media.single(config.base_uri, mid)
47
+ ))
47
48
  end
48
49
 
49
50
  def fetch(arg)
50
51
  Api::JsonClient.execute(build_request(
51
- method: :post,
52
- uri: Api::Uris::Media.multiple(config.base_uri),
53
- body: Array(arg)
54
- ))
52
+ method: :post,
53
+ uri: Api::Uris::Media.multiple(config.base_uri),
54
+ body: Array(arg)
55
+ ))
55
56
  end
56
57
 
57
58
  def descendants(mid, search_params = {})
58
59
  Api::PaginationClient.execute(build_request(
59
- method: :post,
60
- uri: Api::Uris::Media.descendants(config.base_uri, mid),
61
- body: Api::Search.build(search_params)
62
- ))
60
+ method: :post,
61
+ uri: Api::Uris::Media.descendants(config.base_uri, mid),
62
+ body: Api::Search.build(search_params)
63
+ ))
63
64
  end
64
65
 
65
66
  def members(mid)
66
67
  Api::PaginationClient.execute(build_request(
67
- method: :post,
68
- uri: Api::Uris::Media.members(config.base_uri, mid),
69
- body: Api::Search.empty
70
- ))
68
+ method: :post,
69
+ uri: Api::Uris::Media.members(config.base_uri, mid),
70
+ body: Api::Search.empty
71
+ ))
71
72
  end
72
73
 
73
74
  # Gets the merged serie mids as a hash. Expects a JSON response from
@@ -76,8 +77,8 @@ module Poms
76
77
  # @return [Hash] a hash with old_mid => new_mid pairs
77
78
  def merged_series
78
79
  Api::JsonClient.execute(build_request(
79
- uri: Api::Uris::Media.redirects(config.base_uri)
80
- )).fetch('map')
80
+ uri: Api::Uris::Media.redirects(config.base_uri)
81
+ )).fetch('map')
81
82
  end
82
83
 
83
84
  # Fetches the event for current broadcast on the given channel
@@ -85,8 +86,8 @@ module Poms
85
86
  # @param channel The channel name
86
87
  def scheduled_now(channel)
87
88
  Api::JsonClient.execute(build_request(
88
- uri: Api::Uris::Schedule.now(config.base_uri, channel)
89
- )).fetch('items').first
89
+ uri: Api::Uris::Schedule.now(config.base_uri, channel)
90
+ )).fetch('items').first
90
91
  end
91
92
 
92
93
  # Fetches the event for the next broadcast on a given channel
@@ -94,8 +95,8 @@ module Poms
94
95
  # @param channel The channel name
95
96
  def scheduled_next(channel)
96
97
  Api::JsonClient.execute(build_request(
97
- uri: Api::Uris::Schedule.next(config.base_uri, channel)
98
- )).fetch('items').first
98
+ uri: Api::Uris::Schedule.next(config.base_uri, channel)
99
+ )).fetch('items').first
99
100
  end
100
101
 
101
102
  def reset_config
@@ -107,7 +108,7 @@ module Poms
107
108
  end
108
109
 
109
110
  def build_request(attributes)
110
- Api::Request.new(attributes.merge(credentials: config.credentials))
111
+ Api::Request.new(**attributes.merge(credentials: config.credentials))
111
112
  end
112
113
 
113
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', '~> 0.51.0'
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: 2.5.1
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: 2020-05-01 00:00:00.000000000 Z
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: 0.51.0
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: 0.51.0
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.0.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: []