eac_rails_utils 0.31.0 → 0.32.0

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: 4a442a83237bb4c4446106d2ccadbc8bd81ade0bcd9ec0cda330672d35496cce
4
- data.tar.gz: 2b5b31e8dca29d124536f249ec48c5d8166f0ad0dd3d817fe35ad3866e37394e
3
+ metadata.gz: 4c1c8cc243cf56400a3dbabd1a60d2f4446fd9976f4c058566e79111f82e5213
4
+ data.tar.gz: c2dab26dc092a2685758c5fe6813e93150e1cb5a0ed09a149aceb095e1f9db2d
5
5
  SHA512:
6
- metadata.gz: 7e2bf5bdbaeef59c7319f2f53a8671b5a9027df5583215ec4f93ef6fa176cc385fcc89ee022b99413a671dd417e31da34884d9143b62ca2f49af2ec1fcc6649d
7
- data.tar.gz: e19dc24f46d0711405477120be44cc98b0cca36ca62d549361a991f10d219f731662b2149b35ef3e09106dd6a57c600c954f2aa1c26a73f78c9a40cdf737b712
6
+ metadata.gz: b9c411f024f75fe5bc5de0502eac45d4dc4e5711b6cb28b09d24b1700fbb6392a0049cc72d67d3066837c1e10cb4c7155313f3f506d183fc62ce0b419cecc047
7
+ data.tar.gz: f548f87ffaa910b5c33f3e1b99b2bf498c1db924a12f7a59b2d375358b578687dcd89fa990bfab3bd891f051c4e936a7765645912b79077fb26c13affa65011d
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsUtils
4
+ module Availability
5
+ class << self
6
+ # @return [Boolean]
7
+ def database?
8
+ ::ActiveRecord::Base.connection.table_exists?('any_table_name')
9
+ rescue ActiveRecord::NoDatabaseError, PG::ConnectionBad
10
+ false
11
+ else
12
+ true
13
+ end
14
+
15
+ # @return [Boolean]
16
+ def database_schema?
17
+ database? && ::RedminePluginsHelper::Migration.from_code.all?(&:applied?)
18
+ end
19
+
20
+ # @param model_classes [Enumerable<>]
21
+ # @return [Boolean]
22
+ def model?(*model_classes)
23
+ table?(*model_classes.map(&:table_name))
24
+ end
25
+
26
+ # @param table_names [Enumerable<String>]
27
+ # @return [Boolean]
28
+ def table?(*table_names)
29
+ database? && table_names
30
+ .all? { |table_name| ::ActiveRecord::Base.connection.table_exists?(table_name) }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -12,6 +12,7 @@ module EacRailsUtils
12
12
  common_concern do
13
13
  append_after_initializers
14
14
  append_autoload_paths
15
+ append_mailer_preview_paths
15
16
  append_self_migrations
16
17
  end
17
18
 
@@ -32,6 +33,16 @@ module EacRailsUtils
32
33
  config.autoload_paths += Dir["#{config.root}/lib"]
33
34
  end
34
35
 
36
+ # @return [void]
37
+ def append_mailer_preview_paths
38
+ initializer :append_mailer_preview_paths, before: 'action_mailer.set_configs' do |app|
39
+ %w[spec test].each do |test_dir|
40
+ path = config.root.join(test_dir, 'mailers', 'previews')
41
+ (app.config.action_mailer.preview_paths ||= []) << path if path.directory?
42
+ end
43
+ end
44
+ end
45
+
35
46
  def append_self_migrations
36
47
  initializer :append_migrations do |app|
37
48
  config.paths['db/migrate'].expanded.each do |expanded_path|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.31.0'
4
+ VERSION = '0.32.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.0
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E.A.C.
@@ -192,6 +192,7 @@ files:
192
192
  - config/locales/en.yml
193
193
  - config/locales/pt-BR.yml
194
194
  - lib/eac_rails_utils.rb
195
+ - lib/eac_rails_utils/availability.rb
195
196
  - lib/eac_rails_utils/engine.rb
196
197
  - lib/eac_rails_utils/engine_helper.rb
197
198
  - lib/eac_rails_utils/menus/action.rb