Class: Application::Builder
- Defined in:
- lib/hotcocoa/application/builder.rb
Overview
This class is responsible for building application bundles, but could theoretically be used to build other bundles, such as frameworks, with only a few changes.
It is designed to work in conjunction with an Specification object which would provide details on how to build the bundle.
Instance Attribute Summary collapse
-
#spec ⇒ Application::Specification
readonly
Cached spec.
Class Method Summary collapse
-
.build(spec, opts = {}) ⇒ Object
Build an application from a specification, optionally for deployment.
Instance Method Summary collapse
-
#build(opts = {}) ⇒ Object
-
#initialize(spec) ⇒ Builder
constructor
A new instance of Builder.
-
#remove_bundle_root ⇒ Object
Destroy the existing bundle, if it exists.
-
#run ⇒ Object
Run the bundle’s binary directly so
STDOUT
andSTDERR
appear in the terminal.
Constructor Details
#initialize(spec) ⇒ Builder
Returns a new instance of Builder.
35 36 37 38 39 40 41 42 |
# File 'lib/hotcocoa/application/builder.rb', line 35 def initialize spec @spec = case spec when Specification spec when String Specification.load spec end end |
Instance Attribute Details
#spec ⇒ Application::Specification (readonly)
Cached spec.
32 33 34 |
# File 'lib/hotcocoa/application/builder.rb', line 32 def spec @spec end |
Class Method Details
.build(spec, opts = {}) ⇒ Object
Build an application from a specification, optionally for deployment.
24 25 26 |
# File 'lib/hotcocoa/application/builder.rb', line 24 def self.build spec, opts = {} new(spec).build(opts) end |
Instance Method Details
#build(opts = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/hotcocoa/application/builder.rb', line 46 def build opts = {} if spec.overwrite? || opts[:deploy] # Deploying always makes a fresh build remove_bundle_root end build_bundle_structure write_bundle_files copy_sources copy_resources compile_data_models copy_icon_file if spec.icon_exists? deploy if opts[:deploy] end |
#remove_bundle_root ⇒ Object
Destroy the existing bundle, if it exists.
68 69 70 |
# File 'lib/hotcocoa/application/builder.rb', line 68 def remove_bundle_root FileUtils.rm_rf bundle_root if File.exist?(bundle_root) end |
#run ⇒ Object
Run the bundle’s binary directly so STDOUT
and STDERR
appear in the
terminal.
62 63 64 |
# File 'lib/hotcocoa/application/builder.rb', line 62 def run `"./#{executable_file}"` end |