wordmove 1.0.19 → 1.1.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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/lib/wordmove/deployer/base.rb +2 -2
- data/lib/wordmove/generators/Movefile +5 -5
- data/lib/wordmove/generators/movefile.rb +3 -0
- data/lib/wordmove/generators/movefile_adapter.rb +86 -0
- data/lib/wordmove/{sql_mover.rb → sql_adapter.rb} +2 -4
- data/lib/wordmove/version.rb +1 -1
- data/lib/wordmove/wordpress_directory.rb +6 -0
- data/spec/features/movefile_spec.rb +59 -0
- data/spec/fixtures/wp-config.php +90 -0
- data/spec/spec_helper.rb +12 -1
- data/spec/{sql_mover_spec.rb → sql_adapter_spec.rb} +38 -38
- metadata +10 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 106a67fd129100bb5aebc13a4192a80a0d44b03f
|
|
4
|
+
data.tar.gz: e6bb9c88173c3ba982915ceb504483b91067705c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d3c763c22230e1893fd2fac63593e4c8c2872df62af6d85c2a230e85173d763d712d76e92450cb2d543577d5fbbf314f0ad3b873445fedf03109a0b2441059ab
|
|
7
|
+
data.tar.gz: 016a86b636cde8b3b293f50b2b316530bfdbd0b1626e0992e721611bd200f1c873610dcfb9b7bd7f204dc4e3b814480d2ce5bc6c5473f6d3b4c1497d9cf2161c
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -2,7 +2,7 @@ require 'active_support/core_ext'
|
|
|
2
2
|
require 'wordmove/core_ext'
|
|
3
3
|
require 'wordmove/logger'
|
|
4
4
|
require 'wordmove/wordpress_directory'
|
|
5
|
-
require 'wordmove/
|
|
5
|
+
require 'wordmove/sql_adapter'
|
|
6
6
|
require 'escape'
|
|
7
7
|
|
|
8
8
|
module Wordmove
|
|
@@ -177,7 +177,7 @@ module Wordmove
|
|
|
177
177
|
unless options[:no_adapt]
|
|
178
178
|
logger.task_step true, "adapt dump"
|
|
179
179
|
unless simulate?
|
|
180
|
-
|
|
180
|
+
SqlAdapter.new(save_to_path, local, remote).adapt!
|
|
181
181
|
end
|
|
182
182
|
end
|
|
183
183
|
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
local:
|
|
2
2
|
vhost: "http://vhost.local"
|
|
3
|
-
wordpress_path: "
|
|
3
|
+
wordpress_path: "<%= wordpress_path %>" # use an absolute path here
|
|
4
4
|
|
|
5
5
|
database:
|
|
6
|
-
name: "
|
|
7
|
-
user: "user"
|
|
8
|
-
password: "password"
|
|
9
|
-
host: "
|
|
6
|
+
name: "<%= database.name %>"
|
|
7
|
+
user: "<%= database.user %>"
|
|
8
|
+
password: "<%= database.password %>"
|
|
9
|
+
host: "<%= database.host %>"
|
|
10
10
|
|
|
11
11
|
staging:
|
|
12
12
|
vhost: "http://remote.com"
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
require 'thor/group'
|
|
2
|
+
require 'wordmove/generators/movefile_adapter'
|
|
2
3
|
|
|
3
4
|
module Wordmove
|
|
4
5
|
module Generators
|
|
5
6
|
class Movefile < Thor::Group
|
|
6
7
|
include Thor::Actions
|
|
8
|
+
include MovefileAdapter
|
|
7
9
|
|
|
8
10
|
def self.source_root
|
|
9
11
|
File.dirname(__FILE__)
|
|
@@ -16,3 +18,4 @@ module Wordmove
|
|
|
16
18
|
end
|
|
17
19
|
end
|
|
18
20
|
end
|
|
21
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require 'ostruct'
|
|
2
|
+
require 'wordmove/wordpress_directory'
|
|
3
|
+
|
|
4
|
+
module Wordmove
|
|
5
|
+
module Generators
|
|
6
|
+
module MovefileAdapter
|
|
7
|
+
def wordpress_path
|
|
8
|
+
File.expand_path(Dir.pwd)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def database
|
|
12
|
+
DBConfigReader.config
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class DBConfigReader
|
|
17
|
+
def self.config
|
|
18
|
+
new.config
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def config
|
|
22
|
+
OpenStruct.new(database_config)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def database_config
|
|
26
|
+
if wp_config_exists?
|
|
27
|
+
WordpressDBConfig.config
|
|
28
|
+
else
|
|
29
|
+
DefaultDBConfig.config
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def wp_config_exists?
|
|
34
|
+
File.exists?(WordpressDirectory.default_path_for(:wp_config))
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class DefaultDBConfig
|
|
39
|
+
def self.config
|
|
40
|
+
{
|
|
41
|
+
name: "database_name",
|
|
42
|
+
user: "user",
|
|
43
|
+
password: "password",
|
|
44
|
+
host: "127.0.0.1"
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
class WordpressDBConfig
|
|
50
|
+
def self.config
|
|
51
|
+
new.config
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def wp_config
|
|
55
|
+
@wp_config ||= File.open(WordpressDirectory.default_path_for(:wp_config)).read
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def wp_definitions
|
|
59
|
+
{
|
|
60
|
+
name: 'DB_NAME',
|
|
61
|
+
user: 'DB_USER',
|
|
62
|
+
password: 'DB_PASSWORD',
|
|
63
|
+
host: 'DB_HOST'
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def wp_definition_regex(definition)
|
|
68
|
+
/['"]#{definition}['"],\s*["'](?<value>.*)['"]/
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def defaults
|
|
72
|
+
DefaultDBConfig.config.clone
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def config
|
|
76
|
+
wp_definitions.each_with_object(defaults) do |(key, definition), result|
|
|
77
|
+
wp_config.match(wp_definition_regex(definition)) do |match|
|
|
78
|
+
result[key] = match[:value]
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module Wordmove
|
|
2
|
-
|
|
3
|
-
class SqlMover
|
|
4
|
-
|
|
2
|
+
class SqlAdapter
|
|
5
3
|
attr_accessor :sql_content
|
|
6
4
|
attr_reader :sql_path, :source_config, :dest_config
|
|
7
5
|
|
|
@@ -15,7 +13,7 @@ module Wordmove
|
|
|
15
13
|
@sql_content ||= File.open(sql_path).read
|
|
16
14
|
end
|
|
17
15
|
|
|
18
|
-
def
|
|
16
|
+
def adapt!
|
|
19
17
|
replace_vhost!
|
|
20
18
|
replace_wordpress_path!
|
|
21
19
|
write_sql!
|
data/lib/wordmove/version.rb
CHANGED
|
@@ -2,6 +2,7 @@ class WordpressDirectory < Struct.new(:type, :options)
|
|
|
2
2
|
|
|
3
3
|
module PATH
|
|
4
4
|
WP_CONTENT = :wp_content
|
|
5
|
+
WP_CONFIG = :wp_config
|
|
5
6
|
PLUGINS = :plugins
|
|
6
7
|
THEMES = :themes
|
|
7
8
|
UPLOADS = :uploads
|
|
@@ -10,12 +11,17 @@ class WordpressDirectory < Struct.new(:type, :options)
|
|
|
10
11
|
|
|
11
12
|
DEFAULT_PATHS = {
|
|
12
13
|
PATH::WP_CONTENT => 'wp-content',
|
|
14
|
+
PATH::WP_CONFIG => 'wp-config.php',
|
|
13
15
|
PATH::PLUGINS => 'wp-content/plugins',
|
|
14
16
|
PATH::THEMES => 'wp-content/themes',
|
|
15
17
|
PATH::UPLOADS => 'wp-content/uploads',
|
|
16
18
|
PATH::LANGUAGES => 'wp-content/languages'
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
def self.default_path_for(sym)
|
|
22
|
+
DEFAULT_PATHS[sym]
|
|
23
|
+
end
|
|
24
|
+
|
|
19
25
|
def path(*args)
|
|
20
26
|
File.join(options[:wordpress_path], relative_path(*args))
|
|
21
27
|
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'wordmove/generators/movefile'
|
|
3
|
+
|
|
4
|
+
describe Wordmove::Generators::Movefile do
|
|
5
|
+
|
|
6
|
+
let(:movefile) { 'Movefile' }
|
|
7
|
+
let(:tmpdir) { "/tmp/wordmove" }
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
@pwd = Dir.pwd
|
|
11
|
+
FileUtils.mkdir(tmpdir)
|
|
12
|
+
Dir.chdir(tmpdir)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
after do
|
|
16
|
+
Dir.chdir(@pwd)
|
|
17
|
+
FileUtils.rm_rf(tmpdir)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
context "::start" do
|
|
21
|
+
before do
|
|
22
|
+
capture(:stdout) { Wordmove::Generators::Movefile.start }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'creates a Movefile' do
|
|
26
|
+
expect(File.exists?(movefile)).to be_true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'fills local wordpress_path using shell path' do
|
|
30
|
+
yaml = YAML::load(File.open(movefile))
|
|
31
|
+
expect(yaml['local']['wordpress_path']).to eq(Dir.pwd)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'fills database configuration defaults' do
|
|
35
|
+
yaml = YAML::load(File.open(movefile))
|
|
36
|
+
expect(yaml['local']['database']['name']).to eq('database_name')
|
|
37
|
+
expect(yaml['local']['database']['user']).to eq('user')
|
|
38
|
+
expect(yaml['local']['database']['password']).to eq('password')
|
|
39
|
+
expect(yaml['local']['database']['host']).to eq('127.0.0.1')
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
context "database configuration" do
|
|
44
|
+
let(:wp_config) { File.join(File.dirname(__FILE__), "../fixtures/wp-config.php") }
|
|
45
|
+
|
|
46
|
+
before do
|
|
47
|
+
FileUtils.cp(wp_config, ".")
|
|
48
|
+
capture(:stdout) { Wordmove::Generators::Movefile.start }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'fills database configuration from wp-config' do
|
|
52
|
+
yaml = YAML::load(File.open(movefile))
|
|
53
|
+
expect(yaml['local']['database']['name']).to eq('wordmove_db')
|
|
54
|
+
expect(yaml['local']['database']['user']).to eq('wordmove_user')
|
|
55
|
+
expect(yaml['local']['database']['password']).to eq('wordmove_password')
|
|
56
|
+
expect(yaml['local']['database']['host']).to eq('wordmove_host')
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* The base configurations of the WordPress.
|
|
4
|
+
*
|
|
5
|
+
* This file has the following configurations: MySQL settings, Table Prefix,
|
|
6
|
+
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
|
|
7
|
+
* by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
|
|
8
|
+
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
|
|
9
|
+
*
|
|
10
|
+
* This file is used by the wp-config.php creation script during the
|
|
11
|
+
* installation. You don't have to use the web site, you can just copy this file
|
|
12
|
+
* to "wp-config.php" and fill in the values.
|
|
13
|
+
*
|
|
14
|
+
* @package WordPress
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// ** MySQL settings - You can get this info from your web host ** //
|
|
18
|
+
/** The name of the database for WordPress */
|
|
19
|
+
define('DB_NAME', 'wordmove_db');
|
|
20
|
+
|
|
21
|
+
/** MySQL database username */
|
|
22
|
+
define('DB_USER', 'wordmove_user');
|
|
23
|
+
|
|
24
|
+
/** MySQL database password */
|
|
25
|
+
define('DB_PASSWORD', 'wordmove_password');
|
|
26
|
+
|
|
27
|
+
/** MySQL hostname */
|
|
28
|
+
define('DB_HOST', 'wordmove_host');
|
|
29
|
+
|
|
30
|
+
/** Database Charset to use in creating database tables. */
|
|
31
|
+
define('DB_CHARSET', 'utf8');
|
|
32
|
+
|
|
33
|
+
/** The Database Collate type. Don't change this if in doubt. */
|
|
34
|
+
define('DB_COLLATE', '');
|
|
35
|
+
|
|
36
|
+
/**#@+
|
|
37
|
+
* Authentication Unique Keys and Salts.
|
|
38
|
+
*
|
|
39
|
+
* Change these to different unique phrases!
|
|
40
|
+
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
|
|
41
|
+
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
|
|
42
|
+
*
|
|
43
|
+
* @since 2.6.0
|
|
44
|
+
*/
|
|
45
|
+
define('AUTH_KEY', 'put your unique phrase here');
|
|
46
|
+
define('SECURE_AUTH_KEY', 'put your unique phrase here');
|
|
47
|
+
define('LOGGED_IN_KEY', 'put your unique phrase here');
|
|
48
|
+
define('NONCE_KEY', 'put your unique phrase here');
|
|
49
|
+
define('AUTH_SALT', 'put your unique phrase here');
|
|
50
|
+
define('SECURE_AUTH_SALT', 'put your unique phrase here');
|
|
51
|
+
define('LOGGED_IN_SALT', 'put your unique phrase here');
|
|
52
|
+
define('NONCE_SALT', 'put your unique phrase here');
|
|
53
|
+
|
|
54
|
+
/**#@-*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* WordPress Database Table prefix.
|
|
58
|
+
*
|
|
59
|
+
* You can have multiple installations in one database if you give each a unique
|
|
60
|
+
* prefix. Only numbers, letters, and underscores please!
|
|
61
|
+
*/
|
|
62
|
+
$table_prefix = 'wp_';
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* WordPress Localized Language, defaults to English.
|
|
66
|
+
*
|
|
67
|
+
* Change this to localize WordPress. A corresponding MO file for the chosen
|
|
68
|
+
* language must be installed to wp-content/languages. For example, install
|
|
69
|
+
* de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
|
|
70
|
+
* language support.
|
|
71
|
+
*/
|
|
72
|
+
define('WPLANG', '');
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* For developers: WordPress debugging mode.
|
|
76
|
+
*
|
|
77
|
+
* Change this to true to enable the display of notices during development.
|
|
78
|
+
* It is strongly recommended that plugin and theme developers use WP_DEBUG
|
|
79
|
+
* in their development environments.
|
|
80
|
+
*/
|
|
81
|
+
define('WP_DEBUG', false);
|
|
82
|
+
|
|
83
|
+
/* That's all, stop editing! Happy blogging. */
|
|
84
|
+
|
|
85
|
+
/** Absolute path to the WordPress directory. */
|
|
86
|
+
if ( !defined('ABSPATH') )
|
|
87
|
+
define('ABSPATH', dirname(__FILE__) . '/');
|
|
88
|
+
|
|
89
|
+
/** Sets up WordPress vars and included files. */
|
|
90
|
+
require_once(ABSPATH . 'wp-settings.php');
|
data/spec/spec_helper.rb
CHANGED
|
@@ -7,5 +7,16 @@ require 'active_support/core_ext'
|
|
|
7
7
|
require 'thor'
|
|
8
8
|
|
|
9
9
|
RSpec.configure do |config|
|
|
10
|
-
|
|
10
|
+
def capture(stream)
|
|
11
|
+
begin
|
|
12
|
+
stream = stream.to_s
|
|
13
|
+
eval "$#{stream} = StringIO.new"
|
|
14
|
+
yield
|
|
15
|
+
result = eval("$#{stream}").string
|
|
16
|
+
ensure
|
|
17
|
+
eval("$#{stream} = #{stream.upcase}")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
result
|
|
21
|
+
end
|
|
11
22
|
end
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
require 'wordmove/
|
|
1
|
+
require 'wordmove/sql_adapter'
|
|
2
2
|
require 'tempfile'
|
|
3
3
|
|
|
4
|
-
describe Wordmove::
|
|
4
|
+
describe Wordmove::SqlAdapter do
|
|
5
5
|
|
|
6
6
|
let(:sql_path) { double }
|
|
7
7
|
let(:source_config) { double }
|
|
8
8
|
let(:dest_config) { double }
|
|
9
|
-
let(:
|
|
10
|
-
Wordmove::
|
|
9
|
+
let(:adapter) {
|
|
10
|
+
Wordmove::SqlAdapter.new(
|
|
11
11
|
sql_path,
|
|
12
12
|
source_config,
|
|
13
13
|
dest_config
|
|
@@ -16,9 +16,9 @@ describe Wordmove::SqlMover do
|
|
|
16
16
|
|
|
17
17
|
context ".initialize" do
|
|
18
18
|
it "should assign variables correctly on initialization" do
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
adapter.sql_path.should == sql_path
|
|
20
|
+
adapter.source_config.should == source_config
|
|
21
|
+
adapter.dest_config.should == dest_config
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -29,16 +29,16 @@ describe Wordmove::SqlMover do
|
|
|
29
29
|
let(:sql_path) { sql.path }
|
|
30
30
|
|
|
31
31
|
it "should read the sql file content" do
|
|
32
|
-
|
|
32
|
+
adapter.sql_content.should == 'DUMP'
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
context ".
|
|
36
|
+
context ".adapt!" do
|
|
37
37
|
it "should replace host, path and write to sql" do
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
adapter.should_receive(:replace_vhost!).and_return(true)
|
|
39
|
+
adapter.should_receive(:replace_wordpress_path!).and_return(true)
|
|
40
|
+
adapter.should_receive(:write_sql!).and_return(true)
|
|
41
|
+
adapter.adapt!
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
44
|
|
|
@@ -48,8 +48,8 @@ describe Wordmove::SqlMover do
|
|
|
48
48
|
let(:dest_config) do { :vhost => "FUNK" } end
|
|
49
49
|
|
|
50
50
|
it "should replace source vhost with dest vhost" do
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
adapter.should_receive(:replace_field!).with("DUMP", "FUNK").and_return(true)
|
|
52
|
+
adapter.replace_vhost!
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -58,16 +58,16 @@ describe Wordmove::SqlMover do
|
|
|
58
58
|
let(:dest_config) do { :wordpress_path => "FUNK" } end
|
|
59
59
|
|
|
60
60
|
it "should replace source vhost with dest wordpress paths" do
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
adapter.should_receive(:replace_field!).with("DUMP", "FUNK").and_return(true)
|
|
62
|
+
adapter.replace_wordpress_path!
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
context "given an absolute path" do
|
|
66
66
|
let(:source_config) do { :wordpress_absolute_path => "ABSOLUTE_DUMP", :wordpress_path => "DUMP" } end
|
|
67
67
|
|
|
68
68
|
it "should replace the absolute path instead" do
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
adapter.should_receive(:replace_field!).with("ABSOLUTE_DUMP", "FUNK").and_return(true)
|
|
70
|
+
adapter.replace_wordpress_path!
|
|
71
71
|
end
|
|
72
72
|
end
|
|
73
73
|
end
|
|
@@ -75,9 +75,9 @@ describe Wordmove::SqlMover do
|
|
|
75
75
|
|
|
76
76
|
context ".replace_field!" do
|
|
77
77
|
it "should replace source vhost with dest vhost" do
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
adapter.should_receive(:serialized_replace!).ordered.with("DUMP", "FUNK").and_return(true)
|
|
79
|
+
adapter.should_receive(:simple_replace!).ordered.with("DUMP", "FUNK").and_return(true)
|
|
80
|
+
adapter.replace_field!("DUMP", "FUNK")
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
@@ -87,24 +87,24 @@ describe Wordmove::SqlMover do
|
|
|
87
87
|
let(:sql_path) { sql.path }
|
|
88
88
|
|
|
89
89
|
it "should replace source vhost with dest vhost" do
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
adapter.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
|
91
|
+
adapter.sql_content.should == 'a:3:{i:0;s:25:"http://shrubbery.com/spam";i:1;s:6:"foobar";i:2;s:27:"http://shrubbery.com/foobar";}'
|
|
92
92
|
end
|
|
93
93
|
|
|
94
94
|
context "given empty strings" do
|
|
95
95
|
let(:content) { 's:0:"";s:3:"foo";s:0:"";' }
|
|
96
96
|
|
|
97
97
|
it "should leave them untouched" do
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
adapter.serialized_replace!('foo', 'sausage')
|
|
99
|
+
adapter.sql_content.should == 's:0:"";s:7:"sausage";s:0:"";'
|
|
100
100
|
end
|
|
101
101
|
|
|
102
102
|
context "considering escaping" do
|
|
103
103
|
let(:content) { 's:0:\"\";s:3:\"foo\";s:0:\"\";' }
|
|
104
104
|
|
|
105
105
|
it "should leave them untouched" do
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
adapter.serialized_replace!('foo', 'sausage')
|
|
107
|
+
adapter.sql_content.should == 's:0:\"\";s:7:\"sausage\";s:0:\"\";'
|
|
108
108
|
end
|
|
109
109
|
end
|
|
110
110
|
end
|
|
@@ -113,8 +113,8 @@ describe Wordmove::SqlMover do
|
|
|
113
113
|
let(:content) { 's:6:"dump\"\"";' }
|
|
114
114
|
|
|
115
115
|
it "should calculate the correct final length" do
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
adapter.serialized_replace!('dump', 'sausage')
|
|
117
|
+
adapter.sql_content.should == 's:9:"sausage\"\"";'
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
120
|
|
|
@@ -122,8 +122,8 @@ describe Wordmove::SqlMover do
|
|
|
122
122
|
let(:content) { "a:3:{s:20:\\\"http://dump.com/spam\\\";s:6:'foobar';s:22:'http://dump.com/foobar';s:8:'sausages';}" }
|
|
123
123
|
|
|
124
124
|
it "should handle replacing just as well" do
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
adapter.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
|
126
|
+
adapter.sql_content.should == "a:3:{s:25:\\\"http://shrubbery.com/spam\\\";s:6:'foobar';s:27:'http://shrubbery.com/foobar';s:8:'sausages';}"
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
|
|
@@ -131,8 +131,8 @@ describe Wordmove::SqlMover do
|
|
|
131
131
|
let(:content) { 'a:1:{i:0;s:52:"ni http://dump.com/spam ni http://dump.com/foobar ni";}' }
|
|
132
132
|
|
|
133
133
|
it "should replace all occurences" do
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
adapter.serialized_replace!('http://dump.com', 'http://shrubbery.com')
|
|
135
|
+
adapter.sql_content.should == 'a:1:{i:0;s:62:"ni http://shrubbery.com/spam ni http://shrubbery.com/foobar ni";}'
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
138
|
end
|
|
@@ -143,8 +143,8 @@ describe Wordmove::SqlMover do
|
|
|
143
143
|
let(:sql_path) { sql.path }
|
|
144
144
|
|
|
145
145
|
it "should replace source vhost with dest vhost" do
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
adapter.simple_replace!("DUMP", "FUNK")
|
|
147
|
+
adapter.sql_content.should == "THE FUNK!"
|
|
148
148
|
end
|
|
149
149
|
end
|
|
150
150
|
|
|
@@ -155,8 +155,8 @@ describe Wordmove::SqlMover do
|
|
|
155
155
|
let(:the_funk) { "THE FUNK THE FUNK THE FUNK" }
|
|
156
156
|
|
|
157
157
|
it "should write content to file" do
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
adapter.sql_content = the_funk
|
|
159
|
+
adapter.write_sql!
|
|
160
160
|
File.open(sql_path).read == the_funk
|
|
161
161
|
end
|
|
162
162
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wordmove
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stefano Verna
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-09-
|
|
12
|
+
date: 2013-09-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: colored
|
|
@@ -138,16 +138,19 @@ files:
|
|
|
138
138
|
- lib/wordmove/deployer/ssh.rb
|
|
139
139
|
- lib/wordmove/generators/Movefile
|
|
140
140
|
- lib/wordmove/generators/movefile.rb
|
|
141
|
+
- lib/wordmove/generators/movefile_adapter.rb
|
|
141
142
|
- lib/wordmove/logger.rb
|
|
142
|
-
- lib/wordmove/
|
|
143
|
+
- lib/wordmove/sql_adapter.rb
|
|
143
144
|
- lib/wordmove/version.rb
|
|
144
145
|
- lib/wordmove/wordpress_directory.rb
|
|
145
146
|
- pkg/wordmove-0.0.1.gem
|
|
146
147
|
- pkg/wordmove-0.0.2.gem
|
|
147
148
|
- spec/deployer/base_spec.rb
|
|
149
|
+
- spec/features/movefile_spec.rb
|
|
148
150
|
- spec/fixtures/Movefile
|
|
151
|
+
- spec/fixtures/wp-config.php
|
|
149
152
|
- spec/spec_helper.rb
|
|
150
|
-
- spec/
|
|
153
|
+
- spec/sql_adapter_spec.rb
|
|
151
154
|
- wordmove.gemspec
|
|
152
155
|
homepage: https://github.com/welaika/wordmove
|
|
153
156
|
licenses:
|
|
@@ -183,7 +186,9 @@ specification_version: 4
|
|
|
183
186
|
summary: Wordmove, Capistrano for Wordpress
|
|
184
187
|
test_files:
|
|
185
188
|
- spec/deployer/base_spec.rb
|
|
189
|
+
- spec/features/movefile_spec.rb
|
|
186
190
|
- spec/fixtures/Movefile
|
|
191
|
+
- spec/fixtures/wp-config.php
|
|
187
192
|
- spec/spec_helper.rb
|
|
188
|
-
- spec/
|
|
193
|
+
- spec/sql_adapter_spec.rb
|
|
189
194
|
has_rdoc:
|