wcc-media-client 0.4.15 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eea13cbea09893a593ee0c45bbab686663cbd1f8232a29e670af1d55a2241b0a
4
- data.tar.gz: 9bb78c414774998a11d36848811506c3565b31b1b20e3d224e59f42c3586161c
3
+ metadata.gz: 0bcc93bdeb901295a7e4b9d4e958622910a2e28a6019446ca56bcbf0d0989a15
4
+ data.tar.gz: 88ed882ee01d56ca74ac934307ab65619b463b728b78736dce3d66ae44bfce24
5
5
  SHA512:
6
- metadata.gz: dd5641649e7006a85b86a4c7ba0b48a9fe11cbbe6ae37e8ea48691612556d1d5770eb9c2f4f0848dd51ac1d65af44fb20a248325bcc9aab4d5dc16f4a7c9dcd1
7
- data.tar.gz: 96a6b2cf6470c3a1c87e4e541234cbcfd047b3c970525ece8182fc28ecfe68b4c0930cf96f43e9895f657769306efb1ceb494d8f1c4a9fb3023bacc26f261964
6
+ metadata.gz: 732e7474858a343be900bc06f90b97d88fb9df1c951a011cb6bc1f3e5845ff5deec1537e2f20c03d831bed6e8e342a68231ecfa44563c748c3678daa4d1f7385
7
+ data.tar.gz: da6a31215ad7f346fffa07493ad066e9ed89653a853880b9a10d86ac7e0c4ca0e5d4d0a88bcecac008fef8e98a63b98f38e2f69e3ba4f492b38bc3e1cc23fa3f
data/.rubocop.yml CHANGED
@@ -1,4 +1,21 @@
1
- inherit_from: ../.rubocop.yml
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.3
6
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
7
+ # to ignore them, so only the ones explicitly set in this file are enabled.
8
+ DisabledByDefault: false
9
+ NewCops: enable
10
+ Exclude:
11
+ - '**/templates/**/*'
12
+ - '**/vendor/**/*'
13
+ - 'spec/dummy/**/*'
14
+ Include:
15
+ - 'lib/**/*'
16
+ - 'Gemfile'
17
+ - 'wcc-scripture.gemspec'
18
+ - 'spec/**/*_spec.rb'
2
19
 
3
20
  Metrics/BlockLength:
4
21
  Exclude:
@@ -7,9 +24,24 @@ Metrics/BlockLength:
7
24
  Style/ClassAndModuleChildren:
8
25
  Enabled: false
9
26
 
27
+ Style/Documentation:
28
+ Enabled: false
29
+
10
30
  Style/MultilineBlockChain:
11
31
  Exclude:
12
32
  - 'spec/**/*'
13
33
 
14
- Rails/TimeZone:
34
+ Style/OpenStructUse:
35
+ Enabled: false
36
+
37
+ RSpec/DescribedClass:
38
+ Enabled: false
39
+
40
+ RSpec/ExampleLength:
41
+ Enabled: false
42
+
43
+ RSpec/MultipleExpectations:
44
+ Enabled: false
45
+
46
+ RSpec/NamedSubject:
15
47
  Enabled: false
data/Gemfile CHANGED
@@ -4,3 +4,28 @@ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in wcc-media-client.gemspec
6
6
  gemspec
7
+
8
+ group :development, :test do
9
+ gem 'guard', '~> 2.15'
10
+ gem 'guard-rspec', '~> 4.7'
11
+ gem 'guard-rubocop', '~> 1.3'
12
+ gem 'http', '> 1.0', '< 3.0'
13
+ gem 'httplog', '~> 1.0'
14
+ gem 'nio4r', '2.5.2'
15
+ gem 'parallel', '~> 1.19.0'
16
+ gem 'rails', '~> 5.0'
17
+ gem 'rake', '~> 12.3'
18
+ gem 'responders', '< 3.0'
19
+ gem 'rspec', '~> 3.0'
20
+ gem 'rspec_junit_formatter', '~> 0.3.0'
21
+ gem 'rspec-rails', '~> 3.7'
22
+ gem 'rubocop', '~> 1.31.0'
23
+ gem 'rubocop-rspec', '~> 2.12'
24
+ gem 'sidekiq', '< 6.0'
25
+ gem 'simplecov', '~> 0.21.2', require: false
26
+ gem 'simplecov-cobertura', '~> 1.4'
27
+ gem 'sprockets', '< 4.0'
28
+ gem 'sqlite3', '~> 1.3.6'
29
+ gem 'typhoeus', '~> 1.3'
30
+ gem 'webmock', '~> 3.0'
31
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WCC::Media::ActiveRecordShim
2
4
  def self.included(base)
3
5
  base.public_send :include, InstanceMethods
@@ -37,7 +39,7 @@ module WCC::Media::ActiveRecordShim
37
39
  end
38
40
 
39
41
  def find_by(**filters)
40
- raise ArgumentError, "You must provide at least one filter" if filters.empty?
42
+ raise ArgumentError, 'You must provide at least one filter' if filters.empty?
41
43
 
42
44
  find_all(filters).first
43
45
  end
@@ -84,8 +86,12 @@ module WCC::Media::ActiveRecordShim
84
86
  end
85
87
  end
86
88
 
87
- [:filters, :endpoint, :key].each do |att|
88
- class_eval("def #{att}(value); @#{att} = value; end", __FILE__, __LINE__)
89
+ %i[filters endpoint key].each do |att|
90
+ class_eval <<-CODE, __FILE__, __LINE__ + 1
91
+ def #{att}(value); # def filters(value)
92
+ @#{att} = value; # @filters = value
93
+ end # end
94
+ CODE
89
95
  end
90
96
  end
91
- end
97
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'cacheable'
2
4
  require_relative 'active_record_shim'
3
5
 
@@ -27,4 +29,4 @@ module WCC
27
29
  end
28
30
  end
29
31
  end
30
- end
32
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WCC
2
4
  module Media
3
5
  module Cacheable
@@ -17,11 +19,11 @@ module WCC
17
19
  (headers&.fetch('Last-Modified', nil) if respond_to?(:headers))
18
20
  @last_modified = Time.parse(last_modified) if last_modified && /\S/.match(last_modified)
19
21
  end
20
- alias_method :updated_at, :last_modified
22
+ alias updated_at last_modified
21
23
 
22
24
  def self.hash_cache_key(hash)
23
25
  Digest::SHA1.hexdigest(Marshal.dump(hash))
24
26
  end
25
27
  end
26
28
  end
27
- end
29
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WCC
2
4
  module Media
3
5
  class Client < ::WCC::API::RestClient
@@ -20,7 +22,7 @@ module WCC
20
22
 
21
23
  def next_page_query
22
24
  {
23
- offset: page_items.length + skip,
25
+ offset: page_items.length + skip
24
26
  }
25
27
  end
26
28
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'wcc/api/rest_client'
2
4
  require_relative 'message'
3
5
  require_relative 'series'
@@ -12,6 +14,7 @@ module WCC
12
14
  class Client < ::WCC::API::RestClient
13
15
  class << self
14
16
  attr_writer :default
17
+
15
18
  # The default client. Set this in an initializer to change the client used
16
19
  # by all the WCC::Media models
17
20
  def default
@@ -39,9 +42,7 @@ module WCC
39
42
  'playlists' => WCC::Media::Playlist,
40
43
  'streams' => WCC::Media::LiveStream
41
44
  }.freeze
42
- attr_reader(*RESOURCES.keys)
43
-
44
- attr_reader :options
45
+ attr_reader(*RESOURCES.keys, :options)
45
46
 
46
47
  def initialize(**options)
47
48
  options = {
@@ -58,12 +59,12 @@ module WCC
58
59
 
59
60
  Resource =
60
61
  Struct.new(:client, :model, :options) do
61
- def find(id, **params)
62
+ def find(id, **params) # rubocop:disable Metrics/AbcSize
62
63
  raise ArgumentError, "id param must be present, got: #{id}" unless id && /\S/.match(id.to_s)
63
64
 
64
65
  resp = client.get(
65
66
  "#{model.endpoint}/#{id}",
66
- default_params('target').merge(params),
67
+ default_params('target').merge(params)
67
68
  )
68
69
  resp.assert_ok!
69
70
  model.new(resp.body[model.key], resp.headers.freeze)
@@ -71,7 +72,7 @@ module WCC
71
72
 
72
73
  def list(**filters)
73
74
  query = extract_params(filters)
74
- query = query.merge!(apply_filters(filters, model.filters))
75
+ query.merge!(apply_filters(filters, model.filters))
75
76
  resp = client.get(model.endpoint, query)
76
77
  resp.assert_ok!
77
78
  resp.items.map { |s| model.new(s) }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'base'
2
4
  require_relative 'tag_group'
3
5
 
@@ -71,6 +73,7 @@ class WCC::Media::Message < WCC::Media::Base
71
73
  flags
72
74
  assets
73
75
  images
76
+ language
74
77
  external_urls
75
78
  transcript
76
79
  sermon_guide
@@ -85,12 +88,12 @@ class WCC::Media::Message < WCC::Media::Base
85
88
 
86
89
  def has_video? # rubocop:disable Naming/PredicateName
87
90
  assets.each_pair
88
- .any? { |k, v| /video/.match(k) && v && !v.empty? }
91
+ .any? { |k, v| /video/.match(k) && v && !v.empty? }
89
92
  end
90
93
 
91
94
  def has_audio? # rubocop:disable Naming/PredicateName
92
95
  assets.each_pair
93
- .any? { |k, v| /^audio/.match(k) && v && !v.empty? }
96
+ .any? { |k, v| /^audio/.match(k) && v && !v.empty? }
94
97
  end
95
98
 
96
99
  def to_param
@@ -107,6 +110,6 @@ class WCC::Media::Message < WCC::Media::Base
107
110
  end
108
111
  end
109
112
  # pluralize "campus" specifically
110
- alias_method :campuses, :campus
113
+ alias campuses campus
111
114
  remove_method :campus
112
115
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'base'
2
4
  require_relative 'message'
3
5
 
@@ -24,4 +26,4 @@ class WCC::Media::Playlist < WCC::Media::Base
24
26
  def messages
25
27
  (raw['messages'] || []).map { |val| WCC::Media::Message.new(val) }
26
28
  end
27
- end
29
+ end
@@ -2,4 +2,3 @@
2
2
 
3
3
  require 'wcc/rails'
4
4
  require 'wcc/media/client'
5
- require 'wcc/media/engine'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'base'
2
4
 
3
5
  class WCC::Media::Series < WCC::Media::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'base'
2
4
 
3
5
  class WCC::Media::Speaker < WCC::Media::Base
@@ -27,4 +29,4 @@ class WCC::Media::Speaker < WCC::Media::Base
27
29
  end
28
30
  alias_method "#{att}?", att
29
31
  end
30
- end
32
+ end
data/lib/wcc/media/tag.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'base'
2
4
  require_relative 'tag_group'
3
5
 
@@ -19,7 +21,7 @@ class WCC::Media::Tag < WCC::Media::Base
19
21
  end
20
22
 
21
23
  def tag_group
22
- return unless key = raw.dig('tag_group', 'key')
24
+ return unless (key = raw.dig('tag_group', 'key'))
23
25
 
24
26
  WCC::Media::TagGroup[key.to_sym]
25
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  gem 'wcc-data'
2
4
  require 'wcc/data/enumerated_type'
3
5
 
@@ -18,8 +20,8 @@ class WCC::Media::TagGroup < WCC::Data::EnumeratedType
18
20
  end
19
21
 
20
22
  TAG_GROUPS = [
21
- { id: 1, name: "Channels", key: :channels },
22
- { id: 2, name: "Ministries", key: :ministries },
23
- { id: 3, name: "Meta", key: :meta },
24
- { id: 4, name: "Campus", key: :campus },
25
- ]
23
+ { id: 1, name: 'Channels', key: :channels },
24
+ { id: 2, name: 'Ministries', key: :ministries },
25
+ { id: 3, name: 'Meta', key: :meta },
26
+ { id: 4, name: 'Campus', key: :campus }
27
+ ].freeze
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module WCC
2
4
  module Media
3
- VERSION = '0.4.15'.freeze
5
+ VERSION = '0.6.0'
4
6
  end
5
7
  end
@@ -28,26 +28,4 @@ Gem::Specification.new do |spec|
28
28
  spec.add_runtime_dependency 'wcc-auth'
29
29
  spec.add_runtime_dependency 'wcc-base', '~> 0.3.1'
30
30
  spec.add_runtime_dependency 'wcc-data', '~> 0.3.3'
31
-
32
- spec.add_development_dependency 'byebug', '~> 11.0.1'
33
- spec.add_development_dependency 'guard', '~> 2.15'
34
- spec.add_development_dependency 'guard-rspec', '~> 4.7'
35
- spec.add_development_dependency 'guard-rubocop', '1.3.0'
36
- spec.add_development_dependency 'http', '> 1.0', '< 3.0'
37
- spec.add_development_dependency 'httplog', '~> 1.0'
38
- spec.add_development_dependency 'nio4r', '2.5.2'
39
- spec.add_development_dependency 'parallel', '~> 1.19.0'
40
- spec.add_development_dependency 'rails', '~> 5.0'
41
- spec.add_development_dependency 'rake', '~> 12.3'
42
- spec.add_development_dependency 'responders', '< 3.0'
43
- spec.add_development_dependency 'rspec', '~> 3.0'
44
- spec.add_development_dependency 'rspec-rails', '~> 3.7'
45
- spec.add_development_dependency 'rspec_junit_formatter', '~> 0.3.0'
46
- spec.add_development_dependency 'rubocop', '~> 0.60.0'
47
- spec.add_development_dependency 'sidekiq', '< 6.0'
48
- spec.add_development_dependency 'sprockets', '< 4.0'
49
- spec.add_development_dependency 'sqlite3', '~> 1.3.6'
50
- spec.add_development_dependency 'toot', '~> 0.4.1'
51
- spec.add_development_dependency 'typhoeus', '~> 1.3'
52
- spec.add_development_dependency 'webmock', '~> 3.0'
53
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-media-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.15
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-17 00:00:00.000000000 Z
11
+ date: 2022-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wcc-api
@@ -66,306 +66,6 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.3.3
69
- - !ruby/object:Gem::Dependency
70
- name: byebug
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 11.0.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 11.0.1
83
- - !ruby/object:Gem::Dependency
84
- name: guard
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '2.15'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '2.15'
97
- - !ruby/object:Gem::Dependency
98
- name: guard-rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '4.7'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '4.7'
111
- - !ruby/object:Gem::Dependency
112
- name: guard-rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - '='
116
- - !ruby/object:Gem::Version
117
- version: 1.3.0
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - '='
123
- - !ruby/object:Gem::Version
124
- version: 1.3.0
125
- - !ruby/object:Gem::Dependency
126
- name: http
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">"
130
- - !ruby/object:Gem::Version
131
- version: '1.0'
132
- - - "<"
133
- - !ruby/object:Gem::Version
134
- version: '3.0'
135
- type: :development
136
- prerelease: false
137
- version_requirements: !ruby/object:Gem::Requirement
138
- requirements:
139
- - - ">"
140
- - !ruby/object:Gem::Version
141
- version: '1.0'
142
- - - "<"
143
- - !ruby/object:Gem::Version
144
- version: '3.0'
145
- - !ruby/object:Gem::Dependency
146
- name: httplog
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '1.0'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '1.0'
159
- - !ruby/object:Gem::Dependency
160
- name: nio4r
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - '='
164
- - !ruby/object:Gem::Version
165
- version: 2.5.2
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - '='
171
- - !ruby/object:Gem::Version
172
- version: 2.5.2
173
- - !ruby/object:Gem::Dependency
174
- name: parallel
175
- requirement: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - "~>"
178
- - !ruby/object:Gem::Version
179
- version: 1.19.0
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: 1.19.0
187
- - !ruby/object:Gem::Dependency
188
- name: rails
189
- requirement: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - "~>"
192
- - !ruby/object:Gem::Version
193
- version: '5.0'
194
- type: :development
195
- prerelease: false
196
- version_requirements: !ruby/object:Gem::Requirement
197
- requirements:
198
- - - "~>"
199
- - !ruby/object:Gem::Version
200
- version: '5.0'
201
- - !ruby/object:Gem::Dependency
202
- name: rake
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - "~>"
206
- - !ruby/object:Gem::Version
207
- version: '12.3'
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - "~>"
213
- - !ruby/object:Gem::Version
214
- version: '12.3'
215
- - !ruby/object:Gem::Dependency
216
- name: responders
217
- requirement: !ruby/object:Gem::Requirement
218
- requirements:
219
- - - "<"
220
- - !ruby/object:Gem::Version
221
- version: '3.0'
222
- type: :development
223
- prerelease: false
224
- version_requirements: !ruby/object:Gem::Requirement
225
- requirements:
226
- - - "<"
227
- - !ruby/object:Gem::Version
228
- version: '3.0'
229
- - !ruby/object:Gem::Dependency
230
- name: rspec
231
- requirement: !ruby/object:Gem::Requirement
232
- requirements:
233
- - - "~>"
234
- - !ruby/object:Gem::Version
235
- version: '3.0'
236
- type: :development
237
- prerelease: false
238
- version_requirements: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - "~>"
241
- - !ruby/object:Gem::Version
242
- version: '3.0'
243
- - !ruby/object:Gem::Dependency
244
- name: rspec-rails
245
- requirement: !ruby/object:Gem::Requirement
246
- requirements:
247
- - - "~>"
248
- - !ruby/object:Gem::Version
249
- version: '3.7'
250
- type: :development
251
- prerelease: false
252
- version_requirements: !ruby/object:Gem::Requirement
253
- requirements:
254
- - - "~>"
255
- - !ruby/object:Gem::Version
256
- version: '3.7'
257
- - !ruby/object:Gem::Dependency
258
- name: rspec_junit_formatter
259
- requirement: !ruby/object:Gem::Requirement
260
- requirements:
261
- - - "~>"
262
- - !ruby/object:Gem::Version
263
- version: 0.3.0
264
- type: :development
265
- prerelease: false
266
- version_requirements: !ruby/object:Gem::Requirement
267
- requirements:
268
- - - "~>"
269
- - !ruby/object:Gem::Version
270
- version: 0.3.0
271
- - !ruby/object:Gem::Dependency
272
- name: rubocop
273
- requirement: !ruby/object:Gem::Requirement
274
- requirements:
275
- - - "~>"
276
- - !ruby/object:Gem::Version
277
- version: 0.60.0
278
- type: :development
279
- prerelease: false
280
- version_requirements: !ruby/object:Gem::Requirement
281
- requirements:
282
- - - "~>"
283
- - !ruby/object:Gem::Version
284
- version: 0.60.0
285
- - !ruby/object:Gem::Dependency
286
- name: sidekiq
287
- requirement: !ruby/object:Gem::Requirement
288
- requirements:
289
- - - "<"
290
- - !ruby/object:Gem::Version
291
- version: '6.0'
292
- type: :development
293
- prerelease: false
294
- version_requirements: !ruby/object:Gem::Requirement
295
- requirements:
296
- - - "<"
297
- - !ruby/object:Gem::Version
298
- version: '6.0'
299
- - !ruby/object:Gem::Dependency
300
- name: sprockets
301
- requirement: !ruby/object:Gem::Requirement
302
- requirements:
303
- - - "<"
304
- - !ruby/object:Gem::Version
305
- version: '4.0'
306
- type: :development
307
- prerelease: false
308
- version_requirements: !ruby/object:Gem::Requirement
309
- requirements:
310
- - - "<"
311
- - !ruby/object:Gem::Version
312
- version: '4.0'
313
- - !ruby/object:Gem::Dependency
314
- name: sqlite3
315
- requirement: !ruby/object:Gem::Requirement
316
- requirements:
317
- - - "~>"
318
- - !ruby/object:Gem::Version
319
- version: 1.3.6
320
- type: :development
321
- prerelease: false
322
- version_requirements: !ruby/object:Gem::Requirement
323
- requirements:
324
- - - "~>"
325
- - !ruby/object:Gem::Version
326
- version: 1.3.6
327
- - !ruby/object:Gem::Dependency
328
- name: toot
329
- requirement: !ruby/object:Gem::Requirement
330
- requirements:
331
- - - "~>"
332
- - !ruby/object:Gem::Version
333
- version: 0.4.1
334
- type: :development
335
- prerelease: false
336
- version_requirements: !ruby/object:Gem::Requirement
337
- requirements:
338
- - - "~>"
339
- - !ruby/object:Gem::Version
340
- version: 0.4.1
341
- - !ruby/object:Gem::Dependency
342
- name: typhoeus
343
- requirement: !ruby/object:Gem::Requirement
344
- requirements:
345
- - - "~>"
346
- - !ruby/object:Gem::Version
347
- version: '1.3'
348
- type: :development
349
- prerelease: false
350
- version_requirements: !ruby/object:Gem::Requirement
351
- requirements:
352
- - - "~>"
353
- - !ruby/object:Gem::Version
354
- version: '1.3'
355
- - !ruby/object:Gem::Dependency
356
- name: webmock
357
- requirement: !ruby/object:Gem::Requirement
358
- requirements:
359
- - - "~>"
360
- - !ruby/object:Gem::Version
361
- version: '3.0'
362
- type: :development
363
- prerelease: false
364
- version_requirements: !ruby/object:Gem::Requirement
365
- requirements:
366
- - - "~>"
367
- - !ruby/object:Gem::Version
368
- version: '3.0'
369
69
  description: REST Client for accessing the WCC Media library
370
70
  email:
371
71
  - dev@watermark.org
@@ -378,13 +78,11 @@ files:
378
78
  - Gemfile
379
79
  - Guardfile
380
80
  - README.md
381
- - config/routes.rb
382
81
  - lib/wcc/media/active_record_shim.rb
383
82
  - lib/wcc/media/base.rb
384
83
  - lib/wcc/media/cacheable.rb
385
84
  - lib/wcc/media/client.rb
386
85
  - lib/wcc/media/client/response.rb
387
- - lib/wcc/media/engine.rb
388
86
  - lib/wcc/media/live_stream.rb
389
87
  - lib/wcc/media/message.rb
390
88
  - lib/wcc/media/playlist.rb
@@ -400,7 +98,7 @@ homepage: https://github.com/watermarkchurch/media/wcc-media-client
400
98
  licenses:
401
99
  - MIT
402
100
  metadata: {}
403
- post_install_message:
101
+ post_install_message:
404
102
  rdoc_options: []
405
103
  require_paths:
406
104
  - lib
@@ -415,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
415
113
  - !ruby/object:Gem::Version
416
114
  version: '0'
417
115
  requirements: []
418
- rubygems_version: 3.0.3
419
- signing_key:
116
+ rubygems_version: 3.3.22
117
+ signing_key:
420
118
  specification_version: 4
421
119
  summary: ''
422
120
  test_files: []
data/config/routes.rb DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- WCC::Media::Engine.routes.draw do
4
- match "/callbacks", to: Toot::HandlerService, via: :post
5
- end
6
- ActiveSupport::Notifications.instrument 'routes_loaded.engine.media.wcc'
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_job'
4
- require 'toot'
5
- require 'wcc/auth'
6
- require 'wcc/data'
7
-
8
- class WCC::Media::Engine < ::Rails::Engine
9
- isolate_namespace WCC::Media
10
-
11
- class << self
12
- def subscribe(channel, handler = nil, &block)
13
- handler ||= Proc.new(&block)
14
- with_toot_config do |c|
15
- c.subscribe :media, channel, handler
16
- end
17
- end
18
-
19
- def initialized
20
- # Don't register subscriptions unless
21
- # 1. we mounted the engine and
22
- # 2. something subscribed.
23
- ::Toot.config.callback_url &&
24
- ::Toot.config.subscriptions.any? { |s| s.source.name == :media }
25
- end
26
-
27
- def register_subscriptions
28
- return unless initialized
29
-
30
- raise StandardError, "WCC::Auth must be configured" unless WCC::Auth.config.app_name.present? && WCC::Auth.config.app_url.present?
31
-
32
- RegistersSubscriptionsJob.perform_later
33
- end
34
-
35
- # Ensures toot is configured properly with the Media channel. Note this is
36
- # not done until an actual subscription is requested.
37
- def with_toot_config(&block)
38
- return ::Toot.config(&block) if @configured
39
-
40
- ::Toot.config do |c|
41
- media_api_url = WCC::Media::Client.default.api_url
42
-
43
- c.source :media,
44
- channel_prefix: "org.watermark.media.",
45
- subscription_url: URI.join(media_api_url, '/toot/subscriptions')
46
-
47
- # Note - use the [] method to override only if not set in client already
48
- c[:http_connection] ||=
49
- Faraday::Connection.new do |conn|
50
- conn.use :client_app_token
51
- conn.adapter :net_http
52
- end
53
-
54
- yield c
55
- end
56
- @configured = true
57
- end
58
- end
59
-
60
- initializer 'configure WCC::Media Toots' do
61
- ActiveSupport::Notifications.subscribe 'routes_loaded.engine.media.wcc' do
62
- ::Toot.config.callback_url ||=
63
- begin
64
- Rails.application.routes.url_helpers.wcc_media_url + '/callbacks'
65
- rescue ArgumentError => e
66
- raise unless e.message =~ /^Missing host to link to/
67
- end
68
-
69
- if ::Toot.config.callback_url.nil?
70
- Rails.logger.error "Toot.config.callback_url not set! Media webhooks will not be subscribed."
71
- else
72
- WCC::Media::Engine.register_subscriptions
73
- end
74
- end
75
- end
76
-
77
- config.generators do |g|
78
- g.test_framework :rspec, fixture: false
79
- end
80
-
81
- class RegistersSubscriptionsJob < ::ActiveJob::Base
82
- self.queue_adapter = :async
83
-
84
- def perform
85
- Toot::RegistersSubscriptions.call
86
- rescue WCC::Data::Mapper::ServiceUnavailable => e
87
- _handle_error(e)
88
- rescue Faraday::ConnectionFailed => e
89
- _handle_error(e)
90
- rescue Faraday::TimeoutError => e
91
- _handle_error(e)
92
- rescue Faraday::SSLError => e
93
- _handle_error(e)
94
- rescue Toot::RegisterSubscriptionFailure => e
95
- raise unless e.status == 503
96
-
97
- _handle_error(e)
98
- end
99
-
100
- private
101
-
102
- def _handle_error(err)
103
- logger.error "Server is down (will not retry): #{err.class} #{err}"
104
- end
105
- end
106
- end