panda_pal 5.3.12 → 5.3.13

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: 776a9f59c8500e45d110c3e672e8ec97a891e186687473f33d4561ea74f31902
4
- data.tar.gz: b308adfeea7b3b5c15b2a023edd9a0e5eec8a0a768e1fc58c0ecc2c40891cbd0
3
+ metadata.gz: c8eb58ee2c4df4d91c08b20c3ea717a1227ebbc212500b6f5a0abad01855fd8c
4
+ data.tar.gz: ba0b60f6ee46634a554ac779b6cadf671edb922bc33201ac762de4fa9263ec45
5
5
  SHA512:
6
- metadata.gz: 81b794f8cb355eb4c1f2b3497062cf513e240349212a5b607edfcbe7e47074010cb3ef2fdb9da3025e492ed9c8f75b306270adefb59cc73919469f08a21ad664
7
- data.tar.gz: a840a2ad126d6b06f54ec8786b964de3e1095f6f9243d0dcf8b3a18d694f1fa05994127969756678639aacf16849ed7c8528744fd01c7bcf89660c05c891aada
6
+ metadata.gz: 1337a89241f5a12bc0f5d202197f17f6ea4478be3e44786e68cd2b2161fc8df0cc2338418c4cdacbaa99cb1ec9e07a06446bac3a9a9a965285f35b4cbdce91cb
7
+ data.tar.gz: 83c6c892aad41adc5fd7ec2709dd8f5b5a70c238764b9caad989f5a2021ee92d81c64ac05e6ce7a3e72d321d2abfa8b1aba3b1298b2225fff4d476b57d4bd3c6
@@ -8,8 +8,16 @@ module PandaPal
8
8
  end
9
9
 
10
10
  class_methods do
11
+ def define_setting(*args, &blk)
12
+ @_injected_settings_definitions ||= []
13
+ @_injected_settings_definitions << {
14
+ args: args,
15
+ block: blk,
16
+ }
17
+ end
18
+
11
19
  def settings_structure
12
- if PandaPal.lti_options&.[](:settings_structure).present?
20
+ struc = if PandaPal.lti_options&.[](:settings_structure).present?
13
21
  normalize_settings_structure(PandaPal.lti_options[:settings_structure])
14
22
  else
15
23
  {
@@ -18,6 +26,32 @@ module PandaPal
18
26
  properties: {},
19
27
  }
20
28
  end
29
+
30
+ (@_injected_settings_definitions || []).each do |sub|
31
+ args = [*sub[:args]]
32
+ path = args.shift || []
33
+ path = path.split('.') if path.is_a?(String)
34
+ path = Array(path)
35
+
36
+ if path.present?
37
+ key = path.pop
38
+
39
+ root = struc
40
+ path.each do |p|
41
+ root = root[:properties][p.to_sym]
42
+ end
43
+
44
+ if sub[:block]
45
+ root[:properties][key.to_sym] = sub[:block].call
46
+ else
47
+ root[:properties][key.to_sym] = args.shift
48
+ end
49
+ else
50
+ sub[:block].call(struc)
51
+ end
52
+ end
53
+
54
+ struc
21
55
  end
22
56
 
23
57
  def normalize_settings_structure(struc)
@@ -69,7 +103,7 @@ module PandaPal
69
103
  any_match = norm_types.any? do |t|
70
104
  if t == 'Boolean'
71
105
  settings == true || settings == false
72
- else
106
+ elsif t.is_a?(Class)
73
107
  settings.is_a?(t)
74
108
  end
75
109
  end
@@ -11,6 +11,31 @@ module PandaPal
11
11
  included do
12
12
  after_commit :sync_schedule, on: [:create, :update]
13
13
  after_commit :unschedule_tasks, on: :destroy
14
+
15
+ define_setting do |struc|
16
+ next unless _schedule_descriptors.present?
17
+
18
+ struc[:properties][:timezone] ||= {
19
+ type: 'String',
20
+ required: false,
21
+ validate: ->(timezone, *args) {
22
+ ActiveSupport::TimeZone[timezone].present? ? nil : "<path> Invalid Timezone '#{timezone}'"
23
+ },
24
+ }
25
+
26
+ struc[:properties][:task_schedules] = {
27
+ type: 'Hash',
28
+ required: false,
29
+ properties: _schedule_descriptors.keys.reduce({}) do |hash, k|
30
+ desc = _schedule_descriptors[k]
31
+
32
+ hash.tap do |hash|
33
+ kl = ' ' * (k.to_s.length - 4)
34
+ hash[k.to_sym] = hash[k.to_s] = PandaPal::OrganizationConcerns::TaskScheduling.build_settings_entry(desc)
35
+ end
36
+ end,
37
+ }
38
+ end
14
39
  end
15
40
 
16
41
  class_methods do
@@ -18,35 +43,6 @@ module PandaPal
18
43
  @_schedule_descriptors ||= {}
19
44
  end
20
45
 
21
- def settings_structure
22
- return super unless _schedule_descriptors.present?
23
-
24
- super.tap do |struc|
25
- struc[:properties] ||= {}
26
-
27
- struc[:properties][:timezone] ||= {
28
- type: 'String',
29
- required: false,
30
- validate: ->(timezone, *args) {
31
- ActiveSupport::TimeZone[timezone].present? ? nil : "<path> Invalid Timezone '#{timezone}'"
32
- },
33
- }
34
-
35
- struc[:properties][:task_schedules] = {
36
- type: 'Hash',
37
- required: false,
38
- properties: _schedule_descriptors.keys.reduce({}) do |hash, k|
39
- desc = _schedule_descriptors[k]
40
-
41
- hash.tap do |hash|
42
- kl = ' ' * (k.to_s.length - 4)
43
- hash[k.to_sym] = hash[k.to_s] = PandaPal::OrganizationConcerns::TaskScheduling.build_settings_entry(desc)
44
- end
45
- end,
46
- }
47
- end
48
- end
49
-
50
46
  def scheduled_task(cron_time, name_or_method = nil, worker: nil, queue: nil, &block)
51
47
  task_key = (name_or_method.presence || "scheduled_task_#{caller_locations[0].lineno}").to_s
52
48
  raise "Task key '#{task_key}' already taken!" if _schedule_descriptors.key?(task_key)
@@ -1,3 +1,3 @@
1
1
  module PandaPal
2
- VERSION = "5.3.12"
2
+ VERSION = "5.3.13"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panda_pal
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.12
4
+ version: 5.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Instructure ProServe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-19 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails