Sha256: f1e7561d4701630b95ef2ec063cc40364392b2ad76f784d1c49012144d54e3a9

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module Rake; class Builder; module Presenters; module MakefileAm
  class BuilderCollectionPresenter
    attr_accessor :builders

    def initialize(builders)
      @builders = builders
    end

    def to_s
      programs_list + program_sections + libraries_list + library_sections
    end

    def save
      File.open('Makefile.am', 'w') do |f|
        f.write to_s
      end
    end

    private

    def programs
      @builders.reject(&:is_library?)
    end

    def libraries
      @builders.select(&:is_library?)
    end

    def programs_list
      'bin_PROGRAMS = ' + programs.map(&:target_path).join(' ') + "\n\n"
    end

    def libraries_list
      'lib_LIBRARIES = ' + libraries.map(&:target_path).join(' ') + "\n\n"
    end

    def program_sections
      programs.map do |program|
        presenter = Rake::Builder::Presenters::MakefileAm::BuilderPresenter.new(program)
        presenter.to_s
      end.join("\n")
    end

    def library_sections
      libraries.map do |lib|
        presenter = Rake::Builder::Presenters::MakefileAm::BuilderPresenter.new(lib)
        presenter.to_s
      end.join("\n")
    end
  end
end; end; end; end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rake-builder-0.10.1 lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb
rake-builder-0.9.2 lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb