wordpress-deploy 1.0.0.alpha2 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -1
- data/Guardfile +1 -16
- data/README.md +56 -0
- data/lib/wordpress_deploy.rb +43 -9
- data/lib/wordpress_deploy/cli/helpers.rb +6 -3
- data/lib/wordpress_deploy/cli/utility.rb +56 -33
- data/lib/wordpress_deploy/config.rb +77 -0
- data/lib/wordpress_deploy/database/mysql.rb +281 -20
- data/lib/wordpress_deploy/environment.rb +85 -43
- data/lib/wordpress_deploy/environments.rb +89 -0
- data/lib/wordpress_deploy/logger.rb +3 -3
- data/lib/wordpress_deploy/{transfer_protocols → storage}/ftp.rb +52 -116
- data/lib/wordpress_deploy/storage/local.rb +12 -0
- data/lib/wordpress_deploy/version.rb +1 -1
- data/lib/wordpress_deploy/wordpress/salts.rb +68 -0
- data/spec/data/blue.rb +52 -0
- data/spec/data/development.rb +49 -0
- data/spec/data/green.rb +52 -0
- data/spec/data/production.rb +52 -0
- data/spec/data/red.rb +52 -0
- data/spec/data/wp-config.php +90 -0
- data/spec/spec_helper.rb +16 -5
- data/spec/wordpress_deploy/cli/utility_spec.rb +48 -0
- data/spec/{environment_spec.rb → wordpress_deploy/config_spec.rb} +9 -7
- data/spec/wordpress_deploy/database/mysql_spec.rb +147 -0
- data/spec/wordpress_deploy/environment_spec.rb +96 -0
- data/spec/wordpress_deploy/environments_spec.rb +65 -0
- data/spec/wordpress_deploy/storage/ftp_spec.rb +58 -0
- data/spec/wordpress_deploy/storage/local_spec.rb +0 -0
- data/spec/wordpress_deploy/wordpress/salts_spec.rb +70 -0
- data/{spec/data/wp-config-sample.php → templates/wp-config.erb} +17 -17
- data/wordpress_deploy.gemspec +7 -6
- metadata +64 -30
- data/Gemfile.lock +0 -83
- data/lib/wordpress_deploy/wordpress/configuration.rb +0 -196
- data/spec/data/ftp.yml +0 -4
- data/spec/data/wp-config.yml +0 -128
- data/spec/database/mysql_spec.rb +0 -93
- data/spec/transfer_protocols/ftp_spec.rb +0 -193
- data/spec/wordpress/configuration_spec.rb +0 -202
@@ -1,196 +0,0 @@
|
|
1
|
-
module WordpressDeploy
|
2
|
-
module Wordpress
|
3
|
-
|
4
|
-
class Configuration
|
5
|
-
|
6
|
-
attr_accessor :available_names
|
7
|
-
alias :names :available_names
|
8
|
-
|
9
|
-
def initialize(config_name=nil)
|
10
|
-
@template = File.join(Environment.wp_dir, "wp-config-sample.php")
|
11
|
-
@output = File.join(Environment.wp_dir, "wp-config.php")
|
12
|
-
|
13
|
-
@yaml = YAML.load_file(File.join(Environment.config_dir, "wp-config.yml"))
|
14
|
-
@available_names = @yaml.map { |key, val| key }
|
15
|
-
|
16
|
-
self.name = config_name unless config_name.nil?
|
17
|
-
end
|
18
|
-
|
19
|
-
##
|
20
|
-
# Return the configuration's name.
|
21
|
-
#
|
22
|
-
# Defaults to the first configuration name.
|
23
|
-
def name
|
24
|
-
@name ||= available_names.first
|
25
|
-
@name
|
26
|
-
end
|
27
|
-
|
28
|
-
##
|
29
|
-
# Set the configuration's name.
|
30
|
-
#
|
31
|
-
# Only performs the assignment if the proposed name is
|
32
|
-
# an available name.
|
33
|
-
#
|
34
|
-
# Returns the Configuration's name.
|
35
|
-
def name=(new_name)
|
36
|
-
@name = new_name if name? new_name
|
37
|
-
@name
|
38
|
-
end
|
39
|
-
|
40
|
-
##
|
41
|
-
# Test if the name passed in is an available configuration
|
42
|
-
# name.
|
43
|
-
def name?(name_to_check)
|
44
|
-
available_names.include? name_to_check
|
45
|
-
end
|
46
|
-
|
47
|
-
##
|
48
|
-
# Returns 64 psuedo-random characters as a string
|
49
|
-
# Characters can be a-zA-z or !@#$%^&*()-~+=|/{}:;,.?<>[]
|
50
|
-
def self.salt
|
51
|
-
salt_array.sample(64).join("")
|
52
|
-
end
|
53
|
-
|
54
|
-
##
|
55
|
-
# The file that contains the template for the output file
|
56
|
-
def template
|
57
|
-
@template
|
58
|
-
end
|
59
|
-
|
60
|
-
##
|
61
|
-
# The file that will be output
|
62
|
-
def output
|
63
|
-
@output
|
64
|
-
end
|
65
|
-
|
66
|
-
##
|
67
|
-
# Extract just the port number from the DB_HOST
|
68
|
-
# configuration file. Or return the default port of 3306.
|
69
|
-
def port
|
70
|
-
port = 3306
|
71
|
-
match = /:(?<port>\d+)$/.match(send(:DB_HOST))
|
72
|
-
port = match[:port].to_i unless match.nil?
|
73
|
-
port
|
74
|
-
end
|
75
|
-
|
76
|
-
##
|
77
|
-
# Does DB_HOST contain a port number?
|
78
|
-
def port?
|
79
|
-
!(send(:DB_HOST) =~ /:(?<port>\d+)$/).nil?
|
80
|
-
end
|
81
|
-
|
82
|
-
##
|
83
|
-
# Get just the hostname from DB_HOST. Only different from
|
84
|
-
# DB_HOST if DB_HOST has a socket or a port number in it.
|
85
|
-
def host
|
86
|
-
host = "localhost"
|
87
|
-
match = /(?<host>.*?)(?=:|$)/.match(send(:DB_HOST))
|
88
|
-
host = match[:host].to_s unless match.nil?
|
89
|
-
host
|
90
|
-
end
|
91
|
-
|
92
|
-
##
|
93
|
-
# Extract just the socket part from the DB_HOST
|
94
|
-
# configuration file. Or return an empty string if none.
|
95
|
-
def socket
|
96
|
-
socket = ""
|
97
|
-
match = /:(?<socket>\/.*)$/.match(send(:DB_HOST))
|
98
|
-
socket = match[:socket].to_s unless match.nil?
|
99
|
-
socket
|
100
|
-
end
|
101
|
-
|
102
|
-
##
|
103
|
-
# Does DB_HOST contain a socket path?
|
104
|
-
def socket?
|
105
|
-
!(send(:DB_HOST) =~ /:(?<socket>\/.*)$/).nil?
|
106
|
-
end
|
107
|
-
|
108
|
-
##
|
109
|
-
# Write the file the filesystem
|
110
|
-
def save!
|
111
|
-
# Remove the output file if is already there
|
112
|
-
FileUtils.rm @output if File.exists? @output
|
113
|
-
|
114
|
-
# Open the output file
|
115
|
-
output = File.open(@output, 'w')
|
116
|
-
|
117
|
-
# Start parsing the template file
|
118
|
-
File.open(@template, 'r') do |template|
|
119
|
-
template.each_line do |line|
|
120
|
-
match = /^define\(['"](?<parameter>\w*)['"]/.match(line)
|
121
|
-
unless match.nil?
|
122
|
-
# Get named capture group from Regular Expression
|
123
|
-
param = match[:parameter]
|
124
|
-
|
125
|
-
# Get the value for the specified parameter
|
126
|
-
value = send(param)
|
127
|
-
|
128
|
-
# Set the definition of the line
|
129
|
-
line = define(param, value)
|
130
|
-
end
|
131
|
-
output.puts(line)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
ensure
|
136
|
-
# Close the output file if it is open
|
137
|
-
# even if an exception occurs
|
138
|
-
output.close if output
|
139
|
-
end
|
140
|
-
|
141
|
-
WP_CONFIGURATION_ATTRIBUTES = [:DB_NAME, :DB_USER, :DB_PASSWORD, :DB_HOST,
|
142
|
-
:DB_CHARSET, :DB_COLLATE, :WPLANG,
|
143
|
-
:WP_DEBUG]
|
144
|
-
|
145
|
-
WP_CONFIGURATION_SALTS = [:AUTH_KEY, :SECURE_AUTH_KEY,
|
146
|
-
:LOGGED_IN_KEY, :NONCE_KEY, :AUTH_SALT,
|
147
|
-
:SECURE_AUTH_SALT, :LOGGED_IN_SALT,
|
148
|
-
:NONCE_SALT]
|
149
|
-
|
150
|
-
WP_CONFIGURATION_ALL = WP_CONFIGURATION_ATTRIBUTES +
|
151
|
-
WP_CONFIGURATION_SALTS
|
152
|
-
|
153
|
-
##
|
154
|
-
# Define the behaviours of the default parameters quickly
|
155
|
-
def method_missing(meth, *args, &block)
|
156
|
-
# Convert the method to a symbol
|
157
|
-
method_symbol = meth.to_sym
|
158
|
-
|
159
|
-
if WP_CONFIGURATION_ATTRIBUTES.include? method_symbol
|
160
|
-
config = @yaml[name]
|
161
|
-
return config[meth.to_s] if config.include? meth.to_s
|
162
|
-
""
|
163
|
-
elsif WP_CONFIGURATION_SALTS.include? method_symbol
|
164
|
-
# Return salt if the method is a salting method
|
165
|
-
Configuration.salt
|
166
|
-
else
|
167
|
-
# You *must* call super if you don't handle the method, otherwise
|
168
|
-
# you will mess up Ruby's method lookup.
|
169
|
-
super
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
##
|
174
|
-
# Define respond_to?
|
175
|
-
def respond_to?(method)
|
176
|
-
return true if WP_CONFIGURATION_ALL.include? method.to_sym
|
177
|
-
super
|
178
|
-
end
|
179
|
-
|
180
|
-
private
|
181
|
-
|
182
|
-
##
|
183
|
-
# The Salting array
|
184
|
-
# Provides the array of available characters that can bet used as salt
|
185
|
-
def self.salt_array
|
186
|
-
@salt_array ||= %w{0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ! @ # $ % ^ & * ( ) - ~ + = | / { } : ; , . ? < > [ ]}
|
187
|
-
end
|
188
|
-
|
189
|
-
def define(key, value)
|
190
|
-
"define('#{key}', '#{value}');"
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|
194
|
-
|
195
|
-
end
|
196
|
-
end
|
data/spec/data/ftp.yml
DELETED
data/spec/data/wp-config.yml
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
development:
|
2
|
-
DB_NAME: developer_database_name
|
3
|
-
DB_USER: root
|
4
|
-
DB_PASSWORD: q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$
|
5
|
-
DB_HOST: localhost
|
6
|
-
DB_CHARSET: utf8
|
7
|
-
DB_COLLATE: ''
|
8
|
-
|
9
|
-
# FTP Transfer settings
|
10
|
-
FTP_HOST: localhost
|
11
|
-
FTP_USER: root
|
12
|
-
FTP_PASSWORD: q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$
|
13
|
-
FTP_DIR: /wordpress
|
14
|
-
|
15
|
-
# Authentication Unique Keys and Salts
|
16
|
-
# https://api.wordpress.org/secret-key/1.1/salt/
|
17
|
-
# If no salts are supplied they will be generated automatically
|
18
|
-
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
19
|
-
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
20
|
-
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
21
|
-
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
22
|
-
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
23
|
-
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
24
|
-
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
25
|
-
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
26
|
-
|
27
|
-
production:
|
28
|
-
DB_NAME: production_database_name
|
29
|
-
DB_USER: some_user
|
30
|
-
DB_PASSWORD: trecuwawraJaZe6P@kucraDrachustUq
|
31
|
-
DB_HOST: abbott.biz:6654
|
32
|
-
DB_CHARSET: utf8
|
33
|
-
DB_COLLATE: ''
|
34
|
-
|
35
|
-
# FTP Transfer settings
|
36
|
-
FTP_HOST: ftp.abbott.biz:6654
|
37
|
-
FTP_USER: some_user
|
38
|
-
FTP_PASSWORD: trecuwawraJaZe6P@kucraDrachustUq
|
39
|
-
|
40
|
-
# Authentication Unique Keys and Salts
|
41
|
-
# https://api.wordpress.org/secret-key/1.1/salt/
|
42
|
-
# If no salts are supplied they will be generated automatically
|
43
|
-
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
44
|
-
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
45
|
-
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
46
|
-
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
47
|
-
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
48
|
-
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
49
|
-
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
50
|
-
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
51
|
-
|
52
|
-
red:
|
53
|
-
DB_NAME: red
|
54
|
-
DB_USER: red_user
|
55
|
-
DB_PASSWORD: Bun__huPEMeBreM6tebRAp@eguzuQExe
|
56
|
-
DB_HOST: hanerutherford.biz
|
57
|
-
DB_CHARSET: utf8
|
58
|
-
DB_COLLATE: ''
|
59
|
-
|
60
|
-
# FTP Transfer settings
|
61
|
-
FTP_HOST: ftp.hanerutherford.biz
|
62
|
-
FTP_USER: red_user
|
63
|
-
FTP_PASSWORD: Bun__huPEMeBreM6tebRAp@eguzuQExe
|
64
|
-
FTP_DIR: /html
|
65
|
-
|
66
|
-
# Authentication Unique Keys and Salts
|
67
|
-
# https://api.wordpress.org/secret-key/1.1/salt/
|
68
|
-
# If no salts are supplied they will be generated automatically
|
69
|
-
AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
70
|
-
SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
71
|
-
LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
72
|
-
NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
73
|
-
AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
74
|
-
SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
75
|
-
LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
76
|
-
NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
77
|
-
|
78
|
-
green:
|
79
|
-
DB_NAME: green
|
80
|
-
DB_USER: domenick.dare
|
81
|
-
DB_PASSWORD: Daw&HEWuzaz6sa&epHech_spAKucHaTH
|
82
|
-
DB_HOST: yundt.org
|
83
|
-
DB_CHARSET: utf8
|
84
|
-
DB_COLLATE: ''
|
85
|
-
|
86
|
-
# FTP Transfer settings
|
87
|
-
FTP_HOST: ftp.yundt.org
|
88
|
-
FTP_USER: domenick.dare
|
89
|
-
FTP_PASSWORD: Daw&HEWuzaz6sa&epHech_spAKucHaTH
|
90
|
-
FTP_DIR: /wordpress
|
91
|
-
|
92
|
-
# Authentication Unique Keys and Salts
|
93
|
-
# https://api.wordpress.org/secret-key/1.1/salt/
|
94
|
-
# If no salts are supplied they will be generated automatically
|
95
|
-
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
96
|
-
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
97
|
-
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
98
|
-
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
99
|
-
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
100
|
-
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
101
|
-
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
102
|
-
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
103
|
-
|
104
|
-
blue:
|
105
|
-
DB_NAME: blue
|
106
|
-
DB_USER: harrison
|
107
|
-
DB_PASSWORD: w5@reba?9?pepuk7w9a#H86ustaGawE!
|
108
|
-
DB_HOST: torphagenes.com:/tmp/mysql5.sock
|
109
|
-
DB_CHARSET: utf8
|
110
|
-
DB_COLLATE: ''
|
111
|
-
|
112
|
-
# FTP Transfer settings
|
113
|
-
FTP_HOST: ftp.torphagenes.com
|
114
|
-
FTP_USER: harrison
|
115
|
-
FTP_PASSWORD: w5@reba?9?pepuk7w9a#H86ustaGawE!
|
116
|
-
FTP_DIR: /wordpress
|
117
|
-
|
118
|
-
# Authentication Unique Keys and Salts
|
119
|
-
# https://api.wordpress.org/secret-key/1.1/salt/
|
120
|
-
# If no salts are supplied they will be generated automatically
|
121
|
-
#AUTH_KEY: '*oH{(q=`tIzdNJKUk$XfHNNjKd$W=f$S`CtD.,;x0R}$/A,}]!+q0>>QfB#.Bsw]'
|
122
|
-
#SECURE_AUTH_KEY: '{yg|7Q*j-?$%`b|Z!+5U,pvM,eA0+$/ruprp.mO[;|fExU:n0,-!at0+3UY@;h`X'
|
123
|
-
#LOGGED_IN_KEY: 'k]N 9I<-rZq#k Xg)IPhv$E*ktbD7Z_AtI){U;(P;0r#LJlYncEr%8v9tG`>BHU+'
|
124
|
-
#NONCE_KEY: ' /w9->::-YB Xa#lf%TPH+cIf?]Ru4OfKGF2h8PHsa)2,n-~kRJ<[slUg<GZ Asx'
|
125
|
-
#AUTH_SALT: 'VYwGGP,#|9P[5RCUTdv2c8)`^{dotU0fWrU`JE9qq^n=F4//e)fCs<HF6sd>~yjW'
|
126
|
-
#SECURE_AUTH_SALT: 'ok}@vSs=n6%_%UCO|&[?Jc;,-,.#Q3}zR4ej%IoAL7RavTN/Xe,UrQ4)p}onRie0'
|
127
|
-
#LOGGED_IN_SALT: 'Z!,C*:Q_I9A`[pJm-b0Z/(Gm2qvK8>0~| T&)lM+sxG.OdEmgHbAGF&(^>2.rDGW'
|
128
|
-
#NONCE_SALT: 'ay)${bFV=F1KH[`NZ+W+Zk?Hc:@}jN}Ec)+Zn[F1fyP,mwi|@tk/(1hdp[G2F%os'
|
data/spec/database/mysql_spec.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
include WordpressDeploy::Database
|
4
|
-
include WordpressDeploy::Wordpress
|
5
|
-
|
6
|
-
describe MySql do
|
7
|
-
|
8
|
-
let(:mysql) { "/path/to/mysql" }
|
9
|
-
let(:mysqldump) { "/path/to/mysqldump" }
|
10
|
-
|
11
|
-
it { should respond_to :run }
|
12
|
-
it { should respond_to :utility }
|
13
|
-
it { should respond_to :command_name }
|
14
|
-
it { should respond_to :mysqldump }
|
15
|
-
it { should respond_to :configuration }
|
16
|
-
it { should respond_to :configuration= }
|
17
|
-
|
18
|
-
shared_examples "command based on configuration" do
|
19
|
-
before(:each) do
|
20
|
-
subject.configuration = WordpressDeploy::Wordpress::Configuration.new name
|
21
|
-
subject.stub(:utility).with("mysqldump").and_return(mysqldump)
|
22
|
-
end
|
23
|
-
its(:arguments) { should eq expected_args }
|
24
|
-
its(:mysqldump) { should eq "#{mysqldump} #{expected_args}" }
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when configuration is 'development'" do
|
28
|
-
it_should_behave_like "command based on configuration" do
|
29
|
-
let(:name) { "development" }
|
30
|
-
let(:expected_args) { "-P \"3306\" -h \"localhost\" -u \"root\" -pq9&hu6Re_*dReWr_GAba_2wr89#2Ra8$ -B \"developer_database_name\"" }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when configuration is 'production'" do
|
35
|
-
it_should_behave_like "command based on configuration" do
|
36
|
-
let(:name) { "production" }
|
37
|
-
let(:expected_args) { "-P \"6654\" -h \"abbott.biz\" -u \"some_user\" -ptrecuwawraJaZe6P@kucraDrachustUq -B \"production_database_name\"" }
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
context "when configuration is 'red'" do
|
42
|
-
it_should_behave_like "command based on configuration" do
|
43
|
-
let(:name) { "red" }
|
44
|
-
let(:expected_args) { "-P \"3306\" -h \"hanerutherford.biz\" -u \"red_user\" -pBun__huPEMeBreM6tebRAp@eguzuQExe -B \"red\"" }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when configuration is 'green'" do
|
49
|
-
it_should_behave_like "command based on configuration" do
|
50
|
-
let(:name) { "green" }
|
51
|
-
let(:expected_args) { "-P \"3306\" -h \"yundt.org\" -u \"domenick.dare\" -pDaw&HEWuzaz6sa&epHech_spAKucHaTH -B \"green\"" }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
context "when configuration is 'blue'" do
|
56
|
-
it_should_behave_like "command based on configuration" do
|
57
|
-
let(:name) { "blue" }
|
58
|
-
let(:expected_args) { "-P \"3306\" -h \"torphagenes.com\" -u \"harrison\" -pw5@reba?9?pepuk7w9a#H86ustaGawE! -B \"blue\"" }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
context "find commands" do
|
63
|
-
it "should raise Errors::Cli::UtilityNotFoundError if no command given" do
|
64
|
-
expect{subject.utility ""}.to raise_error(WordpressDeploy::Errors::Cli::UtilityNotFoundError)
|
65
|
-
end
|
66
|
-
it "should raise Errors::Cli::UtilityNotFoundError if command not found" do
|
67
|
-
expect{subject.utility "missing_system_command"}.to raise_error(WordpressDeploy::Errors::Cli::UtilityNotFoundError)
|
68
|
-
end
|
69
|
-
it "mysql" do
|
70
|
-
stdin = Object.new
|
71
|
-
stdin.stub(:close)
|
72
|
-
|
73
|
-
stdout = Object.new.stub(:read).and_return("")
|
74
|
-
stdout.stub(:read).and_return(mysql)
|
75
|
-
|
76
|
-
stderr = Object.new.stub(:read).and_return("")
|
77
|
-
stderr.stub(:read).and_return("")
|
78
|
-
|
79
|
-
wait_thr = Object.new
|
80
|
-
wait_thr.stub(:value).and_return($?)
|
81
|
-
|
82
|
-
Open3.should_receive(:popen3).exactly(1).times.and_yield(stdin, stdout, stderr, wait_thr)
|
83
|
-
|
84
|
-
subject.utility("mysql").should eq mysql
|
85
|
-
WordpressDeploy::Database::MySql::UTILITY["mysql"].should eq mysql
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should parse out the command name" do
|
90
|
-
subject.command_name("#{mysqldump} -P \"3306\" -h \"NOT_localhost\" -u \"root\" -ptemp -B \"developer_database_name\"").should eq "mysqldump"
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
@@ -1,193 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
include WordpressDeploy
|
4
|
-
|
5
|
-
describe WordpressDeploy::TransferProtocols::Ftp do
|
6
|
-
before(:each) do
|
7
|
-
# None of the methods that follow are testing
|
8
|
-
# the Net::FTP object actions; therefore they
|
9
|
-
# can be stubbed out
|
10
|
-
@ftp = double("ftp")
|
11
|
-
[:connect, :login, :passive=].each do |methods|
|
12
|
-
@ftp.stub(methods).with(any_args)
|
13
|
-
end
|
14
|
-
Net::FTP.stub(:new).and_return(@ftp)
|
15
|
-
end
|
16
|
-
|
17
|
-
it { should respond_to :name }
|
18
|
-
it { should respond_to :name= }
|
19
|
-
it { should respond_to :available_names }
|
20
|
-
it { should respond_to :names }
|
21
|
-
it { should respond_to :port }
|
22
|
-
it { should respond_to :port? }
|
23
|
-
it { should respond_to :host }
|
24
|
-
it { should respond_to :configuration }
|
25
|
-
it { should respond_to :configuration= }
|
26
|
-
|
27
|
-
it { should respond_to :FTP_USER }
|
28
|
-
it { should respond_to :FTP_PASSWORD }
|
29
|
-
it { should respond_to :FTP_HOST }
|
30
|
-
it { should respond_to :FTP_DIR }
|
31
|
-
|
32
|
-
its(:names) { should have(5).strings }
|
33
|
-
its(:names) { should include "development" }
|
34
|
-
its(:names) { should include "production" }
|
35
|
-
its(:names) { should include "red" }
|
36
|
-
its(:names) { should include "green" }
|
37
|
-
its(:names) { should include "blue" }
|
38
|
-
its(:available_names) { should have(5).strings }
|
39
|
-
its(:available_names) { should include "development" }
|
40
|
-
its(:available_names) { should include "production" }
|
41
|
-
its(:available_names) { should include "red" }
|
42
|
-
its(:available_names) { should include "green" }
|
43
|
-
its(:available_names) { should include "blue" }
|
44
|
-
|
45
|
-
it "should allow creation of new configuration by name" do
|
46
|
-
ftp = WordpressDeploy::TransferProtocols::Ftp.new "red"
|
47
|
-
ftp.name.should eq "red"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should only allow configuration names found in the yaml file" do
|
51
|
-
["production", "development", "red", "green", "blue"].each do |name|
|
52
|
-
subject.name = name
|
53
|
-
subject.name.should eq name
|
54
|
-
end
|
55
|
-
[:production, nil].each do |name|
|
56
|
-
subject.name = name
|
57
|
-
subject.name.should_not eq name
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
shared_examples "ftp named configuration" do
|
62
|
-
before(:each) { subject.name = name }
|
63
|
-
its(:name) { should eq name }
|
64
|
-
its(:FTP_USER) { should eq ftp_user }
|
65
|
-
its(:FTP_PASSWORD) { should eq ftp_password }
|
66
|
-
its(:FTP_HOST) { should eq ftp_host }
|
67
|
-
its(:FTP_DIR) { should eq ftp_dir_raw }
|
68
|
-
its(:local_path) { should eq Environment.wp_dir }
|
69
|
-
its(:remote_path) { should eq ftp_dir }
|
70
|
-
its(:username) { should eq ftp_user }
|
71
|
-
its(:password) { should eq ftp_password }
|
72
|
-
its(:host) { should eq host }
|
73
|
-
its(:port) { should eq port }
|
74
|
-
its(:port?) { should eq has_port }
|
75
|
-
end
|
76
|
-
|
77
|
-
context "development" do
|
78
|
-
it_should_behave_like "ftp named configuration" do
|
79
|
-
let(:name) { "development" }
|
80
|
-
let(:ftp_user) { "root" }
|
81
|
-
let(:ftp_password) { "q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$" }
|
82
|
-
let(:ftp_host) { "localhost" }
|
83
|
-
let(:ftp_dir_raw) { "/wordpress" }
|
84
|
-
let(:ftp_dir) { "/wordpress" }
|
85
|
-
let(:host) { "localhost" }
|
86
|
-
let(:port) { 21 }
|
87
|
-
let(:has_port) { false }
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
context "production" do
|
92
|
-
it_should_behave_like "ftp named configuration" do
|
93
|
-
let(:name) { "production" }
|
94
|
-
let(:ftp_user) { "some_user" }
|
95
|
-
let(:ftp_password) { "trecuwawraJaZe6P@kucraDrachustUq" }
|
96
|
-
let(:ftp_host) { "ftp.abbott.biz:6654" }
|
97
|
-
let(:ftp_dir_raw) { nil }
|
98
|
-
let(:ftp_dir) { "/" }
|
99
|
-
let(:host) { "ftp.abbott.biz" }
|
100
|
-
let(:port) { 6654 }
|
101
|
-
let(:has_port) { true }
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context "red" do
|
106
|
-
it_should_behave_like "ftp named configuration" do
|
107
|
-
let(:name) { "red" }
|
108
|
-
let(:ftp_user) { "red_user" }
|
109
|
-
let(:ftp_password) { "Bun__huPEMeBreM6tebRAp@eguzuQExe" }
|
110
|
-
let(:ftp_host) { "ftp.hanerutherford.biz" }
|
111
|
-
let(:ftp_dir_raw) { "/html" }
|
112
|
-
let(:ftp_dir) { "/html" }
|
113
|
-
let(:host) { "ftp.hanerutherford.biz" }
|
114
|
-
let(:port) { 21 }
|
115
|
-
let(:has_port) { false }
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context "green" do
|
120
|
-
it_should_behave_like "ftp named configuration" do
|
121
|
-
let(:name) { "green" }
|
122
|
-
let(:ftp_user) { "domenick.dare" }
|
123
|
-
let(:ftp_password) { "Daw&HEWuzaz6sa&epHech_spAKucHaTH" }
|
124
|
-
let(:ftp_host) { "ftp.yundt.org" }
|
125
|
-
let(:ftp_dir_raw) { "/wordpress" }
|
126
|
-
let(:ftp_dir) { "/wordpress" }
|
127
|
-
let(:host) { "ftp.yundt.org" }
|
128
|
-
let(:port) { 21 }
|
129
|
-
let(:has_port) { false }
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context "blue" do
|
134
|
-
it_should_behave_like "ftp named configuration" do
|
135
|
-
let(:name) { "blue" }
|
136
|
-
let(:ftp_user) { "harrison" }
|
137
|
-
let(:ftp_password) { "w5@reba?9?pepuk7w9a#H86ustaGawE!" }
|
138
|
-
let(:ftp_host) { "ftp.torphagenes.com" }
|
139
|
-
let(:ftp_dir_raw) { "/wordpress" }
|
140
|
-
let(:ftp_dir) { "/wordpress" }
|
141
|
-
let(:host) { "ftp.torphagenes.com" }
|
142
|
-
let(:port) { 21 }
|
143
|
-
let(:has_port) { false }
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
it "has methods that allow for interactive overwrite" do
|
148
|
-
expect { subject.transmit }.to raise_error(NotImplementedError)
|
149
|
-
expect { subject.receive }.to raise_error(NotImplementedError)
|
150
|
-
end
|
151
|
-
|
152
|
-
it { should respond_to :transmit! }
|
153
|
-
it { should respond_to :receive! }
|
154
|
-
|
155
|
-
context "FTP connection" do
|
156
|
-
before(:each) do
|
157
|
-
@ftp = double("ftp")
|
158
|
-
@ftp.should_receive(:connect).with("localhost", 21)
|
159
|
-
@ftp.should_receive(:login).with("root", "q9&hu6Re_*dReWr_GAba_2wr89#2Ra8$")
|
160
|
-
@ftp.should_receive(:passive=).with(true)
|
161
|
-
@ftp.stub(:pwd)
|
162
|
-
@ftp.stub(:closed?).and_return(false)
|
163
|
-
@ftp.stub(:close)
|
164
|
-
@ftp.stub(:chdir)
|
165
|
-
@ftp.stub(:putbinaryfile)
|
166
|
-
Net::FTP.stub(:new).and_return(@ftp)
|
167
|
-
WordpressDeploy::TransferProtocols::Ftp.any_instance.stub(:ftp).and_return(@ftp)
|
168
|
-
end
|
169
|
-
|
170
|
-
it "with valid credentials" do
|
171
|
-
ftp = WordpressDeploy::TransferProtocols::Ftp.new("developer")
|
172
|
-
end
|
173
|
-
|
174
|
-
it "close an open connection" do
|
175
|
-
ftp = WordpressDeploy::TransferProtocols::Ftp.new("developer")
|
176
|
-
ftp.close.should be_true
|
177
|
-
#ftp.close.should be_false
|
178
|
-
end
|
179
|
-
|
180
|
-
it "should send files" do
|
181
|
-
files = Dir.glob(File.join(data_dir, "**/*"))
|
182
|
-
|
183
|
-
Dir.should_receive(:glob).with("/Users/ryan/Source/wordpress-deploy/spec/data/**/*").and_return(files)
|
184
|
-
|
185
|
-
ftp = WordpressDeploy::TransferProtocols::Ftp.new("developer")
|
186
|
-
|
187
|
-
ftp.should_receive(:put_file).exactly(files.count).times
|
188
|
-
|
189
|
-
ftp.transmit!
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
end
|