discourse_subscription_client 0.1.0.pre12 → 0.1.0.pre14

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: d17f2464b6f962f809428eea6207696f20a1d935ed573ec0f3970242712a8da9
4
- data.tar.gz: f226a6927bc9e41fcd199572d5417850212de9d335ed58fa325b58b0842776d3
3
+ metadata.gz: 07afbdfba495c751b1a4f98c5ab657e5f0e044613e525ed806a438a97d41e994
4
+ data.tar.gz: 790e0abe8336eeb2f53eeb0f49a975d0f2a5a9054b6bc56bee6435d76474c563
5
5
  SHA512:
6
- metadata.gz: cda4eb9051cbeb1a62e317a314d79bd08a2e0eb255775adf6e0c45ff53bb527ab3b14338d0a90d4f09fc28a8da20ebb3f375eeba33bc43770d7eb07734d99fa7
7
- data.tar.gz: 72cfb38e708e8a4c8bb56cb8d38a7374300d194e68c461ef32bca490a199e00775463ec3196fca50b0166ee6d49ad0b04e9e25fda689811eab127074ac81e915
6
+ metadata.gz: 4d63f530f372e9fe425ca8584ed89b64ae2b95815ee61de495c2b77946b6e379ade75705bb225d6f89433f9ea0fbcd6f643c67dec0f3f7f6f593f23d97aaed6c
7
+ data.tar.gz: 9875787a8a6de21f0fe8d9482f82cd3045dd73a9394e2d6d2ba6d2b3892d569162628b2eed2e5974200aab3ea6e3c9833a00e1f91c9042d643267d1b59d3df22
@@ -7,9 +7,18 @@ module DiscourseSubscriptionClient
7
7
  engine_name PLUGIN_NAME
8
8
  isolate_namespace DiscourseSubscriptionClient
9
9
 
10
+ def enabled_site_setting
11
+ @enabled_site_setting = "subscription_client_enabled"
12
+ end
13
+
14
+ def configurable?
15
+ true
16
+ end
17
+
10
18
  config.before_initialize do
11
19
  config.i18n.load_path += Dir["#{config.root}/config/locales/**/*.yml"]
12
20
  Rails.autoloaders.main.ignore(config.root) if defined?(Rails) == "constant"
21
+ Discourse.plugins_by_name[PLUGIN_NAME] = self
13
22
  end
14
23
 
15
24
  config.after_initialize do
@@ -35,7 +35,14 @@ module DiscourseSubscriptionClient
35
35
  end
36
36
 
37
37
  def find_resources
38
- find_plugins
38
+ resources = find_plugins
39
+
40
+ resources.each do |r|
41
+ @resources << {
42
+ name: r[:name],
43
+ supplier_url: r[:supplier_url]
44
+ }
45
+ end
39
46
  end
40
47
 
41
48
  def find_suppliers
@@ -73,17 +80,19 @@ module DiscourseSubscriptionClient
73
80
  end
74
81
 
75
82
  def find_plugins
83
+ plugins = []
76
84
  Dir["#{DiscourseSubscriptionClient.root}/plugins/*/plugin.rb"].sort.each do |path|
77
85
  source = File.read(path)
78
86
  metadata = Plugin::Metadata.parse(source)
79
87
 
80
88
  next unless metadata.subscription_url.present?
81
89
 
82
- @resources << {
90
+ plugins << {
83
91
  name: metadata.name,
84
92
  supplier_url: ENV["TEST_SUBSCRIPTION_URL"] || metadata.subscription_url
85
93
  }
86
94
  end
95
+ plugins
87
96
  end
88
97
 
89
98
  def valid_supplier_data?(data)
@@ -93,12 +102,11 @@ module DiscourseSubscriptionClient
93
102
  return false unless data[:products].is_a?(Hash)
94
103
 
95
104
  data[:products].all? do |_resource, products|
96
- products.is_a?(Array) &&
97
- products.all? do |product|
98
- %i[product_id product_slug].all? do |key|
99
- product.key?(key) && product[key].is_a?(String)
100
- end
105
+ products.is_a?(Array) && products.all? do |product|
106
+ %i[product_id product_slug].all? do |key|
107
+ product.key?(key) && product[key].is_a?(String)
101
108
  end
109
+ end
102
110
  end
103
111
  end
104
112
  end
@@ -13,6 +13,8 @@ module DiscourseSubscriptionClient
13
13
  def update
14
14
  return unless SiteSetting.subscription_client_enabled
15
15
 
16
+ DiscourseSubscriptionClient::Resources.find_all
17
+
16
18
  @result = DiscourseSubscriptionClient::Subscriptions::UpdateResult.new
17
19
 
18
20
  if @suppliers.blank?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DiscourseSubscriptionClient
4
- VERSION = "0.1.0.pre12"
4
+ VERSION = "0.1.0.pre14"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: discourse_subscription_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre12
4
+ version: 0.1.0.pre14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Angus McLeod
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-31 00:00:00.000000000 Z
11
+ date: 2023-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -278,7 +278,7 @@ metadata:
278
278
  homepage_uri: https://github.com/paviliondev/discourse_subscription_client
279
279
  source_code_uri: https://github.com/paviliondev/discourse_subscription_client
280
280
  changelog_uri: https://github.com/paviliondev/discourse_subscription_client
281
- post_install_message:
281
+ post_install_message:
282
282
  rdoc_options: []
283
283
  require_paths:
284
284
  - lib
@@ -294,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
294
294
  version: 1.3.1
295
295
  requirements: []
296
296
  rubygems_version: 3.4.6
297
- signing_key:
297
+ signing_key:
298
298
  specification_version: 4
299
299
  summary: Discourse plugin subscription client.
300
300
  test_files: []