lib/sculptor/cli/create.rb in sculptor-0.0.3 vs lib/sculptor/cli/create.rb in sculptor-0.0.4
- old
+ new
@@ -14,20 +14,25 @@
true
end
desc 'create NAME', 'Create new model NAME'
def create(name)
- model_path = "source/#{name}"
+ dir = Dir.pwd.match(/\/source$/) ? "." : "source"
+
+ model_path = "#{dir}/#{name}"
+
say(set_color("Creating model: ", :yellow) + set_color(model_path, :white, :bold))
is_subdir = name.split('/').count > 1
parent_path = is_subdir ? model_path.split('/')[0..-2].join('/') : model_path
@name = name
@title = options[:title] || ask('Title: ')
@description = options[:desc] || ask('Description: ')
@stylesheet = ask('Stylesheet: ')
+ @iframe = yes?('Use iframe?')
+
@dir = is_subdir ? name.split('/')[0..-2].join('/') : name
@has_data = if yes?('Include data?')
@model_name = name.split('/').last
template 'data', (is_subdir ? model_path : File.join(model_path, name)) + '.yaml'