motor-admin 0.1.9 → 0.1.10

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: 2d6f58a141ea2313b151ee2648a4b98ea3327b8f81b5d7473d8f4a36e6ffb7a4
4
- data.tar.gz: b30868890700641a08cff0abc865e736823def3b066ca8bf38c4968dddd3e2b4
3
+ metadata.gz: dffbef14f764d553575a908cee996e197c587b0db25dbe039c95094e0291e451
4
+ data.tar.gz: 92ba80b363b93b28cd53a80cd0d9725f408f0a8269d0b7398080adfe2c55ad0c
5
5
  SHA512:
6
- metadata.gz: cc33e35f237bc0d15c57da84d67276efa2b26bc09d6b19845a1f6438f81c4e42ec0d5a64274aecaa817faacbde7d5f5c11245b3a0c81f97e3c3e99c808e8b7ec
7
- data.tar.gz: 44152701924a0f006ed102080b612db45a9ca76caf6180c58ad04ec4eb6f8e2210e667a9ceec5228d7a9854a77fca67bf86d0660b655c7715bd71875e4d4a4d7
6
+ metadata.gz: fb50489810374fef3e44f5016660d4a73bb3e3234622b9452522e4050a48c50240ef296b24c7a1c78d73d202df648a60ae1fbcb3a957e20f1d4dac90b762c6ef
7
+ data.tar.gz: e94dc6c92b8d96f6d974dffca9fe49698455d3c2229eada3fa43654caf60e671ff9b8a0c8183fc58ac8b1edeec52e68004d869d2fe6934af42a2b4d55e60943f
@@ -9,19 +9,31 @@ module Motor
9
9
  'text/css'
10
10
  ].freeze
11
11
 
12
+ MIME_TYPES = {
13
+ '.js' => 'application/javascript',
14
+ '.css' => 'text/css',
15
+ '.woff2' => 'font/woff2'
16
+ }.freeze
17
+
12
18
  def show
13
19
  filename = params[:filename]
14
20
 
15
21
  return [404, {}, ''] unless Motor::Assets.manifest.values.include?(filename)
16
22
 
23
+ assign_headers(filename)
24
+
17
25
  self.response_body = CACHE_STORE.fetch(filename) do
18
- Motor::Assets.load_asset(filename)
26
+ Motor::Assets.load_asset(filename, gzip: headers['Content-Encoding'] == 'gzip')
19
27
  end
28
+ end
20
29
 
21
- headers['Content-Type'] = Marcel::MimeType.for(name: filename)
30
+ private
22
31
 
23
- headers['Content-Encoding'] = 'gzip' if !Motor.development? && GZIP_TYPES.include?(headers['Content-Type'])
32
+ def assign_headers(filename)
33
+ content_type = MIME_TYPES[File.extname(filename)]
24
34
 
35
+ headers['Content-Type'] = content_type
36
+ headers['Content-Encoding'] = 'gzip' if !Motor.development? && GZIP_TYPES.include?(content_type)
25
37
  headers['Cache-Control'] = 'max-age=31536000'
26
38
  end
27
39
  end
@@ -44,10 +44,9 @@ module Motor
44
44
  end
45
45
 
46
46
  def update_from_params!(alert, params)
47
- raise NameAlreadyExists if name_already_exists?(alert)
48
-
49
47
  alert = assign_attributes(alert, params)
50
48
 
49
+ raise NameAlreadyExists if name_already_exists?(alert)
51
50
  raise InvalidInterval unless alert.cron
52
51
 
53
52
  ApplicationRecord.transaction do
data/lib/motor/assets.rb CHANGED
@@ -18,16 +18,16 @@ module Motor
18
18
  Motor::Admin.routes.url_helpers.motor_asset_path(manifest[path])
19
19
  end
20
20
 
21
- def load_asset(filename)
21
+ def load_asset(filename, gzip: false)
22
22
  if Motor.development?
23
23
  load_from_dev_server(filename)
24
24
  else
25
- load_from_disk(filename)
25
+ load_from_disk(filename, gzip: gzip)
26
26
  end
27
27
  end
28
28
 
29
- def load_from_disk(filename)
30
- filename += '.gz' if filename.match?(/\.(?:js|css)\z/)
29
+ def load_from_disk(filename, gzip:)
30
+ filename += '.gz' if gzip
31
31
 
32
32
  path = ASSETS_PATH.join(filename)
33
33
 
@@ -31,7 +31,7 @@ module Motor
31
31
  address
32
32
  ].freeze
33
33
 
34
- DISPLAY_NAME_REGEXP = Regexp.new(Regexp.union(DISPLAY_NAMES), Regexp::IGNORECASE)
34
+ DISPLAY_NAME_REGEXP = Regexp.new(Regexp.union(DISPLAY_NAMES).source, Regexp::IGNORECASE)
35
35
 
36
36
  module_function
37
37
 
@@ -58,7 +58,11 @@ module Motor
58
58
  def call
59
59
  models.map do |model|
60
60
  build_model_schema(model)
61
- end
61
+ rescue StandardError => e
62
+ Rails.logger.error(e)
63
+
64
+ next
65
+ end.compact
62
66
  end
63
67
 
64
68
  def models
@@ -69,7 +73,8 @@ module Motor
69
73
 
70
74
  models -= Motor::ApplicationRecord.descendants
71
75
  models -= [ActiveRecord::SchemaMigration] if defined?(ActiveRecord::SchemaMigration)
72
- models -= [ActiveStorage::Blob, ActiveStorage::VariantRecord] if defined?(ActiveStorage::Blob)
76
+ models -= [ActiveStorage::Blob] if defined?(ActiveStorage::Blob)
77
+ models -= [ActiveStorage::VariantRecord] if defined?(ActiveStorage::VariantRecord)
73
78
 
74
79
  models
75
80
  end
@@ -30,10 +30,10 @@ module Motor
30
30
  end
31
31
 
32
32
  def update_from_params!(dashboard, params)
33
- raise TitleAlreadyExists if title_already_exists?(dashboard)
34
-
35
33
  dashboard = assign_attributes(dashboard, params)
36
34
 
35
+ raise TitleAlreadyExists if title_already_exists?(dashboard)
36
+
37
37
  ApplicationRecord.transaction do
38
38
  dashboard.save!
39
39
  end
@@ -30,10 +30,10 @@ module Motor
30
30
  end
31
31
 
32
32
  def update_from_params!(form, params)
33
- raise NameAlreadyExists if name_already_exists?(form)
34
-
35
33
  form = assign_attributes(form, params)
36
34
 
35
+ raise NameAlreadyExists if name_already_exists?(form)
36
+
37
37
  ApplicationRecord.transaction do
38
38
  form.save!
39
39
  end
@@ -30,10 +30,10 @@ module Motor
30
30
  end
31
31
 
32
32
  def update_from_params!(query, params)
33
- raise NameAlreadyExists if name_already_exists?(query)
34
-
35
33
  query = assign_attributes(query, params)
36
34
 
35
+ raise NameAlreadyExists if name_already_exists?(query)
36
+
37
37
  ApplicationRecord.transaction do
38
38
  query.save!
39
39
  end
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.10'
5
5
  end
@@ -5,9 +5,9 @@
5
5
  "fonts/ionicons.ttf?v=3.0.0-alpha.3": "fonts/ionicons.ttf",
6
6
  "fonts/ionicons.woff2?v=3.0.0-alpha.3": "fonts/ionicons.woff2",
7
7
  "fonts/ionicons.woff?v=3.0.0-alpha.3": "fonts/ionicons.woff",
8
- "main-46621a8bdbb789e17c3f.css.gz": "main-46621a8bdbb789e17c3f.css.gz",
9
- "main-46621a8bdbb789e17c3f.js.LICENSE.txt": "main-46621a8bdbb789e17c3f.js.LICENSE.txt",
10
- "main-46621a8bdbb789e17c3f.js.gz": "main-46621a8bdbb789e17c3f.js.gz",
11
- "main.css": "main-46621a8bdbb789e17c3f.css",
12
- "main.js": "main-46621a8bdbb789e17c3f.js"
8
+ "main-4bdedd7fcff1351efaf6.css.gz": "main-4bdedd7fcff1351efaf6.css.gz",
9
+ "main-4bdedd7fcff1351efaf6.js.LICENSE.txt": "main-4bdedd7fcff1351efaf6.js.LICENSE.txt",
10
+ "main-4bdedd7fcff1351efaf6.js.gz": "main-4bdedd7fcff1351efaf6.js.gz",
11
+ "main.css": "main-4bdedd7fcff1351efaf6.css",
12
+ "main.js": "main-4bdedd7fcff1351efaf6.js"
13
13
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-23 00:00:00.000000000 Z
11
+ date: 2021-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -208,8 +208,8 @@ files:
208
208
  - lib/motor/ui_configs.rb
209
209
  - lib/motor/version.rb
210
210
  - ui/dist/fonts/ionicons.woff2
211
- - ui/dist/main-46621a8bdbb789e17c3f.css.gz
212
- - ui/dist/main-46621a8bdbb789e17c3f.js.gz
211
+ - ui/dist/main-4bdedd7fcff1351efaf6.css.gz
212
+ - ui/dist/main-4bdedd7fcff1351efaf6.js.gz
213
213
  - ui/dist/manifest.json
214
214
  homepage:
215
215
  licenses: