Class: Wpcap::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/wpcap/command.rb

Class Method Summary collapse

Class Method Details

.build(args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/wpcap/command.rb', line 28

def self.build(args)
  @wp_root = File.expand_path args.first
  @application = File.dirname @wp_root
  puts "Processing #{@wp_root} into a wpcap directory style"
  unless File.exists? @wp_root + '/wp-load.php'
    warn "This folder does not appear to be a wordpress directory. "
    abort
  end

  FileUtils.mv @wp_root, @wp_root + "/app", :force => true
  self.setup
end

.create(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/wpcap/command.rb', line 11

def self.create(args)
  @application = args.first.to_s.downcase
  @wp_root = File.join( (args[1].nil? ? Dir.pwd : args[1]) , @application)
  @app_dir = @wp_root + "/app"

  if File.directory? "#{@wp_root}"
    warn "Project Folder Already Exists"
    abort
  end

  FileUtils.mkdir_p(@wp_root)

  install_wordpress @app_dir

  self.setup
end

.help(cmd) ⇒ Object



60
61
62
63
# File 'lib/wpcap/command.rb', line 60

def self.help(cmd)
  puts "`#{cmd}` is not a wpcap command."
  puts "See `wpcap help` for a list of available commands."
end

.run(command, args) ⇒ Object



7
8
9
# File 'lib/wpcap/command.rb', line 7

def self.run(command, args)
  Wpcap::Command.send(command, args)
end

.setupObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/wpcap/command.rb', line 41

def self.setup
  puts "Capifying your project and seting up config directories"
  unless File.exists? "#{@app_dir}/wp-load.php"
    warn "This does not Appear to be a wpcap project"
    abort
  end

  self.capify(@wp_root)

  FileUtils.mkdir_p "#{@wp_root}/config/deploy"
  FileUtils.touch "#{@wp_root}/config/database.yml"
  FileUtils.rm "#{@wp_root}/config/deploy.rb" if File.exists?  "#{@wp_root}/config/deploy.rb"
  FileUtils.cp "#{File.dirname(__FILE__)}/recipes/templates/deploy.rb.erb"      ,   "#{@wp_root}/config/deploy.rb"
  FileUtils.cp "#{File.dirname(__FILE__)}/recipes/templates/deploy_stage.rb.erb",   "#{@wp_root}/config/deploy/staging.rb"
  FileUtils.cp "#{File.dirname(__FILE__)}/recipes/templates/deploy_stage.rb.erb",   "#{@wp_root}/config/deploy/production.rb"

  puts "You are all Done, begin building your wordpress site in the app directory!"
end