class Bundler::CLI

def gem(name)

def gem(name)
  name = name.chomp("/") # remove trailing slash if present
  target = File.join(Dir.pwd, name)
  constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
  constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
  constant_array = constant_name.split('::')
  git_author_name = `git config user.name`.chomp
  git_author_email = `git config user.email`.chomp
  author_name = git_author_name.empty? ? "TODO: Write your name" : git_author_name
  author_email = git_author_email.empty? ? "TODO: Write your email address" : git_author_email
  FileUtils.mkdir_p(File.join(target, 'lib', name))
  opts = {:name => name, :constant_name => constant_name, :constant_array => constant_array, :author_name => author_name, :author_email => author_email}
  template(File.join("newgem/Gemfile.tt"),               File.join(target, "Gemfile"),                opts)
  template(File.join("newgem/Rakefile.tt"),              File.join(target, "Rakefile"),               opts)
  template(File.join("newgem/gitignore.tt"),             File.join(target, ".gitignore"),             opts)
  template(File.join("newgem/newgem.gemspec.tt"),        File.join(target, "#{name}.gemspec"),        opts)
  template(File.join("newgem/lib/newgem.rb.tt"),         File.join(target, "lib/#{name}.rb"),         opts)
  template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{name}/version.rb"), opts)
  if options[:bin]
    template(File.join("newgem/bin/newgem.tt"),          File.join(target, 'bin', name),              opts)
  end
  Bundler.ui.info "Initializating git repo in #{target}"
  Dir.chdir(target) { `git init`; `git add .` }
end