standalone_activerecord_boot_loader 0.1.0 → 0.2.0

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: 4d8f08d56bc81a54009dceeb08cb557f028b0fb2d2114429d49e531bae30f7da
4
- data.tar.gz: 2c5227c63b26e9d7fc743ad6049bbe1499ec78c1d1321c1347d1e04b1d70cee6
3
+ metadata.gz: df4b2b206babe944bedc4374b282b192850edd3488be8a8e3f4c1474a240a1a3
4
+ data.tar.gz: 5575bf0d8a514583e552ae143714f93a384891ac7880e255d7a88341d0f8e32d
5
5
  SHA512:
6
- metadata.gz: c5d433dea59d6197dd8ddd9f91e1d4012ed5d6221c1a3a499354d19132eeee94eb516b671f92935f13d168e13089096cfae400714aa0e0de07ac316647c29aa9
7
- data.tar.gz: c44157dfffbe29e425fda0020ab9e0f642e830318bf5922870480c5d343beeada8a24b9f4109e940a2765b50f23424af6622d081b1372614df50ee9dc10ec9a1
6
+ metadata.gz: 720b7e1078459443e7bf8b68086ba6a56a818d84e07c99390560e27693857fb53fdb2527b8889668ff3d426603fd2102f5371651d5567504462df243da3bcca4
7
+ data.tar.gz: 6129f0fa6078c85c3dbf92e4db0e4f8bcb03fb6bfb32650f91d60cdf08bec89dfc7bd411706b31fad69877f0c821d0a98a7ce74a989da1bc8367c517b7a29b43
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StandaloneActiverecordBootLoader
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -38,17 +38,10 @@ module StandaloneActiverecordBootLoader
38
38
  end
39
39
 
40
40
  def create_database
41
- conn_spec = database_config[@env]
42
-
43
- # ActiveRecord 6系以降
44
- if defined?(ActiveRecord::DatabaseConfigurations::HashConfig)
45
- conn_spec = ActiveRecord::DatabaseConfigurations::HashConfig.new(@env, 'primary', conn_spec)
46
- end
47
-
48
- tasks = ActiveRecord::Tasks::MySQLDatabaseTasks.new(conn_spec)
41
+ tasks = ActiveRecord::Tasks::MySQLDatabaseTasks.new(build_database_config)
49
42
  begin
50
43
  tasks.create
51
- rescue => e
44
+ rescue StandardError => e
52
45
  # ActiveRecord 5系
53
46
  if defined?(ActiveRecord::Tasks::DatabaseAlreadyExists)
54
47
  return if e.instance_of?(ActiveRecord::Tasks::DatabaseAlreadyExists)
@@ -70,5 +63,16 @@ module StandaloneActiverecordBootLoader
70
63
  def database_config
71
64
  @database_config ||= YAML::load(ERB.new(File.read(database_yml_path)).result)
72
65
  end
66
+
67
+ def build_database_config
68
+ unless defined?(ActiveRecord::DatabaseConfigurations::HashConfig)
69
+ return database_config[@env]
70
+ end
71
+
72
+ config = ActiveRecord::DatabaseConfigurations::HashConfig.new(@env, 'primary', database_config[@env])
73
+ return database_config[@env] unless config.respond_to?(:merge)
74
+
75
+ config
76
+ end
73
77
  end
74
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standalone_activerecord_boot_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Ooishi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-18 00:00:00.000000000 Z
11
+ date: 2022-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -60,7 +60,7 @@ licenses: []
60
60
  metadata:
61
61
  homepage_uri: https://github.com/taka0125/standalone_activerecord_boot_loader
62
62
  source_code_uri: https://github.com/taka0125/standalone_activerecord_boot_loader
63
- post_install_message:
63
+ post_install_message:
64
64
  rdoc_options: []
65
65
  require_paths:
66
66
  - lib
@@ -75,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.2.22
79
- signing_key:
78
+ rubygems_version: 3.3.7
79
+ signing_key:
80
80
  specification_version: 4
81
81
  summary: ActiveRecordを単体で動かす時に使う起動処理
82
82
  test_files: []