Sha256: ee38b3cfdcc72abd4db56d41c8288ae40cd941c8d96cae07b89495464a58d433

Contents?: true

Size: 1.12 KB

Versions: 5

Compression:

Stored size: 1.12 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(&:label).join(' ') + "\n\n"
    end

    def libraries_list
      'lib_LIBRARIES = ' + libraries.map(&:label).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

5 entries across 5 versions & 1 rubygems

Version Path
rake-builder-0.9.1 lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb
rake-builder-0.9.0 lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb
rake-builder-0.8.0 lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb
rake-builder-0.7.0 lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb
rake-builder-0.0.19 lib/rake/builder/presenters/makefile_am/builder_collection_presenter.rb