Class: Blogaze::Bin::Create

Inherits:
Shebang::Command
  • Object
show all
Defined in:
lib/blogaze/bin/create.rb

Constant Summary collapse

PROTOTYPE =

Path to the prototype application to use for new installations.

__DIR__('../../../proto')

Instance Method Summary collapse

Instance Method Details

#indexObject



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
# File 'lib/blogaze/bin/create.rb', line 19

def index
  # Require the name argument
  if ARGV[0] == '' or ARGV[0].nil?
    puts "Missing argument [NAME]"
    return
  end

  # Destination to copy files
  destination = File.join(Dir.pwd, ARGV[0])

  # Make sure the destination doesn't exist
  if File.directory?(destination) and !option(:f)
    puts "Directory already exists with name: #{ARGV[0]}"
    return
  else
    # Copy files
    puts 'Copying files...'
    FileUtils.cp_r(PROTOTYPE, destination)

    # Rename config files
    ['config.default.rb', 'database.default.rb'].each do |config|
      FileUtils.mv(destination + "/config/#{config}", destination + "/config/" + config.gsub('.default', ''))
    end

    # Tell the user what to do next
    puts 'Done.'
    puts
    puts "You will need to enter your database information"
    puts "into the 'config/database.rb' file then run the"
    puts "following commands:"
    puts
    puts "  rake db:migrate"
    puts "  rake db:defaults"
    puts
    puts "The default admin account is:"
    puts "  Username: admin"
    puts "  Password: admin"
    puts
  end
end