Class: Ecic::FileAdder

Inherits:
Thor::Group
  • Object
show all
Includes:
LibraryCreationHelper, SourceListUpdater, Thor::Actions
Defined in:
lib/ecic/file_adder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from LibraryCreationHelper

#create_library_if_missing, #generate_library, #ok_to_create_library?

Methods included from SourceListUpdater

#add_src_file

Instance Attribute Details

#file_namesObject

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_nameObject

Returns the value of attribute library_name.



8
9
10
# File 'lib/ecic/file_adder.rb', line 8

def library_name
  @library_name
end

#projectObject

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_listObject



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