daddy 0.9.16 → 0.9.18

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: 54b50f10c353ee074f29bc7851e0c5ee33e82a1cf325f2b1178a27565f6b649f
4
- data.tar.gz: 7f05b4291c47f44960853430ac699c4919668898f5aba8d62708c9ac27ed66bd
3
+ metadata.gz: 3e862e37efacb02975df4d1b10c057e38300b96af772d36105af1b987aaf3c33
4
+ data.tar.gz: 37862ad7abc3bd741486ec24abecf8a49560ca801210249378bb8c7c77070a23
5
5
  SHA512:
6
- metadata.gz: 1430690d24611de760e956483befbb9c1b890570f3314c5589e2f66806ee736b5e05a42b287d4bcf9e6df089b7c777f9a570eb7771ae77f3a25fcde0ccc8acbd
7
- data.tar.gz: 6eb971434b89d35e37f405470157bad91a3e175db8d69a96e4b83038aef4e8b7df01d5778ea43242af1c2fd9a736643116017b84512872b95563fe9dc51a4594
6
+ metadata.gz: e74c5c181caac4dc3f77c2b032a6b6776c0b86402e8f204c50e34ca1c485da95a8c2a92e569c84d782f26587dc04ab2647f06b7c5e1a24285dff099123b09706
7
+ data.tar.gz: 3bea0cc1bf10b09cb6e660512f5cd51c8f30cf93e6834a65d938e373d0908d8e7cacc78e9d4c2a76eb8b52e7fbcf191d1b08ec2f53a069ea24a2c9107efb460f
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 = '16'
5
+ VERSION_REVISION = '18'
6
6
  ].join('.')
7
7
  end
@@ -10,19 +10,29 @@ namespace :dad do
10
10
  FileUtils.mkdir_p("tmp")
11
11
  system("echo '# mysql ddl' > tmp/create_databases.sql")
12
12
 
13
+ user = host = port = nil
14
+ config.each do |env, props|
15
+ next if env == 'default'
16
+ next if props['username'] == user
17
+
18
+ user = props['username']
19
+ host = props['host']
20
+ port = props['port']
21
+ system("echo 'drop user if exists \"#{user}\"@\"%\";' >> tmp/create_databases.sql")
22
+ system("echo 'create user \"#{user}\"@\"%\" IDENTIFIED BY \"#{props['password']}\";' >> tmp/create_databases.sql")
23
+ end
24
+
13
25
  config.each do |env, props|
14
26
  next if env == 'default'
15
27
  next if ENV['RAILS_ENV'] and ENV['RAILS_ENV'] != env
16
28
 
17
29
  system("echo 'drop database if exists #{props['database']};' >> tmp/create_databases.sql")
18
30
  system("echo 'create database #{props['database']};' >> tmp/create_databases.sql")
19
- system("echo 'drop user if exists \"#{props['username']}\"@\"%\";' >> tmp/create_databases.sql")
20
- system("echo 'create user \"#{props['username']}\"@\"%\" IDENTIFIED BY \"#{props['password']}\";' >> tmp/create_databases.sql")
21
- system("echo 'grant all on #{props['database']}.* to #{props['username']} identified by \"#{props['password']}\";' >> tmp/create_databases.sql")
31
+ system("echo 'grant all on #{props['database']}.* to #{user};' >> tmp/create_databases.sql")
22
32
 
23
33
  if ENV['FILE']
24
- system("echo 'grant all on #{props['database']}.* to #{props['username']}@localhost identified by \"#{props['password']}\";' >> tmp/create_databases.sql")
25
- system("echo 'grant file on *.* to #{props['username']}@localhost;' >> tmp/create_databases.sql")
34
+ system("echo 'grant all on #{props['database']}.* to #{user}@localhost;' >> tmp/create_databases.sql")
35
+ system("echo 'grant file on *.* to #{user}@localhost;' >> tmp/create_databases.sql")
26
36
  end
27
37
  puts "database for environment #{env} written to tmp/create_databases.sql"
28
38
  end
@@ -30,11 +40,22 @@ namespace :dad do
30
40
  system("echo 'flush privileges;' >> tmp/create_databases.sql")
31
41
  system("echo >> tmp/create_databases.sql")
32
42
 
43
+ options = []
44
+ if host
45
+ port ||= 3306 if host != 'localhost'
46
+ options << "-h #{host}"
47
+ options << "-P #{port}" if port
48
+ end
33
49
  if ENV['MYSQL_NO_ROOT_PASSWORD']
34
- fail unless system("mysql -u root < tmp/create_databases.sql")
50
+ options << '-u root'
35
51
  else
36
- fail unless system("mysql -u #{ENV['MYSQL_ROOT'] || 'root'} -p < tmp/create_databases.sql")
52
+ options << "-u #{ENV['MYSQL_ROOT'] || 'root'}"
53
+ options << '-p'
37
54
  end
55
+
56
+ command = "mysql #{options.join(' ')} < tmp/create_databases.sql"
57
+ puts command
58
+ fail unless system(command)
38
59
  end
39
60
  end
40
61
  end
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.16
4
+ version: 0.9.18
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-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api