Class: Ap4r::Script::WorkspaceGenerator

Inherits:
Base show all
Defined in:
lib/ap4r/script/workspace_generator.rb

Constant Summary collapse

AP4R_Directories =
%w(config log public script tmp)

Instance Method Summary collapse

Instance Method Details

#run(argv, options) ⇒ Object



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
# File 'lib/ap4r/script/workspace_generator.rb', line 13

def run argv, options
  OptionParser.new {|opt|
    opt.on('-m'){
      # merge to rails project but not implemented yet...
    }

    opt.parse!(argv)
  }

  dir = argv.last
  unless dir
    logger.warn{"Specify a name of application root directory."}
    exit(1)
  end

  root_dir = File.expand_path(dir)

  logger.info{"make application root directory [#{root_dir}] ... "}
  FileUtils.mkdir_p(root_dir)

  logger.info{"make directories for AP4R [#{AP4R_Directories.join(", ")}] ..."}
  FileUtils.mkdir_p(AP4R_Directories.map{|d| File.join(root_dir, d)})

  %w(config script).each{ |recursive_copy_dir|
    copy_files(File.join(ap4r_base, recursive_copy_dir),
               File.join(root_dir, recursive_copy_dir))
  }

  copy_file(File.join(ap4r_base, "fresh_rakefile"), File.join(root_dir, "Rakefile"))

  logger.info{"\n[#{root_dir}] has successfully set up!\n"}

end