system_settings 0.5.0 → 0.5.1

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
- SHA1:
3
- metadata.gz: 2036203e28d2865ae3f3e30c35f5edb3df4b0521
4
- data.tar.gz: f29b50d3c8ec75d7132d1101300aa2bdea5e43bb
2
+ SHA256:
3
+ metadata.gz: afe9ba8b4637175f7d2640470fb5b76f1b3571adcb372665e526cba396005185
4
+ data.tar.gz: bed30ae08b20275af2fd92bf477a9d71ca2b39bb9b53ace4a7beb2453af74da6
5
5
  SHA512:
6
- metadata.gz: 61485716578503ff6f5248fc4dbc90aafac5d7e555e83d174ea8ea5b8b0f978e22bdcbf2065685b56c0e4bfff5666227e1674c899d165a6217b9b3a133469854
7
- data.tar.gz: abce6f1eee8d79749d13ed8eac27f8862e6ac778263f7647d618cbe4b4120eb33207638af86809775a2dd8034e98d8766ba22c38b69c26eb22a2d599dfbf9f89
6
+ metadata.gz: 71f7750c242feaf7c10968bfda2f9379c8cd99b683da19db0174ba41823694b384283974a134ae0f5e567782f5d963d4bc015cf7d0017bea26c1e8befca684a3
7
+ data.tar.gz: 70d9f8b6b6e52c66f24a1c4ed36658be555f96416c01a3f32f23251c4fb3f0e9d2e782484e609099a425764776c91b5d7eae69c449eea7b352080929d6a69ac6
@@ -1,14 +1,14 @@
1
1
  module SystemSettings
2
2
  class Configurator
3
3
  class << self
4
- def from_file(file_name)
4
+ def from_file(file_name, kernel_class: Kernel)
5
5
  file_name = file_name.to_path if file_name.respond_to?(:to_path)
6
6
  raise Errors::SettingsReadError, "The file name must either be a String or implement #to_path" unless file_name.is_a?(String)
7
7
  raise Errors::SettingsReadError, "#{file_name} file does not exist" unless File.exist?(file_name)
8
8
  raise Errors::SettingsReadError, "#{file_name} file not readable" unless File.readable?(file_name)
9
9
  SystemSettings.instrument("system_settings.from_file", path: file_name) do |payload|
10
10
  file_content = File.read(file_name)
11
- new.tap do |obj|
11
+ new(kernel_class: kernel_class).tap do |obj|
12
12
  obj.instance_eval(file_content, file_name, 1)
13
13
  payload[:items] = obj.items
14
14
  end
@@ -22,8 +22,9 @@ module SystemSettings
22
22
 
23
23
  attr_reader :items
24
24
 
25
- def initialize(&block)
25
+ def initialize(kernel_class: Kernel, &block)
26
26
  @items = []
27
+ @kernel_class = kernel_class
27
28
  return unless block_given?
28
29
  if block.arity == 1
29
30
  yield self
@@ -57,9 +58,13 @@ module SystemSettings
57
58
  if settings_table_exists?
58
59
  SystemSettings::Setting.transaction do
59
60
  @items.each do |entry|
60
- persisted_record = entry[:class].find_by(name: entry[:name])
61
+ persisted_record = SystemSettings::Setting.find_by(name: entry[:name])
61
62
  if persisted_record
62
- persisted_record.update!(description: entry[:description])
63
+ if persisted_record.class == entry[:class]
64
+ persisted_record.update!(description: entry[:description])
65
+ else
66
+ warn "SystemSettings: Type mismatch detected! Previously #{entry[:name]} had type #{persisted_record.class.name} but you are loading #{entry[:class].name}"
67
+ end
63
68
  else
64
69
  entry[:class].create!(name: entry[:name], value: entry[:value], description: entry[:description])
65
70
  end
@@ -86,6 +91,10 @@ module SystemSettings
86
91
 
87
92
  private
88
93
 
94
+ def warn(*args)
95
+ @kernel_class.warn(*args)
96
+ end
97
+
89
98
  def settings_table_exists?
90
99
  SystemSettings::Setting.table_exists?
91
100
  end
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "/system_settings/static/css/main.92b62519.chunk.css",
4
- "main.js": "/system_settings/static/js/main.3240d6b4.chunk.js",
4
+ "main.js": "/system_settings/static/js/main.127b4c25.chunk.js",
5
5
  "runtime~main.js": "/system_settings/static/js/runtime~main.a09e9b82.js",
6
- "static/js/2.3fd64734.chunk.js": "/system_settings/static/js/2.3fd64734.chunk.js",
6
+ "static/js/2.3891b1da.chunk.js": "/system_settings/static/js/2.3891b1da.chunk.js",
7
7
  "index.html": "/system_settings/index.html",
8
- "precache-manifest.0e020e029f3aadbe0b26621b84010585.js": "/system_settings/precache-manifest.0e020e029f3aadbe0b26621b84010585.js",
8
+ "precache-manifest.9a5e0d0daf376c08f5a7b80b49b88371.js": "/system_settings/precache-manifest.9a5e0d0daf376c08f5a7b80b49b88371.js",
9
9
  "service-worker.js": "/system_settings/service-worker.js"
10
10
  }
11
11
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="shortcut icon" href="/system_settings/favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><title>System Settings</title><link href="/system_settings/static/css/main.92b62519.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="/system_settings/static/js/runtime~main.a09e9b82.js"></script><script src="/system_settings/static/js/2.3fd64734.chunk.js"></script><script src="/system_settings/static/js/main.3240d6b4.chunk.js"></script></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"><link rel="shortcut icon" href="/system_settings/favicon.ico"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><title>System Settings</title><link href="/system_settings/static/css/main.92b62519.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="/system_settings/static/js/runtime~main.a09e9b82.js"></script><script src="/system_settings/static/js/2.3891b1da.chunk.js"></script><script src="/system_settings/static/js/main.127b4c25.chunk.js"></script></body></html>
@@ -1,19 +1,19 @@
1
1
  self.__precacheManifest = (self.__precacheManifest || []).concat([
2
2
  {
3
- "revision": "992f4780889b7b5d8cb84042a0e994c6",
3
+ "revision": "cbe97afd60ae091779221d8d269d3186",
4
4
  "url": "/system_settings/index.html"
5
5
  },
6
6
  {
7
- "revision": "7a76831de683d940339e",
7
+ "revision": "1aff74f8dd7cf841b97d",
8
8
  "url": "/system_settings/static/css/main.92b62519.chunk.css"
9
9
  },
10
10
  {
11
- "revision": "78fcb78c6fb9ed311d5f",
12
- "url": "/system_settings/static/js/2.3fd64734.chunk.js"
11
+ "revision": "cb5e14f25e489e1305c3",
12
+ "url": "/system_settings/static/js/2.3891b1da.chunk.js"
13
13
  },
14
14
  {
15
- "revision": "7a76831de683d940339e",
16
- "url": "/system_settings/static/js/main.3240d6b4.chunk.js"
15
+ "revision": "1aff74f8dd7cf841b97d",
16
+ "url": "/system_settings/static/js/main.127b4c25.chunk.js"
17
17
  },
18
18
  {
19
19
  "revision": "1b52e032205e59a9e84f",
@@ -14,7 +14,7 @@
14
14
  importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");
15
15
 
16
16
  importScripts(
17
- "/system_settings/precache-manifest.0e020e029f3aadbe0b26621b84010585.js"
17
+ "/system_settings/precache-manifest.9a5e0d0daf376c08f5a7b80b49b88371.js"
18
18
  );
19
19
 
20
20
  self.addEventListener('message', (event) => {