Class: Squib::Commands::New
- Inherits:
-
Object
- Object
- Squib::Commands::New
- Defined in:
- lib/squib/commands/new.rb
Overview
Generate a new Squib project into a fresh directory.
Provides conventions for using Git (you are using version control, right??). Also provides some basic layout and config files to start from, along with templates for instructions and other notes you don’t want to forget.
Instance Method Summary collapse
- #advanced_message ⇒ Object
- #empty_path_error ⇒ Object
-
#process(args, advanced) ⇒ Object
private
:nodoc:.
- #template_path(advanced) ⇒ Object
Instance Method Details
#advanced_message ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/squib/commands/new.rb', line 57 def "\nThis is the advanced layout designed for larger games. Everything is\norganized into separate directories and the workflow is all based on\nthe Rakefile.\n\nFrom within this directory, run `bundle install` to install extra\ngems.\n\nAfter that, run `rake` to build. Check out the Rakefile for more.\n\nHappy Squibbing! And best of luck with your game.\n -Andy (@andymeneely)\n\n EOS\nend\n" |
#empty_path_error ⇒ Object
43 44 45 |
# File 'lib/squib/commands/new.rb', line 43 def empty_path_error ArgumentError.new('Please specify a path.') end |
#process(args, advanced) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
:nodoc:
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/squib/commands/new.rb', line 26 def process(args, advanced) raise empty_path_error if args.empty? new_project_path = File.(args.join(' '), Dir.pwd) FileUtils.mkdir_p new_project_path if !Dir["#{new_project_path}/**/*"].empty? $stderr.puts "#{new_project_path} exists and is not empty. Doing nothing and quitting." else Dir.chdir(new_project_path) do FileUtils.cp_r template_path(advanced) + '/.', new_project_path end end puts "Created basic Squib project in #{new_project_path}." puts if advanced end |
#template_path(advanced) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/squib/commands/new.rb', line 47 def template_path(advanced) path = case advanced when true '../builtin/projects/advanced' else '../builtin/projects/basic' end File.(path, File.dirname(__FILE__)) end |