moirai 0.4.1 → 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: c5a4c92d52a38c7cbae4d8216b9421d15f6b2db58328ef8f8df5b46da0c97785
4
- data.tar.gz: c23ab52e4a50ee7478abdf41cee44fe04daa7760c1f69179cc7195ca58f70ead
3
+ metadata.gz: e417177bded1e57fa207b75a86d1b26c7b0d39aa6800b43a7d8a4c15d2926a86
4
+ data.tar.gz: 248a19eaa9ab8eb10113be5166ae7f327f6c368cfaedd323c16296d187d2c35c
5
5
  SHA512:
6
- metadata.gz: 1afbdd4d152ddc16ce221e2918092feb2a0e2437af4bce78163b5b2fc9973ebe504b8f42650ffebe56b982f3f646c0602cd9b50c68e17b48c08552b7eed26fd8
7
- data.tar.gz: 78dfa1fafe07d6a51ee10d3afe111767d3ede63cb254b408c44745369aa5a27c5e84922f613e4b7ccdfe8610aa9f7894fe6d07f8f833404c8d0a40a1b90da5bd
6
+ metadata.gz: bb076f72b6715f531af179c2a76802761a2e656e1cec4e27afe7d8bd6c6bda25835b689941eb450c4a5fa1a3b8aed21f624e7cc416873af6333b284191c4139e
7
+ data.tar.gz: dc1cf7853270e580be8af708a3c4e21ad43efcc63a3a1301d28268af82d4933c07d10969f464bf049f07af328254b0036e1af6540425d2ea7d67e4f32be60802
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
+ ## 0.4.3
2
+
3
+ * Do not initialize moirai if we don't have a database connection. ([@coorasse][])
4
+
5
+ ## 0.4.2
6
+
7
+ * Fix bug when the params is defined but is `nil`. ([@coorasse][])
8
+
1
9
  ## 0.4.1
2
10
 
3
- * 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][])
4
12
 
5
13
  ## 0.4.0 - Breaking Changes ⚠️
6
14
 
@@ -12,7 +20,7 @@ config.moirai.enable_inline_editing = ->(params:) { your_options_here }
12
20
 
13
21
  move in here the conditions you had previously defined in the helper.
14
22
 
15
- * 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][])
16
24
 
17
25
  ## 0.3.1
18
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
@@ -25,7 +25,7 @@ module ActionView::Helpers::TranslationHelper # rubocop:disable Lint/ConstantDef
25
25
  alias_method :t, :translate
26
26
 
27
27
  def moirai_edit_enabled?
28
- Moirai.enable_inline_editing.call(params: defined?(params) ? params : {})
28
+ Moirai.enable_inline_editing.call(params: defined?(params) ? (params || {}) : {})
29
29
  end
30
30
 
31
31
  private
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Moirai
4
- VERSION = "0.4.1"
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.1
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