Sha256: 0c4f3484610187d75909cf5584588f0139d3468f72e187dd9e5127a61426eb51
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
module Jsus # # Packager is a plain simple class accepting several source files # and joining their contents. # # It uses Container for storage which means it automatically sorts sources. # class Packager # Container with source files attr_accessor :container # # Inits packager with the given sources. # # @param [SourceFile] source files # @api public def initialize(*sources) self.container = Container.new(*sources) end # @return [Jsus::Container] container with source files # @api public def sources container end # Concatenates all the sources' contents into a single string. # If given a filename, outputs into a file. # # @param [String, nil] output file name # @return [String] concatenated source files # @api public def pack(output_file = nil) result = sources.map {|s| s.content }.join("\n") if output_file FileUtils.mkdir_p(File.dirname(output_file)) File.open(output_file, "w") {|f| f << result } end result end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jsus-0.3.3 | lib/jsus/packager.rb |
jsus-0.3.2 | lib/jsus/packager.rb |