Class: Objc2swiftAssistant::FileSet

Inherits:
FailableProcessingElement show all
Defined in:
lib/objc2swift_assistant/file_sets.rb

Direct Known Subclasses

GeneratedSwiftFileSet, ScannedFileSet

Instance Attribute Summary collapse

Attributes inherited from FailableProcessingElement

#error_messages

Instance Method Summary collapse

Methods inherited from FailableProcessingElement

#add_error, #add_warning, #has_errors, #initiailize

Constructor Details

#initialize(root, configuration) ⇒ FileSet

Returns a new instance of FileSet.



22
23
24
25
26
27
# File 'lib/objc2swift_assistant/file_sets.rb', line 22

def initialize( root, configuration )
  super()
  @configuration = configuration
  @root = Pathname.new( root )
  @directory_nodes_by_path = {}
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



20
21
22
# File 'lib/objc2swift_assistant/file_sets.rb', line 20

def configuration
  @configuration
end

#directory_nodes_by_pathObject

Returns the value of attribute directory_nodes_by_path.



19
20
21
# File 'lib/objc2swift_assistant/file_sets.rb', line 19

def directory_nodes_by_path
  @directory_nodes_by_path
end

#rootObject

Returns the value of attribute root.



17
18
19
# File 'lib/objc2swift_assistant/file_sets.rb', line 17

def root
  @root
end

#root_dir_nodeObject

Returns the value of attribute root_dir_node.



18
19
20
# File 'lib/objc2swift_assistant/file_sets.rb', line 18

def root_dir_node
  @root_dir_node
end

Instance Method Details

#directory_node_for_path(path) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/objc2swift_assistant/file_sets.rb', line 29

def directory_node_for_path( path )
  node = @directory_nodes_by_path[ path.to_s ]

  if node.nil?
    node = make_directory_node( path )
    @directory_nodes_by_path[ path.to_s ] = node
  end

  return node
end

#dump(indent, tab, errors_only) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/objc2swift_assistant/file_sets.rb', line 45

def dump( indent, tab, errors_only )
  if errors_only
    puts( "\nWARNING: You specified '--structure errors'")
    puts( "         This option (Logging only only the file structure that caused errors) is not yet supported. The full source file structure will be logged.\n\n" )
  end

  @configuration.log_verbose( indent + "File Set")
  @root_dir_node.dump( indent+tab, tab, errors_only )
end

#make_directory_node(path) ⇒ Object



40
41
42
43
# File 'lib/objc2swift_assistant/file_sets.rb', line 40

def make_directory_node( path )
  node = DirectoryNode.new( path, self )
  node
end

#scanObject

Create nodes for all directories and files of interest Use find() to limit stack depth



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/objc2swift_assistant/file_sets.rb', line 57

def scan()
  @root.find() do |path|
    if path.directory?
      process_directory( path )
    else
      process_file( path )
    end
  end

  @configuration.log_verbose( "Processed #{@directory_nodes_by_path.size} directories.")

  collect_active_file_nodes()
end