lib/hyla/commands/create.rb in hyla-1.0 vs lib/hyla/commands/create.rb in hyla-1.0.1
- old
+ new
@@ -1,25 +1,34 @@
module Hyla
module Commands
class Create < Command
- def self.process(args, options = {})
+ def self.process(args, options)
+ destination = options[:destination] if check_mandatory_option?('--d / --destination', options[:destination])
+ artefact_type = options[:artefact_type] if check_mandatory_option?('--a / --artefact_type', options[:artefact_type])
+ type = options[:type] if check_mandatory_option?('--t / --type', options[:type])
- @config = Hyla::Configuration.new
-
- destination = options[:destination]
- artefact_type = options[:artefact_type]
- type = options[:type]
-
- copy_artefact(type, artefact_type, destination)
+ copy_artefact(type, artefact_type, destination)
end
+ #
+ # Copy Artefact to Destination directory
+ #
def self.copy_artefact(type, artefact_type, destination)
- artefact_name = type + '_' + artefact_type + @config.ADOC_EXT
- source = [@config.templates, 'sample', artefact_name] * '/'
- destination = [destination] * '/'
+ artefact_file_name = type + '_' + artefact_type + Configuration::ADOC_EXT
+ source = [Configuration::samples, artefact_file_name] * '/'
+ destination = File.expand_path(destination)
+
FileUtils.cp(source, destination)
+
+ Hyla::logger.info ">> Artefact #{artefact_file_name} added to project #{destination}"
+
+ case artefact_type
+ when 'image','audio','video'
+ source_dir = [Configuration::samples, artefact_type] * '/'
+ FileUtils.cp_r(source_dir,destination)
+ end
end
- end # class
+ end # class Create
end # module Commands
end # module Hyla
\ No newline at end of file