wordpress-deploy 1.0.0.alpha1 → 1.0.0.alpha2

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.
Files changed (38) hide show
  1. data/.gitignore +26 -1
  2. data/.rspec +1 -0
  3. data/.rvmrc +48 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +2 -5
  6. data/Gemfile.lock +40 -28
  7. data/Guardfile +24 -0
  8. data/README.md +22 -7
  9. data/bin/wp-deploy +1 -4
  10. data/lib/wordpress_deploy.rb +22 -48
  11. data/lib/wordpress_deploy/cli/helpers.rb +27 -14
  12. data/lib/wordpress_deploy/cli/utility.rb +86 -37
  13. data/lib/wordpress_deploy/database/mysql.rb +22 -136
  14. data/lib/wordpress_deploy/environment.rb +68 -0
  15. data/lib/wordpress_deploy/errors.rb +54 -0
  16. data/lib/wordpress_deploy/logger.rb +28 -50
  17. data/lib/wordpress_deploy/transfer_protocols/ftp.rb +305 -0
  18. data/lib/wordpress_deploy/version.rb +1 -1
  19. data/lib/wordpress_deploy/wordpress/configuration.rb +196 -0
  20. data/spec/data/ftp.yml +4 -0
  21. data/spec/data/wp-config-sample.php +90 -0
  22. data/spec/data/wp-config.yml +128 -0
  23. data/spec/database/mysql_spec.rb +93 -0
  24. data/spec/environment_spec.rb +35 -0
  25. data/spec/spec_helper.rb +36 -1
  26. data/spec/transfer_protocols/ftp_spec.rb +193 -0
  27. data/spec/wordpress/configuration_spec.rb +202 -0
  28. data/wordpress_deploy.gemspec +13 -10
  29. metadata +63 -47
  30. data/lib/wordpress_deploy/config.rb +0 -68
  31. data/lib/wordpress_deploy/database/base.rb +0 -53
  32. data/lib/wordpress_deploy/pipeline.rb +0 -110
  33. data/lib/wordpress_deploy/storage/base.rb +0 -99
  34. data/lib/wordpress_deploy/storage/ftp.rb +0 -133
  35. data/lib/wordpress_deploy/storage/local.rb +0 -82
  36. data/lib/wordpress_deploy/storage/scp.rb +0 -99
  37. data/lib/wordpress_deploy/storage/sftp.rb +0 -108
  38. data/spec/config_spec.rb +0 -16
data/.gitignore CHANGED
@@ -1,2 +1,27 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ # Mac files
1
21
  .DS_Store
2
- pkg/*
22
+
23
+ # Spec data made during tests
24
+ spec/data/wp-config.php
25
+ *.log
26
+ config/
27
+ site/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p194@wordpress-deploy"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.14.10 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
35
+
36
+ # If you use bundler, this might be useful to you:
37
+ # if [[ -s Gemfile ]] && {
38
+ # ! builtin command -v bundle >/dev/null ||
39
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
40
+ # }
41
+ # then
42
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
43
+ # gem install bundler
44
+ # fi
45
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
46
+ # then
47
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
48
+ # fi
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile CHANGED
@@ -1,7 +1,4 @@
1
- # encoding: utf-8
1
+ source 'https://rubygems.org'
2
2
 
3
- # RubyGems Source
4
- source 'http://rubygems.org'
5
-
6
- # Include gem dependencies from the gemspec for development purposes
3
+ # Specify your gem's dependencies in daavtest.gemspec
7
4
  gemspec
@@ -1,71 +1,83 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wordpress-deploy (1.0.0)
4
+ wordpress-deploy (1.0.0.alpha2)
5
5
  actionpack (~> 3.2.6)
6
6
  colorize (~> 0.5.8)
7
- open4 (~> 1.3.0)
8
- thor (~> 0.14.6)
7
+ os (~> 0.9.4)
8
+ thor (~> 0.15.4)
9
+ titleize (~> 1.2.1)
9
10
 
10
11
  GEM
11
- remote: http://rubygems.org/
12
+ remote: https://rubygems.org/
12
13
  specs:
13
- actionpack (3.2.6)
14
- activemodel (= 3.2.6)
15
- activesupport (= 3.2.6)
14
+ actionpack (3.2.7)
15
+ activemodel (= 3.2.7)
16
+ activesupport (= 3.2.7)
16
17
  builder (~> 3.0.0)
17
18
  erubis (~> 2.7.0)
18
- journey (~> 1.0.1)
19
+ journey (~> 1.0.4)
19
20
  rack (~> 1.4.0)
20
21
  rack-cache (~> 1.2)
21
22
  rack-test (~> 0.6.1)
22
23
  sprockets (~> 2.1.3)
23
- activemodel (3.2.6)
24
- activesupport (= 3.2.6)
24
+ activemodel (3.2.7)
25
+ activesupport (= 3.2.7)
25
26
  builder (~> 3.0.0)
26
- activesupport (3.2.6)
27
+ activesupport (3.2.7)
27
28
  i18n (~> 0.6)
28
29
  multi_json (~> 1.0)
29
30
  builder (3.0.0)
30
31
  colorize (0.5.8)
31
32
  diff-lcs (1.1.3)
32
33
  erubis (2.7.0)
34
+ ffi (1.1.4)
35
+ guard (1.3.0)
36
+ listen (>= 0.4.2)
37
+ thor (>= 0.14.6)
38
+ guard-rspec (1.2.1)
39
+ guard (>= 1.1)
33
40
  hike (1.2.1)
34
41
  i18n (0.6.0)
35
42
  journey (1.0.4)
36
- metaclass (0.0.1)
37
- mocha (0.11.4)
38
- metaclass (~> 0.0.1)
43
+ listen (0.4.7)
44
+ rb-fchange (~> 0.0.5)
45
+ rb-fsevent (~> 0.9.1)
46
+ rb-inotify (~> 0.8.8)
39
47
  multi_json (1.3.6)
40
- open4 (1.3.0)
48
+ os (0.9.6)
41
49
  rack (1.4.1)
42
50
  rack-cache (1.2)
43
51
  rack (>= 0.4)
44
52
  rack-test (0.6.1)
45
53
  rack (>= 1.0)
46
54
  rake (0.9.2.2)
47
- rspec (2.10.0)
48
- rspec-core (~> 2.10.0)
49
- rspec-expectations (~> 2.10.0)
50
- rspec-mocks (~> 2.10.0)
51
- rspec-core (2.10.1)
52
- rspec-expectations (2.10.0)
55
+ rb-fchange (0.0.5)
56
+ ffi
57
+ rb-fsevent (0.9.1)
58
+ rb-inotify (0.8.8)
59
+ ffi (>= 0.5.0)
60
+ rspec (2.11.0)
61
+ rspec-core (~> 2.11.0)
62
+ rspec-expectations (~> 2.11.0)
63
+ rspec-mocks (~> 2.11.0)
64
+ rspec-core (2.11.1)
65
+ rspec-expectations (2.11.2)
53
66
  diff-lcs (~> 1.1.3)
54
- rspec-mocks (2.10.1)
67
+ rspec-mocks (2.11.1)
55
68
  sprockets (2.1.3)
56
69
  hike (~> 1.2)
57
70
  rack (~> 1.0)
58
71
  tilt (~> 1.1, != 1.3.0)
59
- thor (0.14.6)
72
+ thor (0.15.4)
60
73
  tilt (1.3.3)
61
- timecop (0.3.5)
74
+ titleize (1.2.1)
62
75
 
63
76
  PLATFORMS
64
77
  ruby
65
78
 
66
79
  DEPENDENCIES
67
- mocha
68
- rake
69
- rspec
70
- timecop
80
+ guard-rspec (~> 1.2.1)
81
+ rake (~> 0.9.2.2)
82
+ rspec (~> 2.11.0)
71
83
  wordpress-deploy!
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/wordpress_deploy/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ #watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ #watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ #watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ #watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ #watch('config/routes.rb') { "spec/routing" }
15
+ #watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara request specs
18
+ #watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ #watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ #watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/README.md CHANGED
@@ -1,22 +1,37 @@
1
- Wordpress Deploy
2
- ======
1
+ Wordpress Deploy [![Build Status](https://secure.travis-ci.org/RLovelett/wordpress-deploy.png?branch=master)](http://travis-ci.org/RLovelett/wordpress-deploy)
2
+ ================
3
3
 
4
4
  Wordpress Deploy is a RubyGem, written for Linux and Mac OSX, that allows you to easily perform Wordpress deployment operations. It provides you with an elegant DSL in Ruby for modeling your deployments.
5
5
 
6
- ### Author
6
+ [Relocate Method](http://codex.wordpress.org/Changing_The_Site_URL#Relocate_method)
7
7
 
8
- **[Ryan Lovelett](http://ryan.lovelett.me/) ( [@rlovelett](http://twitter.com/#!/rlovelett) )**
8
+ Author
9
+ ------
10
+
11
+ [Ryan Lovelett](http://ryan.lovelett.me/) ( [@rlovelett](http://twitter.com/#!/rlovelett) )
9
12
 
10
13
  Drop me a message for any questions, suggestions, requests, bugs or submit them to the [issue log](https://github.com/rlovelett/wordpress-deploy/issues).
11
14
 
15
+ Requirements
16
+ ------------
17
+
18
+ * thor ~>0.15.4
19
+ * colorize ~>0.5.8
20
+ * os ~>0.9.4
21
+ * titleize ~>1.2.1
22
+ * rspec ~>2.11.0
12
23
 
13
- ### Installation
24
+ Installation
25
+ ------------
14
26
 
15
27
  To get the latest stable version
16
28
 
17
29
  gem install wordpress-deploy
18
30
 
19
- You can view the list of released versions over at [RubyGems.org (Backup)](https://rubygems.org/gems/wordpress-deploy/versions)
31
+ You can view the list of released versions over at [RubyGems.org
32
+ (Wordpress Deploy)](https://rubygems.org/gems/wordpress-deploy/versions)
20
33
 
34
+ Usage
35
+ -----
21
36
 
22
- ### Getting Started
37
+ wp-deploy help
@@ -4,8 +4,5 @@
4
4
  # Load the WordpressDeploy core library
5
5
  require File.expand_path("../../lib/wordpress_deploy", __FILE__)
6
6
 
7
- # Load the WordpressDeploy command line interface utility
8
- require File.expand_path("../../lib/wordpress_deploy/cli/utility", __FILE__)
9
-
10
7
  # Initialize the WordpressDeploy command line utility
11
- WordpressDeploy::CLI::Utility.start
8
+ WordpressDeploy::Cli::Utility.start
@@ -1,61 +1,35 @@
1
- # encoding: utf-8
1
+ require "thor"
2
+ require "open3"
3
+ require "fileutils"
2
4
 
3
- # Load Ruby Core Libraries
4
- require 'rubygems'
5
- require 'fileutils'
6
- require 'tempfile'
7
- require 'yaml'
8
- require 'etc'
9
-
10
- require 'open4'
11
- require 'thor'
12
-
13
- ##
14
- # The Wordpress Deploy Ruby Gem
15
5
  module WordpressDeploy
16
-
17
6
  ##
18
- # Wordpress Deploy's internal paths
19
- ROOT_PATH = File.dirname(__FILE__)
20
- LIBRARY_PATH = File.join(ROOT_PATH, 'wordpress_deploy')
21
- CLI_PATH = File.join(LIBRARY_PATH, 'cli')
22
- DATABASE_PATH = File.join(LIBRARY_PATH, 'database')
23
- STORAGE_PATH = File.join(LIBRARY_PATH, 'storage')
24
-
25
- ##
26
- # Autoload Wordpress Deploy CLI files
27
- module CLI
7
+ # WordpressDeploy's internal paths
8
+ #
9
+ LIBRARY_PATH = File.join(File.dirname(__FILE__), 'wordpress_deploy')
10
+ CLI_PATH = File.join(LIBRARY_PATH, 'cli')
11
+ WORDPRESS_PATH = File.join(LIBRARY_PATH, 'wordpress')
12
+ TRANSFER_PROTOCOLS_PATH = File.join(LIBRARY_PATH, 'transfer_protocols')
13
+ DATABASE_PATH = File.join(LIBRARY_PATH, 'database')
14
+
15
+ module Cli
28
16
  autoload :Helpers, File.join(CLI_PATH, 'helpers')
29
17
  autoload :Utility, File.join(CLI_PATH, 'utility')
30
18
  end
31
19
 
32
- ##
33
- # Autoload Wordpress Deploy storage files
34
- module Storage
35
- autoload :Base, File.join(STORAGE_PATH, 'base')
36
- autoload :FTP, File.join(STORAGE_PATH, 'ftp')
37
- autoload :SFTP, File.join(STORAGE_PATH, 'sftp')
38
- autoload :SCP, File.join(STORAGE_PATH, 'scp')
39
- autoload :Local, File.join(STORAGE_PATH, 'local')
20
+ module Wordpress
21
+ autoload :Configuration, File.join(WORDPRESS_PATH, 'configuration')
40
22
  end
41
23
 
42
- ##
43
- # Autoload Wordpress Deploy database files
44
- module Database
45
- autoload :Base, File.join(DATABASE_PATH, 'base')
46
- autoload :MySQL, File.join(DATABASE_PATH, 'mysql')
47
- autoload :PostgreSQL, File.join(DATABASE_PATH, 'postgresql')
48
- autoload :MongoDB, File.join(DATABASE_PATH, 'mongodb')
49
- autoload :Redis, File.join(DATABASE_PATH, 'redis')
50
- autoload :Riak, File.join(DATABASE_PATH, 'riak')
24
+ module TransferProtocols
25
+ autoload :Ftp, File.join(TRANSFER_PROTOCOLS_PATH, 'ftp')
51
26
  end
52
27
 
53
- %w{
54
- config
55
- errors
56
- logger
57
- pipeline
58
- version
59
- }.each {|lib| require File.join(LIBRARY_PATH, lib) }
28
+ module Database
29
+ autoload :MySql, File.join(DATABASE_PATH, 'mysql')
30
+ end
60
31
 
32
+ %w{version logger errors environment}.each do |klass|
33
+ require File.join(LIBRARY_PATH, klass)
34
+ end
61
35
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module WordpressDeploy
4
- module CLI
4
+ module Cli
5
5
  module Helpers
6
6
  UTILITY = {}
7
7
 
@@ -17,24 +17,26 @@ module WordpressDeploy
17
17
  # Returns nil
18
18
  def run(command)
19
19
  name = command_name(command)
20
- Logger.message "Running system utility '#{ name }'..."
20
+ Logger.debug "Running system utility '#{ name }'..."
21
21
 
22
22
  begin
23
- out, err = '', ''
24
- ps = Open4.popen4(command) do |pid, stdin, stdout, stderr|
23
+ out, err, ps = '', '', nil
24
+ Open3.popen3 command do |stdin, stdout, stderr, wait_thr|
25
25
  stdin.close
26
- out, err = stdout.read.strip, stderr.read.strip
26
+ out = stdout.read.strip
27
+ err = stderr.read.strip
28
+ ps = wait_thr.value #Process::Status object returned
27
29
  end
28
30
  rescue Exception => e
29
- raise Errors::CLI::SystemCallError.wrap(e, <<-EOS)
31
+ raise Errors::Cli::SystemCallError.wrap(e, <<-EOS)
30
32
  Failed to execute system command on #{ RUBY_PLATFORM }
31
33
  Command was: #{ command }
32
34
  EOS
33
35
  end
34
36
 
35
- if ps.success?
37
+ if !ps.nil? && ps.success?
36
38
  unless out.empty?
37
- Logger.message(
39
+ Logger.debug(
38
40
  out.lines.map {|line| "#{ name }:STDOUT: #{ line }" }.join
39
41
  )
40
42
  end
@@ -47,7 +49,7 @@ module WordpressDeploy
47
49
 
48
50
  return nil
49
51
  else
50
- raise Errors::CLI::SystemCallError, <<-EOS
52
+ raise Errors::Cli::SystemCallError, <<-EOS
51
53
  '#{ name }' Failed on #{ RUBY_PLATFORM }
52
54
  The following information should help to determine the problem:
53
55
  Command was: #{ command }
@@ -64,18 +66,29 @@ module WordpressDeploy
64
66
  # Raises an error if utility can not be found in the system's $PATH
65
67
  def utility(name)
66
68
  name = name.to_s.strip
67
- raise Errors::CLI::UtilityNotFoundError,
69
+ raise Errors::Cli::UtilityNotFoundError,
68
70
  'Utility Name Empty' if name.empty?
69
71
 
70
- path = UTILITY[name] || %x[which #{ name } 2>/dev/null].chomp
71
- if path.empty?
72
- raise Errors::CLI::UtilityNotFoundError, <<-EOS
72
+ path = UTILITY[name]
73
+ err, ps = '', nil
74
+ Open3.popen3 "which #{name}" do |stdin, stdout, stderr, wait_thr|
75
+ stdin.close
76
+ path = stdout.read.strip.chomp
77
+ err = stderr.read.strip.chomp
78
+
79
+ # Process::Status object returned
80
+ ps = wait_thr.value
81
+ end if path.nil?
82
+
83
+ if !ps.nil? && ps.success?
84
+ UTILITY[name] = path
85
+ else
86
+ raise Errors::Cli::UtilityNotFoundError, <<-EOS
73
87
  Could not locate '#{ name }'.
74
88
  Make sure the specified utility is installed
75
89
  and available in your system's $PATH.
76
90
  EOS
77
91
  end
78
- UTILITY[name] = path
79
92
  end
80
93
 
81
94
  ##