wordmove 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown CHANGED
@@ -51,6 +51,11 @@ local:
51
51
  staging:
52
52
  vhost: "http://remote.com"
53
53
  wordpress_path: "/var/www/your_site"
54
+ # paths: # you can customize wordpress paths
55
+ # wp_content: "wp-content"
56
+ # uploads: "wp-content/uploads"
57
+ # plugins: "wp-content/plugins"
58
+ # languages: "wp-content/languages"
54
59
  database:
55
60
  name: "database_name"
56
61
  user: "user"
data/lib/wordmove/cli.rb CHANGED
@@ -15,6 +15,7 @@ module Wordmove
15
15
  method_option :uploads, :aliases => "-u", :type => :boolean
16
16
  method_option :themes, :aliases => "-t", :type => :boolean
17
17
  method_option :plugins, :aliases => "-p", :type => :boolean
18
+ method_option :languages, :aliases => "-l", :type => :boolean
18
19
  method_option :verbose, :aliases => "-v", :type => :boolean
19
20
  method_option :simulate, :aliases => "-s", :type => :boolean
20
21
  method_option :no_adapt, :type => :boolean
@@ -22,7 +23,7 @@ module Wordmove
22
23
  method_option :config, :aliases => "-c"
23
24
  def pull
24
25
  deployer = Wordmove::Deployer::Base.deployer_for(options)
25
- %w(db uploads themes plugins).map(&:to_sym).each do |task|
26
+ %w(db uploads themes plugins languages).map(&:to_sym).each do |task|
26
27
  if options[task]
27
28
  deployer.send("pull_#{task}")
28
29
  end
@@ -34,6 +35,7 @@ module Wordmove
34
35
  method_option :db, :aliases => "-d", :type => :boolean
35
36
  method_option :themes, :aliases => "-t", :type => :boolean
36
37
  method_option :plugins, :aliases => "-p", :type => :boolean
38
+ method_option :languages, :aliases => "-l", :type => :boolean
37
39
  method_option :verbose, :aliases => "-v", :type => :boolean
38
40
  method_option :simulate, :aliases => "-s", :type => :boolean
39
41
  method_option :no_adapt, :type => :boolean
@@ -41,7 +43,7 @@ module Wordmove
41
43
  method_option :config, :aliases => "-c"
42
44
  def push
43
45
  deployer = Wordmove::Deployer::Base.deployer_for(options)
44
- %w(db uploads themes plugins).map(&:to_sym).each do |task|
46
+ %w(db uploads themes plugins languages).map(&:to_sym).each do |task|
45
47
  if options[task]
46
48
  deployer.send("push_#{task}")
47
49
  end
@@ -1,5 +1,6 @@
1
1
  require 'active_support/core_ext'
2
2
  require 'wordmove/logger'
3
+ require 'wordmove/wordpress_directory'
3
4
  require 'wordmove/sql_mover'
4
5
  require 'escape'
5
6
 
@@ -60,15 +61,19 @@ module Wordmove
60
61
  def remote_get_directory(directory); end
61
62
  def remote_put_directory(directory); end
62
63
 
63
- %w(uploads themes plugins).each do |task|
64
+ %w(uploads themes plugins languages).each do |task|
64
65
  define_method "push_#{task}" do
65
66
  logger.task "Pushing #{task.titleize}"
66
- remote_put_directory(local_wpcontent_path(task), remote_wpcontent_path(task), paths_to_exclude)
67
+ local_path = send("local_#{task}_dir").path
68
+ remote_path = send("remote_#{task}_dir").path
69
+ remote_put_directory(local_path, remote_path, paths_to_exclude)
67
70
  end
68
71
 
69
72
  define_method "pull_#{task}" do
70
73
  logger.task "Pulling #{task.titleize}"
71
- remote_get_directory(remote_wpcontent_path(task), local_wpcontent_path(task), paths_to_exclude)
74
+ local_path = send("local_#{task}_dir").path
75
+ remote_path = send("remote_#{task}_dir").path
76
+ remote_get_directory(remote_path, local_path, paths_to_exclude)
72
77
  end
73
78
  end
74
79
 
@@ -99,16 +104,18 @@ module Wordmove
99
104
  options[:simulate]
100
105
  end
101
106
 
102
- def local_wpcontent_path(*args)
103
- File.join(local_options[:wordpress_path], "wp-content", *args)
104
- end
105
-
106
- def remote_wpcontent_path(*args)
107
- File.join(remote_options[:wordpress_path], "wp-content", *args)
108
- end
109
-
110
- def remote_wpcontent_url(*args)
111
- remote_options[:vhost] + File.join("/wp-content", *args)
107
+ [ WordpressDirectory::PATH::WP_CONTENT,
108
+ WordpressDirectory::PATH::PLUGINS,
109
+ WordpressDirectory::PATH::THEMES,
110
+ WordpressDirectory::PATH::UPLOADS,
111
+ WordpressDirectory::PATH::LANGUAGES
112
+ ].each do |type|
113
+ [ :remote, :local ].each do |location|
114
+ define_method "#{location}_#{type}_dir" do
115
+ options = send("#{location}_options")
116
+ WordpressDirectory.new(type, options)
117
+ end
118
+ end
112
119
  end
113
120
 
114
121
  def adapt_sql(save_to_path, local, remote)
@@ -17,9 +17,9 @@ module Wordmove
17
17
  def push_db
18
18
  super
19
19
 
20
- local_dump_path = local_wpcontent_path("dump.sql")
21
- remote_dump_path = remote_wpcontent_path("dump.sql")
22
- local_backup_path = local_wpcontent_path("remote-backup-#{Time.now.to_i}.sql")
20
+ local_dump_path = local_wp_content_dir.path("dump.sql")
21
+ remote_dump_path = remote_wp_content_dir.path("dump.sql")
22
+ local_backup_path = local_wp_content_dir.path("remote-backup-#{Time.now.to_i}.sql")
23
23
 
24
24
  download_remote_db(local_backup_path)
25
25
  save_local_db(local_dump_path)
@@ -39,8 +39,8 @@ module Wordmove
39
39
 
40
40
  def pull_db
41
41
  super
42
- local_dump_path = local_wpcontent_path("dump.sql")
43
- local_backup_path = local_wpcontent_path("local-backup-#{Time.now.to_i}.sql")
42
+ local_dump_path = local_wp_content_dir.path("dump.sql")
43
+ local_backup_path = local_wp_content_dir.path("local-backup-#{Time.now.to_i}.sql")
44
44
 
45
45
  save_local_db(local_backup_path)
46
46
  download_remote_db(local_dump_path)
@@ -93,7 +93,7 @@ module Wordmove
93
93
  end
94
94
 
95
95
  def download_remote_db(local_dump_path)
96
- remote_dump_script = remote_wpcontent_path("dump.php")
96
+ remote_dump_script = remote_wp_content_dir.path("dump.php")
97
97
  # generate a secure one-time password
98
98
  one_time_password = SecureRandom.hex(40)
99
99
  # generate dump script
@@ -101,15 +101,15 @@ module Wordmove
101
101
  # upload the dump script
102
102
  remote_put(dump_script, remote_dump_script)
103
103
  # download the resulting dump (using the password)
104
- dump_url = "#{remote_wpcontent_url("dump.php")}?shared_key=#{one_time_password}"
104
+ dump_url = "#{remote_wp_content_dir.url("dump.php")}?shared_key=#{one_time_password}"
105
105
  download(dump_url, local_dump_path)
106
106
  # remove it remotely
107
107
  remote_delete(remote_dump_script)
108
108
  end
109
109
 
110
110
  def import_remote_dump
111
- temp_path = local_wpcontent_path("temp.txt")
112
- remote_import_script_path = remote_wpcontent_path("import.php")
111
+ temp_path = local_wp_content_dir.path("temp.txt")
112
+ remote_import_script_path = remote_wp_content_dir.path("import.php")
113
113
  # generate a secure one-time password
114
114
  one_time_password = SecureRandom.hex(40)
115
115
  # generate import script
@@ -117,7 +117,7 @@ module Wordmove
117
117
  # upload import script
118
118
  remote_put(import_script, remote_import_script_path)
119
119
  # run import script
120
- import_url = "#{remote_wpcontent_url("import.php")}?shared_key=#{one_time_password}&start=1&foffset=0&totalqueries=0&fn=dump.sql"
120
+ import_url = "#{remote_wp_content_dir.url("import.php")}?shared_key=#{one_time_password}&start=1&foffset=0&totalqueries=0&fn=dump.sql"
121
121
  download(import_url, temp_path)
122
122
  run "rm #{temp_path}"
123
123
  # remove script remotely
@@ -14,8 +14,8 @@ module Wordmove
14
14
  def push_db
15
15
  super
16
16
 
17
- local_dump_path = local_wpcontent_path("dump.sql")
18
- local_backup_path = local_wpcontent_path("remote-backup-#{Time.now.to_i}.sql")
17
+ local_dump_path = local_wp_content_dir.path("dump.sql")
18
+ local_backup_path = local_wp_content_dir.path("remote-backup-#{Time.now.to_i}.sql")
19
19
  download_remote_db(local_backup_path)
20
20
 
21
21
  save_local_db(local_dump_path)
@@ -27,9 +27,9 @@ module Wordmove
27
27
  def pull_db
28
28
  super
29
29
 
30
- local_dump_path = local_wpcontent_path("dump.sql")
31
- remote_dump_path = remote_wpcontent_path("dump.sql")
32
- local_backup_path = local_wpcontent_path("local-backup-#{Time.now.to_i}.sql")
30
+ local_dump_path = local_wp_content_dir.path("dump.sql")
31
+ remote_dump_path = remote_wp_content_dir.path("dump.sql")
32
+ local_backup_path = local_wp_content_dir.path("local-backup-#{Time.now.to_i}.sql")
33
33
  save_local_db(local_backup_path)
34
34
 
35
35
  download_remote_db(local_dump_path)
@@ -58,7 +58,7 @@ module Wordmove
58
58
  end
59
59
 
60
60
  def download_remote_db(local_dump_path)
61
- remote_dump_path = remote_wpcontent_path("dump.sql")
61
+ remote_dump_path = remote_wp_content_dir.path("dump.sql")
62
62
  # dump remote db into file
63
63
  remote_run mysql_dump_command(remote_options[:database], remote_dump_path)
64
64
  # download remote dump
@@ -67,7 +67,7 @@ module Wordmove
67
67
  end
68
68
 
69
69
  def import_remote_dump(local_dump_path)
70
- remote_dump_path = remote_wpcontent_path("dump.sql")
70
+ remote_dump_path = remote_wp_content_dir.path("dump.sql")
71
71
  remote_put(local_dump_path, remote_dump_path)
72
72
  remote_run mysql_import_command(remote_dump_path, remote_options[:database])
73
73
  remote_delete(remote_dump_path)
@@ -9,6 +9,16 @@ local:
9
9
  staging:
10
10
  vhost: "http://remote.com"
11
11
  wordpress_path: "/var/www/your_site"
12
+ # paths: # you can customize wordpress internal paths
13
+ # wp_content: "wp-content"
14
+ # uploads: "wp-content/uploads"
15
+ # plugins: "wp-content/plugins"
16
+ # languages: "wp-content/languages"
17
+ exclude:
18
+ - ".sass-cache"
19
+ - ".git"
20
+ - "tmp/*"
21
+ - "wp-content/*.sql"
12
22
  database:
13
23
  name: "database_name"
14
24
  user: "user"
@@ -1,3 +1,3 @@
1
1
  module Wordmove
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
@@ -0,0 +1,36 @@
1
+ class WordpressDirectory < Struct.new(:type, :options)
2
+
3
+ module PATH
4
+ WP_CONTENT = :wp_content
5
+ PLUGINS = :plugins
6
+ THEMES = :themes
7
+ UPLOADS = :uploads
8
+ LANGUAGES = :languages
9
+ end
10
+
11
+ DEFAULT_PATHS = {
12
+ PATH::WP_CONTENT => 'wp-content',
13
+ PATH::PLUGINS => 'wp-content/plugins',
14
+ PATH::THEMES => 'wp-content/themes',
15
+ PATH::UPLOADS => 'wp-content/uploads',
16
+ PATH::LANGUAGES => 'wp-content/languages'
17
+ }
18
+
19
+ def path(*args)
20
+ File.join(options[:wordpress_path], relative_path(*args))
21
+ end
22
+
23
+ def url(*args)
24
+ File.join(options[:vhost], relative_path(*args))
25
+ end
26
+
27
+ def relative_path(*args)
28
+ path = if options[:paths] && options[:paths][type]
29
+ options[:paths][type]
30
+ else
31
+ DEFAULT_PATHS[type]
32
+ end
33
+ File.join(path, *args)
34
+ end
35
+
36
+ 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.6
4
+ version: 1.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -171,11 +171,6 @@ files:
171
171
  - README.mdown
172
172
  - Rakefile
173
173
  - bin/wordmove
174
- - features/generator.feature
175
- - features/pull.feature
176
- - features/push.feature
177
- - features/step_definitions/aruba_ext_steps.rb
178
- - features/support/setup.rb
179
174
  - lib/wordmove.rb
180
175
  - lib/wordmove/assets/dump.php.erb
181
176
  - lib/wordmove/assets/import.php.erb
@@ -188,6 +183,7 @@ files:
188
183
  - lib/wordmove/logger.rb
189
184
  - lib/wordmove/sql_mover.rb
190
185
  - lib/wordmove/version.rb
186
+ - lib/wordmove/wordpress_directory.rb
191
187
  - pkg/wordmove-0.0.1.gem
192
188
  - pkg/wordmove-0.0.2.gem
193
189
  - spec/fixtures/Movefile
@@ -221,11 +217,6 @@ signing_key:
221
217
  specification_version: 3
222
218
  summary: Capistrano for Wordpress
223
219
  test_files:
224
- - features/generator.feature
225
- - features/pull.feature
226
- - features/push.feature
227
- - features/step_definitions/aruba_ext_steps.rb
228
- - features/support/setup.rb
229
220
  - spec/fixtures/Movefile
230
221
  - spec/spec_helper.rb
231
222
  - spec/sql_mover_spec.rb
@@ -1,30 +0,0 @@
1
- Feature: Generating Movefile
2
- In order to configure Wordmove
3
- As a WP developer
4
- I want Wordmove to generate me a Wordmove skeleton file
5
-
6
- Scenario: Wordmove creation
7
- When I run "wordmove init"
8
- Then the following files should exist:
9
- | Movefile |
10
- Then the file "Movefile" should contain:
11
- """
12
- local:
13
- vhost: "http://vhost.local"
14
- wordpress_path: "~/dev/sites/your_site"
15
- database:
16
- user: "user"
17
- password: "password"
18
- host: "host"
19
- remote:
20
- vhost: "http://remote.com"
21
- wordpress_path: "/var/www/your_site"
22
- database:
23
- user: "user"
24
- password: "password"
25
- host: "host"
26
- ssh:
27
- user: "user"
28
- password: "password"
29
- host: "host"
30
- """
File without changes
File without changes
@@ -1,3 +0,0 @@
1
- Then /^the file "([^"]*)" should contain:$/ do |file, content|
2
- check_file_content(file, content, true)
3
- end
@@ -1,2 +0,0 @@
1
- require 'aruba/cucumber'
2
-