Class: Wordpress::Cli
- Inherits:
-
Object
- Object
- Wordpress::Cli
- Defined in:
- lib/wordpress/cli.rb
Overview
Sets up a new project or upgrades the Wordpress installation in an existing project.
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Instance Method Summary collapse
-
#initialize(*argv) ⇒ Cli
constructor
A new instance of Cli.
- #run ⇒ Object
Constructor Details
#initialize(*argv) ⇒ Cli
Returns a new instance of Cli.
9 10 11 12 13 |
# File 'lib/wordpress/cli.rb', line 9 def initialize(*argv) abort "Please specify the directory set up, e.g. #{File.basename($0)} ." if argv.empty? abort 'Too many arguments; please specify only the directory to set up.' if argv.length > 1 @base = File.(argv.shift) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
7 8 9 |
# File 'lib/wordpress/cli.rb', line 7 def base @base end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/wordpress/cli.rb', line 15 def run directory(base) do file 'Capfile', <<-END %w(rubygems wordpress).each { |lib| require lib } require 'wordpress/recipes/deploy' load 'config/deploy' END directory('config') do file 'boot.rb', <<-END %w( rubygems wordpress ).each { |lib| require lib } WORDPRESS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) END file 'deploy.rb', <<-END set :application, 'set your application name here' set :repository, 'set your repository location here' set :database_name, 'set your database name here' set :database_username, 'set your database username here' # If you aren't deploying to /u/apps/\#{application} on the target # servers (which is the default), you can specify the actual location # via the :deploy_to variable: # set :deploy_to, "/var/www/\#{application}" # If you aren't using Subversion to manage your source code, specify # your SCM below: # set :scm, :git # set :git_shallow_clone, 1 server 'your server here', :web, :app, :db, :primary => true END file 'lighttpd.conf', <<-END server.port = 3000 var.root = env.WORDPRESS_ROOT server.document-root = var.root + "/public" server.error-handler-404 = "/index.php" server.modules = ( "mod_fastcgi" ) index-file.names = ( "index.php" ) fastcgi.server = ( ".php" => (( "bin-path" => env.PHP_FASTCGI, "socket" => var.root + "/tmp/sockets/php" ))) include "lighttpd-mimetypes.conf" END file 'lighttpd-mimetypes.conf', <<-END mimetype.assign = ( ".pdf" => "application/pdf", ".sig" => "application/pgp-signature", ".spl" => "application/futuresplash", ".class" => "application/octet-stream", ".ps" => "application/postscript", ".torrent" => "application/x-bittorrent", ".dvi" => "application/x-dvi", ".gz" => "application/x-gzip", ".pac" => "application/x-ns-proxy-autoconfig", ".swf" => "application/x-shockwave-flash", ".tar.gz" => "application/x-tgz", ".tgz" => "application/x-tgz", ".tar" => "application/x-tar", ".zip" => "application/zip", ".mp3" => "audio/mpeg", ".m3u" => "audio/x-mpegurl", ".wma" => "audio/x-ms-wma", ".wax" => "audio/x-ms-wax", ".ogg" => "application/ogg", ".wav" => "audio/x-wav", ".gif" => "image/gif", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".png" => "image/png", ".xbm" => "image/x-xbitmap", ".xpm" => "image/x-xpixmap", ".xwd" => "image/x-xwindowdump", ".css" => "text/css", ".html" => "text/html", ".htm" => "text/html", ".js" => "text/javascript", ".asc" => "text/plain", ".c" => "text/plain", ".cpp" => "text/plain", ".log" => "text/plain", ".conf" => "text/plain", ".text" => "text/plain", ".txt" => "text/plain", ".dtd" => "text/xml", ".xml" => "text/xml", ".mpeg" => "video/mpeg", ".mpg" => "video/mpeg", ".mov" => "video/quicktime", ".qt" => "video/quicktime", ".avi" => "video/x-msvideo", ".asf" => "video/x-ms-asf", ".asx" => "video/x-ms-asf", ".wmv" => "video/x-ms-wmv", ".bz2" => "application/x-bzip", ".tbz" => "application/x-bzip-compressed-tar", ".tar.bz2" => "application/x-bzip-compressed-tar", # default mime type "" => "application/octet-stream", ) END config = Wordpress.config(:db_name => File.basename(base), :db_user => 'root', :db_password => '', :secret_key => Digest::SHA1.hexdigest(rand.to_s), :abspath => '/../public/') file 'wp-config.php', config file 'wp-config-sample.php', config end directory('public') do Wordpress.release.upgrade system 'rm', 'wp-config-sample.php' symlink '../config/wp-config.php' end directory('script') do file 'server', <<-END, :mode => 0755 #!/usr/bin/env ruby require File.join(File.dirname(__FILE__), '..', 'config', 'boot') require 'wordpress/servers/lighttpd' END end end end |