moirai 0.4.2 → 0.4.3

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: b1ccb1de7355ee89f7ab7c774ef50df313d18e76073cdfca05274c90ffc1b00e
4
- data.tar.gz: 2baade3d17dd785693a3770687bf16555624508936db76cc65346ad83f143319
3
+ metadata.gz: e417177bded1e57fa207b75a86d1b26c7b0d39aa6800b43a7d8a4c15d2926a86
4
+ data.tar.gz: 248a19eaa9ab8eb10113be5166ae7f327f6c368cfaedd323c16296d187d2c35c
5
5
  SHA512:
6
- metadata.gz: 86aaf468fff8de8cdd1c0de8f3af40bccc4fab4ef14c752bea1773d5c5cb7dd3e0a2a1d89616c295265a1d9407398f3c7d31a5a6c8b04185358b02202cebf7c0
7
- data.tar.gz: d822eed2aae03aa6f1eaa4274d2a187d724125ab7b64b8dac6344b5235208ce5995e1703012d905d8384ec7634cb9d191ebd215266147437ab3962b263379bde
6
+ metadata.gz: bb076f72b6715f531af179c2a76802761a2e656e1cec4e27afe7d8bd6c6bda25835b689941eb450c4a5fa1a3b8aed21f624e7cc416873af6333b284191c4139e
7
+ data.tar.gz: dc1cf7853270e580be8af708a3c4e21ad43efcc63a3a1301d28268af82d4933c07d10969f464bf049f07af328254b0036e1af6540425d2ea7d67e4f32be60802
data/CHANGELOG.md CHANGED
@@ -1,10 +1,14 @@
1
+ ## 0.4.3
2
+
3
+ * Do not initialize moirai if we don't have a database connection. ([@coorasse][])
4
+
1
5
  ## 0.4.2
2
6
 
3
- * Fix bug when the params is defined but is `nil`
7
+ * Fix bug when the params is defined but is `nil`. ([@coorasse][])
4
8
 
5
9
  ## 0.4.1
6
10
 
7
- * Fix bug when the string is not a string, but a boolean
11
+ * Fix bug when the string is not a string, but a boolean. ([@coorasse][])
8
12
 
9
13
  ## 0.4.0 - Breaking Changes ⚠️
10
14
 
@@ -16,7 +20,7 @@ config.moirai.enable_inline_editing = ->(params:) { your_options_here }
16
20
 
17
21
  move in here the conditions you had previously defined in the helper.
18
22
 
19
- * Moirai now works also in emails. That's why we have a breaking change.
23
+ * Moirai now works also in emails. That's why we have a breaking change. ([@coorasse][])
20
24
 
21
25
  ## 0.3.1
22
26
 
data/lib/moirai/engine.rb CHANGED
@@ -10,18 +10,26 @@ module Moirai
10
10
 
11
11
  config.moirai = ActiveSupport::OrderedOptions.new
12
12
 
13
+ def self.on_sqlite?
14
+ defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) &&
15
+ ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)
16
+ end
17
+
18
+ def self.on_postgres?
19
+ ActiveRecord::Base.connection.table_exists?("moirai_translations")
20
+ end
21
+
13
22
  config.after_initialize do
14
23
  I18n.original_backend = I18n.backend
15
24
  table_created =
16
25
  begin
17
- (defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) &&
18
- ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter)) ||
19
- ActiveRecord::Base.connection.table_exists?("moirai_translations")
20
- rescue ActiveRecord::NoDatabaseError
26
+ on_sqlite? || on_postgres?
27
+ rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished
21
28
  false
22
29
  end
23
30
  if table_created
24
31
  I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Moirai.new, I18n.backend)
32
+ Rails.logger.info("moirai has been enabled.")
25
33
  else
26
34
  Rails.logger.warn("moirai disabled: tables have not been generated yet.")
27
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moirai
4
- VERSION = "0.4.2"
4
+ VERSION = "0.4.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moirai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Rodi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-11-26 00:00:00.000000000 Z
13
+ date: 2024-11-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails