Class: Snapshot::Builder
- Inherits:
-
Object
- Object
- Snapshot::Builder
- Defined in:
- lib/snapshot/builder.rb
Constant Summary collapse
- BUILD_DIR =
'/tmp/snapshot'
Instance Method Summary collapse
- #build_app(clean: true) ⇒ Object
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
8 9 10 |
# File 'lib/snapshot/builder.rb', line 8 def initialize end |
Instance Method Details
#build_app(clean: true) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/snapshot/builder.rb', line 12 def build_app(clean: true) FileUtils.rm_rf(BUILD_DIR) if clean command = SnapshotConfig.shared_instance.build_command if not command # That's the default case, user did not provide a custom build_command raise "Could not find project. Please pass the path to your project using 'project_path'.".red unless SnapshotConfig.shared_instance.project_name command = generate_build_command(clean: clean) end Helper.log.info "Building project '#{SnapshotConfig.shared_instance.project_name}' - this might take some time...".green Helper.log.debug command.yellow all_lines = [] PTY.spawn(command) do |stdin, stdout, pid| stdin.each do |line| all_lines << line begin parse_build_line(line) if line.length > 2 rescue Exception => ex Helper.log.fatal all_lines.join("\n") raise ex end end end if all_lines.join('\n').include?'** BUILD SUCCEEDED **' Helper.log.info "BUILD SUCCEEDED".green return true else Helper.log.info(all_lines.join(' ')) raise "Looks like the build was not successfull." end end |