/usr/lib/ruby/vendor_ruby/ramaze/bin/create.rb is in ruby-ramaze 2012.12.08-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 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 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 | require 'fileutils'
module Ramaze
#:nodoc:
module Bin
##
# Simple command that allows users to easily create a new application based
# on the prototype that ships with Ramaze.
#
# Usage:
#
# ramaze create blog
#
# @author Yorick Peterse
# @since 21-07-2011
#
class Create
Description = 'Creates a new Ramaze application'
Banner = <<-TXT.strip
Allows developers to easily create new Ramaze applications based on the
prototype that ships with Ramaze.
Usage:
ramaze create [NAME] [OPTIONS]
Example:
ramaze create blog
TXT
##
# Creates a new instance of the command and sets the options for
# OptionParser.
#
# @author Yorick Peterse
# @since 21-07-2011
#
def initialize
@options = {
:force => false
}
@opts = OptionParser.new do |opt|
opt.banner = Banner
opt.summary_indent = ' '
opt.separator "\nOptions:\n"
opt.on('-f', '--force', 'Overwrites existing directories') do
@options[:force] = true
end
opt.on('-h', '--help', 'Shows this help message') do
puts @opts
exit
end
end
end
##
# Runs the command based on the specified command line arguments.
#
# @author Yorick Peterse
# @since 21-07-2011
# @param [Array] argv Array containing all command line arguments.
#
def run(argv = [])
@opts.parse!(argv)
path = argv.delete_at(0)
proto = __DIR__('../../proto')
abort 'You need to specify a name for your application' if path.nil?
if File.directory?(path) and @options[:force] === false
abort 'The specified application already exists, use -f to overwrite it'
end
if File.directory?(path) and @options[:force] === true
FileUtils.rm_rf(path)
end
begin
FileUtils.cp_r(proto, path)
puts "The application has been generated and saved in #{path}"
rescue
abort 'The application could not be generated'
end
end
end # Create
end # Bin
end # Ramaze
|