Class: Lono::New
- Inherits:
-
Object
- Object
- Lono::New
- Defined in:
- lib/lono/new.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options) ⇒ New
constructor
A new instance of New.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ New
Returns a new instance of New.
3 4 5 6 7 |
# File 'lib/lono/new.rb', line 3 def initialize() @options = @project_root = [:project_root] || '.' @format = [:format] || 'json' end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'lib/lono/new.rb', line 2 def @options end |
Instance Method Details
#run ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lono/new.rb', line 9 def run puts "Setting up lono project" unless [:quiet] source_root = File.("../../starter_projects/#{@format}_project", __FILE__) paths = Dir.glob("#{source_root}/**/*"). select {|p| File.file?(p) } paths.each do |src| # starter_projects/yaml_project/ -> regexp = Regexp.new(".*starter_projects/#{@format}_project/") dest = src.gsub(regexp,'') dest = "#{@project_root}/#{dest}" if File.exist?(dest) and ![:force] puts "already exists: #{dest}" unless [:quiet] else puts "creating: #{dest}" unless [:quiet] dirname = File.dirname(dest) FileUtils.mkdir_p(dirname) unless File.exist?(dirname) FileUtils.cp(src, dest) end end puts "Starter lono project created" unless [:quiet] end |