Class: MRubyPortable::NewProject
- Inherits:
-
Object
- Object
- MRubyPortable::NewProject
- Defined in:
- lib/mruby_portable/new_project.rb
Instance Attribute Summary collapse
-
#target_dir ⇒ Object
readonly
Returns the value of attribute target_dir.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(target_dir) ⇒ NewProject
constructor
A new instance of NewProject.
Constructor Details
#initialize(target_dir) ⇒ NewProject
Returns a new instance of NewProject.
10 11 12 |
# File 'lib/mruby_portable/new_project.rb', line 10 def initialize(target_dir) @target_dir = File.(target_dir) end |
Instance Attribute Details
#target_dir ⇒ Object (readonly)
Returns the value of attribute target_dir.
8 9 10 |
# File 'lib/mruby_portable/new_project.rb', line 8 def target_dir @target_dir end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/mruby_portable/new_project.rb', line 14 def call raise Error, "directory already exists: #{target_dir}" if File.exist?(target_dir) FileUtils.mkdir_p(File.join(target_dir, "assets")) render("project/mruby-portable.yml.erb", File.join(target_dir, "mruby-portable.yml")) FileUtils.cp(Paths.template("project", "main.rb"), File.join(target_dir, "main.rb")) FileUtils.touch(File.join(target_dir, "assets", ".keep")) target_dir end |