phenix 0.3.0 → 0.4.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 +4 -4
- data/lib/phenix.rb +25 -12
- data/lib/phenix/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02c40fe211c590d4f7ba84d7133271b50669088d
|
4
|
+
data.tar.gz: 25735809d7f5d851b18081a2bfd0ec2de39298a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3713144e578b2a711a8f56d8be89bd2f458922dcb5ed63a0fff078c74d1243f3d77b07ee67813a1b8769ab8d30770a8fe4b395287c6a49ef68e0df2584a69946
|
7
|
+
data.tar.gz: ad56ea002acc7c2e03864779ffae8b4410b50f66d151757a64e18fc1573f7ee80697b21858ec132f30afd6273f1c0c2dd9ea6e7c308b7e3c320744aa43b44714
|
data/lib/phenix.rb
CHANGED
@@ -3,6 +3,13 @@ require 'phenix/version'
|
|
3
3
|
require 'erb'
|
4
4
|
|
5
5
|
module Phenix
|
6
|
+
CONFIG_TO_MYSQL_MAPPING = {
|
7
|
+
'username' => 'user',
|
8
|
+
'password' => 'password',
|
9
|
+
'port' => 'port',
|
10
|
+
'host' => 'host'
|
11
|
+
}.freeze
|
12
|
+
|
6
13
|
class << self
|
7
14
|
attr_accessor :database_config_path, :schema_path, :skip_database
|
8
15
|
attr_accessor :current_configuration
|
@@ -36,15 +43,18 @@ module Phenix
|
|
36
43
|
|
37
44
|
def create_databases(with_schema)
|
38
45
|
for_each_database do |name, conf|
|
39
|
-
run_mysql_command(conf, "CREATE DATABASE #{conf['database']}")
|
46
|
+
run_mysql_command(conf, "CREATE DATABASE IF NOT EXISTS #{conf['database']}")
|
40
47
|
ActiveRecord::Base.establish_connection(name.to_sym)
|
41
48
|
populate_database if with_schema
|
42
49
|
end
|
43
50
|
end
|
44
51
|
|
45
52
|
def populate_database
|
53
|
+
old = ActiveRecord::Migration.verbose
|
46
54
|
ActiveRecord::Migration.verbose = false
|
47
55
|
load(Phenix.schema_path)
|
56
|
+
ensure
|
57
|
+
ActiveRecord::Migration.verbose = old
|
48
58
|
end
|
49
59
|
|
50
60
|
def drop_databases
|
@@ -61,18 +71,21 @@ module Phenix
|
|
61
71
|
end
|
62
72
|
end
|
63
73
|
|
64
|
-
def run_mysql_command(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
"
|
69
|
-
|
70
|
-
commands << "--host=#{conf['host']}" if conf['host'].present?
|
71
|
-
commands << "--port=#{conf['port']}" if conf['port'].present?
|
72
|
-
commands << " --password=#{conf['password']} 2> /dev/null" if conf['password'].present?
|
73
|
-
commands.join(' ')
|
74
|
+
def run_mysql_command(config, execute)
|
75
|
+
command = ['mysql']
|
76
|
+
CONFIG_TO_MYSQL_MAPPING.each do |c, m|
|
77
|
+
if v = config[c].presence
|
78
|
+
command << "--#{m}" << v.to_s
|
79
|
+
end
|
74
80
|
end
|
75
|
-
|
81
|
+
command << "--execute"
|
82
|
+
command << execute
|
83
|
+
|
84
|
+
pio = IO.popen(command, err: '/dev/null')
|
85
|
+
result = pio.read
|
86
|
+
pio.close
|
87
|
+
raise "Failed to execute #{execute}" unless $?.success?
|
88
|
+
result
|
76
89
|
end
|
77
90
|
|
78
91
|
extend self
|
data/lib/phenix/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phenix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Schambacher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,6 +114,20 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: single_cov
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
117
131
|
description:
|
118
132
|
email:
|
119
133
|
- pschambacher@zendesk.com
|
@@ -142,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
156
|
version: '0'
|
143
157
|
requirements: []
|
144
158
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.5.1
|
146
160
|
signing_key:
|
147
161
|
specification_version: 4
|
148
162
|
summary: Read a dynamic database.yml file and allow you to drop/create the database
|