Class: Jsus::Packager
- Inherits:
-
Object
- Object
- Jsus::Packager
- Defined in:
- lib/jsus/packager.rb
Overview
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.
Instance Attribute Summary collapse
-
#container ⇒ Object
Container with source files.
Instance Method Summary collapse
-
#initialize(sources) ⇒ Packager
constructor
Inits packager with the given sources.
-
#pack(output_file = nil) ⇒ String
Concatenates all the sources' contents into a single string.
-
#sources ⇒ Jsus::Container
Container with source files.
Constructor Details
Instance Attribute Details
#container ⇒ Object
Container with source files
10 11 12 |
# File 'lib/jsus/packager.rb', line 10 def container @container end |
Instance Method Details
#pack(output_file = nil) ⇒ String
Concatenates all the sources' contents into a single string. If given a filename, outputs into a file.
38 39 40 41 42 43 44 45 46 |
# File 'lib/jsus/packager.rb', line 38 def pack(output_file = nil) result = sources.map {|s| s.source }.join("\n") if output_file FileUtils.mkdir_p(File.dirname(output_file)) File.open(output_file, "w") {|f| f << result } end result end |
#sources ⇒ Jsus::Container
Returns container with source files.
28 29 30 |
# File 'lib/jsus/packager.rb', line 28 def sources @sources end |