Sha256: 235026f478e704aa99aed74ed137967315778bf141dbb7c9e0efeacf4d375cf5

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

module Xcake
  class TargetFileReferenceGenerator < Generator
    attr_accessor :root_node
    attr_accessor :dependency_provider

    def initialize(context)
      @context = context
      @root_node = Node.new

      @dependency_provider = DependencyProvider.new(FileReferenceInstaller)
    end

    def self.dependencies
      [TargetGenerator]
    end

    def process_files_for_target(target)
      native_target = @context.native_object_for(target)

      Dir.glob(target.include_files).each do |file|
        @root_node.create_children_with_path(file, native_target)
      end if target.include_files

      Dir.glob(target.exclude_files).each do |file|
        @root_node.remove_children_with_path(file, native_target)
      end if target.exclude_files
    end

    def visit_project(project)
      project.targets.each do |target|
        process_files_for_target(target)
      end

      root_node.accept(self)
    end

    def visit_node(node)
      return unless node.path
      puts "Adding #{node.path}..."

      installer_class = @dependency_provider.tsort.detect do |i|
        i.can_install_node(node)
      end

      unless installer_class.nil?
        installer = installer_class.new(context)
        node.accept(installer)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xcake-0.6.20 lib/xcake/generator/target_file_reference_generator.rb