Sha256: a8b98d8f80368a9ff3348270304c20646a590cf4c49877695c64d5197bc2ef52

Contents?: true

Size: 1.28 KB

Versions: 2

Compression:

Stored size: 1.28 KB

Contents

require_relative '../feature/ruby/merge_gem'

module IronWorkerNG
  module Code
    class Builder < IronWorkerNG::Code::Base
      def initialize(*args, &block)
        @features = []
        @fixators = []

        @base_dir = ''
        @dest_dir = ''

        runtime(:ruby)
      end

      def bundle(container)
        @exec = IronWorkerNG::Feature::Common::MergeExec::Feature.new(self, '__builder__.rb', {})

        super(container)

        container.get_output_stream(@dest_dir + '__builder__.sh') do |builder|
          builder.write <<BUILDER_SH
# #{IronWorkerNG.full_version}
#{remote_build_command}
BUILDER_SH
        end

        container.get_output_stream(@dest_dir + '__builder__.rb') do |builder|
          builder.write <<BUILDER_RUBY
# #{IronWorkerNG.full_version}

require 'json'

require 'iron_worker_ng'

exit 1 unless system('cd __build__ && sh ../__builder__.sh && cd ..')

::Dir.chdir('__build__')

code = IronWorkerNG::Code::Base.new
code.inside_builder = true

code.name params[:code_name]
code.dir '.'

client = IronWorkerNG::Client.new(JSON.parse(params[:client_options]))

res = client.codes.create(code, JSON.parse(params[:codes_create_options]))

client.tasks.set_progress(iron_task_id, :msg => res.marshal_dump.to_json)
BUILDER_RUBY
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
iron_worker_ng-0.10.4 lib/iron_worker_ng/code/builder.rb
iron_worker_ng-0.10.3 lib/iron_worker_ng/code/builder.rb