Sha256: ddd696b1e2c98082678d2f4681ae3535dcb90d0310efb4842704635f23aa4978

Contents?: true

Size: 1.58 KB

Versions: 16

Compression:

Stored size: 1.58 KB

Contents

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

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

      repository = FileReferenceInstaller.repository
      puts "Registered Generators #{repository}"

      dependency_provider = DependencyProvider.new(repository)
      resolver = Molinillo::Resolver.new(dependency_provider, UI.new)
      @installer_resolution = resolver.resolve(repository)
    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}..."

      #TODO: Don't use class as name
      #TODO: Filter and first generator
      #TODO: Debug logs for generator
      installer_class = @installer_resolution.tsort.detect do |i|
        i.name.can_install_node(node)
      end

      if installer_class != nil then
        installer = installer_class.name.new(context)
        node.accept(installer)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
xcake-0.6.19 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.18 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.17 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.16 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.14 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.13 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.12 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.11 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.10 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.9 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.8 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.7 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.6 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.5 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.4 lib/xcake/generator/target_file_reference_generator.rb
xcake-0.6.2 lib/xcake/generator/target_file_reference_generator.rb