Class: Ecic::FileAdder
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Ecic::FileAdder
- Includes:
- LibraryCreationHelper, SourceListUpdater, Thor::Actions
- Defined in:
- lib/ecic/file_adder.rb
Instance Attribute Summary collapse
-
#file_names ⇒ Object
Returns the value of attribute file_names.
-
#library_name ⇒ Object
Returns the value of attribute library_name.
-
#project ⇒ Object
Returns the value of attribute project.
Instance Method Summary collapse
Methods included from LibraryCreationHelper
#create_library_if_missing, #generate_library, #ok_to_create_library?
Methods included from SourceListUpdater
Instance Attribute Details
#file_names ⇒ Object
Returns the value of attribute file_names.
8 9 10 |
# File 'lib/ecic/file_adder.rb', line 8 def file_names @file_names end |
#library_name ⇒ Object
Returns the value of attribute library_name.
8 9 10 |
# File 'lib/ecic/file_adder.rb', line 8 def library_name @library_name end |
#project ⇒ Object
Returns the value of attribute project.
8 9 10 |
# File 'lib/ecic/file_adder.rb', line 8 def project @project end |
Instance Method Details
#add_files_to_source_list ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ecic/file_adder.rb', line 10 def add_files_to_source_list #If a library name is given, the project must already contain a library #with that name. Otherwise an error message must be returned, because we #do not know if it is a design or testbench library. unless library_name.nil? library = project.get_library(library_name) raise "Unknown library called '#{library_name}'. Please create the library before adding files to it. " if library.nil? end destination_path = Pathname.new(destination_root) file_names.each { |file_name| src_file_info = SourceFileInfo.new(project, file_name, library) raise "Library name could not be determined from the path of '#{file_name}'.\nMake sure the appropriate library has been created and specify it with the --lib option - or create an empty sources.rb file in the root directory of the library." if src_file_info.library.nil? if create_library_if_missing(src_file_info.library) add_src_file(src_file_info, destination_path) else say set_color("Skipping #{file_name}",Thor::Shell::Color::BLUE) end } end |