# ========================================================================== # Generator: PROJECT # Copyright: ©2006-2011 Strobe Inc. and contributors # portions copyright ©2009 Apple Inc. # ==========================================================================

namespace :generator do

# Accept the following types of arguments:
#
#  project .             #=> Make current working directory. like sc-init
#  project project_name  #=> Create project_name, namespace: ProjectName
#  project ProjectName   #=> Create project_name, namespace: ProjectName
#  project NameSpace path/to/project #=> Create path/to/project, NameSpace
#
task :prepare do
  # get arguments & normalize
  gen = GENERATOR
  namespace = gen.arguments[1]
  project_path = gen.arguments[2]

  if project_path
    project_path = File.expand_path(project_path)
    namespace = File.basename(project_path) if namespace == '.'
  elsif namespace == '.'
    project_path = Dir.pwd
    namespace = File.basename(project_path)
  else
    project_path = Dir.pwd / gen.snake_case(namespace)
  end

  # Setup standard options for generating a project
  gen.target_name = gen.target = gen.method_name = gen.class_name = nil
  gen.build_root = File.dirname(project_path) # dir where project dir lives
  gen.filename = File.basename(project_path) # project dir name
  gen.namespace = gen.camel_case namespace
end

end

# default behavior for a template is to just copy the contents of the # templates directory to the end destination. Add any additional configs here. config :templates,

:root_dir   => '_file_path_'