daddy 0.9.15 → 0.9.17

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: 83f26abfad4548e521a75c8739d373be17e949ecefdd24ee5ae6720345cfb657
4
- data.tar.gz: 4e7e951bcedf7df58de4bc9cb31e95351b7641eff3dfb593455d9adc0adac63d
3
+ metadata.gz: 16b6d0ee819d9a4ea56297e4fd52f2ab9fa091eb5122f5402160e95599e93bcd
4
+ data.tar.gz: 2d647c14595a3a42b36863b7fe3b272a64e6efb9bce19761255e618baf67cfb1
5
5
  SHA512:
6
- metadata.gz: 692b8c969023e967bd64d2c4153797b938fa16a432a8b21866a757d12aef468febd0a0ab940ccd84c4640d689f2ca5a5ad0e777ef5de56b224f9caf0327a2f1f
7
- data.tar.gz: 2f0f3343079e1471b435d69621f29b421ecb3cfcffbb5ade14c490857af148634f40235d698085a4eaac7a9fb96a04dc49958c1935c9739117c99dd1219d8a32
6
+ metadata.gz: 6104f6985d62771b44c0a45d0e21f7d940b7cacc5c88432dbc6d6eaca26f0f2cfd55875027f9d4f82ee832471bd388614e356c4cf5abae3f8595c24b87934811
7
+ data.tar.gz: 73b78f59158b82056e5bd57e12733d2e62825dd145a5bd6f86a5eb33ef232ed2fe85f804ca25ba03c324c76777f5ce52b58dadd58ea6d71ca32812f2d656a2cb
data/lib/daddy/version.rb CHANGED
@@ -2,6 +2,6 @@ module Daddy
2
2
  VERSION = [
3
3
  VERSION_MAJOR = '0',
4
4
  VERSION_MINOR = '9',
5
- VERSION_REVISION = '15'
5
+ VERSION_REVISION = '17'
6
6
  ].join('.')
7
7
  end
@@ -8,7 +8,7 @@ namespace :dad do
8
8
  @app_name = File.basename(Rails.root)[0..15]
9
9
 
10
10
  template = File.join(File.dirname(__FILE__), 'db/database.yml.erb')
11
- render template, :to => 'config/database.yml'
11
+ render template, to: 'config/database.yml'
12
12
  end
13
13
  end
14
14
  end
@@ -5,31 +5,39 @@ namespace :dad do
5
5
 
6
6
  desc 'database.yml に従ってDBを作成します。'
7
7
  task :create do
8
- config = YAML.load(ERB.new(File.read('config/database.yml'), 0, '-').result)
8
+ config = YAML.safe_load(ERB.new(File.read('config/database.yml'), 0, '-').result, [], [], aliases: true)
9
9
 
10
10
  FileUtils.mkdir_p("tmp")
11
11
  system("echo '# mysql ddl' > tmp/create_databases.sql")
12
12
 
13
+ user = nil
13
14
  config.each do |env, props|
14
15
  next if env == 'default'
16
+ next if props['username'] == user
17
+
18
+ user = props['username']
19
+ system("echo 'drop user if exists \"#{user}\"@\"%\";' >> tmp/create_databases.sql")
20
+ system("echo 'create user \"#{user}\"@\"%\" IDENTIFIED BY \"#{props['password']}\";' >> tmp/create_databases.sql")
21
+ end
22
+
23
+ config.each do |env, props|
24
+ next if env == 'default'
25
+ next if ENV['RAILS_ENV'] and ENV['RAILS_ENV'] != env
15
26
 
16
- puts "database for environment #{env}"
17
27
  system("echo 'drop database if exists #{props['database']};' >> tmp/create_databases.sql")
18
28
  system("echo 'create database #{props['database']};' >> tmp/create_databases.sql")
19
- system("echo 'grant all on #{props['database']}.* to #{props['username']} identified by \"#{props['password']}\";' >> tmp/create_databases.sql")
29
+ system("echo 'grant all on #{props['database']}.* to #{user};' >> tmp/create_databases.sql")
20
30
 
21
31
  if ENV['FILE']
22
- system("echo 'grant all on #{props['database']}.* to #{props['username']}@localhost identified by \"#{props['password']}\";' >> tmp/create_databases.sql")
23
- system("echo 'grant file on *.* to #{props['username']}@localhost;' >> tmp/create_databases.sql")
32
+ system("echo 'grant all on #{props['database']}.* to #{user}@localhost;' >> tmp/create_databases.sql")
33
+ system("echo 'grant file on *.* to #{user}@localhost;' >> tmp/create_databases.sql")
24
34
  end
35
+ puts "database for environment #{env} written to tmp/create_databases.sql"
25
36
  end
26
37
 
27
38
  system("echo 'flush privileges;' >> tmp/create_databases.sql")
28
39
  system("echo >> tmp/create_databases.sql")
29
40
 
30
- puts
31
- puts File.read('tmp/create_databases.sql')
32
-
33
41
  if ENV['MYSQL_NO_ROOT_PASSWORD']
34
42
  fail unless system("mysql -u root < tmp/create_databases.sql")
35
43
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.15
4
+ version: 0.9.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - ichy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-09 00:00:00.000000000 Z
11
+ date: 2025-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api
@@ -466,7 +466,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
466
466
  - !ruby/object:Gem::Version
467
467
  version: '0'
468
468
  requirements: []
469
- rubygems_version: 3.4.22
469
+ rubygems_version: 3.3.26
470
470
  signing_key:
471
471
  specification_version: 4
472
472
  summary: My rails dad