12
13
14
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
|
# File 'lib/wordless/cli.rb', line 12
def wp(dir_name = 'wordpress')
download_url, version, locale = Net::HTTP.get('api.wordpress.org', "/core/version-check/1.5/?locale=#{options[:locale]}").split[2,3]
downloaded_file = Tempfile.new('wordpress')
begin
puts "Downloading WordPress #{version} (#{locale})..."
`curl #{download_url} > #{downloaded_file.path} && unzip #{downloaded_file.path} -d #{dir_name}`
subdirectory = Dir["#{dir_name}/*/"].first FileUtils.mv Dir["#{subdirectory}*"], dir_name FileUtils.rmdir subdirectory
ensure
downloaded_file.close
downloaded_file.unlink
end
puts %Q{Installed WordPress in directory "#{dir_name}".}.green
if options[:bare]
dirs = %w(themes plugins).map {|d| "#{dir_name}/wp-content/#{d}"}
FileUtils.rm_rf dirs
FileUtils.mkdir dirs
dirs.each do |dir|
FileUtils.cp "#{dir_name}/wp-content/index.php", dir
end
puts "Removed default themes and plugins.".green
end
void = RbConfig::CONFIG['host_os'] =~ /msdos|mswin|djgpp|mingw/ ? 'NUL' : '/dev/null'
if git_installed?
if system 'git init'
puts "Initialized git repository.".green
else
puts "Couldn't initialize git repository.".red
end
else
puts "Didn't initialize git repository because git isn't installed.".yellow
end
end
|