Class: Montage::Commands::Init
- Inherits:
-
Object
- Object
- Montage::Commands::Init
- Extended by:
- Montage::Commands
- Defined in:
- lib/montage/commands/init.rb
Overview
Creates a new project.
Constant Summary collapse
- TEMPLATES =
Path to lib/templates
Pathname.new(__FILE__).dirname.parent + 'templates'
Constants included from Montage::Commands
Class Method Summary collapse
-
.run ⇒ Object
Creates a new project in the current directory.
Instance Method Summary collapse
-
#initialize(dir) ⇒ Init
constructor
Creates a new Generate instance.
-
#run! ⇒ Object
Runs the command, creating the new project structure.
Methods included from Montage::Commands
Constructor Details
#initialize(dir) ⇒ Init
Creates a new Generate instance.
38 39 40 |
# File 'lib/montage/commands/init.rb', line 38 def initialize(dir) @dir = Pathname.new(dir) end |
Class Method Details
.run ⇒ Object
Creates a new project in the current directory.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/montage/commands/init.rb', line 17 def self.run(*) new(Dir.pwd).run! rescue Montage::ProjectExists => e if e..match(/`(.*)'$/)[1] == Dir.pwd say color("A Montage project already exists in the " \ "current directory", :red) else say color(e..compress_lines, :red) end exit(1) end |
Instance Method Details
#run! ⇒ Object
Runs the command, creating the new project structure.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/montage/commands/init.rb', line 44 def run! begin found = Project.find(@dir) rescue MissingProject ask_questions! make_directories! create_config! copy_sources! say color("Your project was created", :green) say Montage::Commands::BLANK else raise Montage::ProjectExists, <<-ERROR.compress_lines A Montage project exists in a parent directory at `#{found.paths.root}' ERROR end end |