Class: IronWorkerNG::Code::Builder
- Defined in:
- lib/iron_worker_ng/code/builder.rb
Instance Attribute Summary collapse
-
#builder_remote_build_command ⇒ Object
Returns the value of attribute builder_remote_build_command.
Attributes inherited from Base
#base_dir, #dest_dir, #env, #features, #fix_params, #fixators, #use_build_cache, #use_local_iron_worker_ng, #zip_package
Instance Method Summary collapse
- #bundle(container, local = false) ⇒ Object
-
#initialize(*args, &block) ⇒ Builder
constructor
A new instance of Builder.
Methods inherited from Base
#build_workerfile, #create_container, #fixate, #full_remote_build, #full_remote_build=, #guess_name_for_path, #install, #method_missing, #name, #name=, #remote, #remote_build_command, #remote_build_command=, #run, #runtime, #runtime=, #runtime_bundle, #runtime_run_code, #stack, #to_s
Methods included from Feature::Common::SetEnv::InstanceMethods
Methods included from Feature::Common::MergeZip::InstanceMethods
Methods included from Feature::Common::MergeDeb::InstanceMethods
Methods included from Feature::Common::MergeDir::InstanceMethods
Methods included from Feature::Common::MergeFile::InstanceMethods
Constructor Details
#initialize(*args, &block) ⇒ Builder
Returns a new instance of Builder.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/iron_worker_ng/code/builder.rb', line 8 def initialize(*args, &block) @features = [] @fixators = [] @base_dir = '' @dest_dir = '' @remote_build_command = nil @full_remote_build = false @use_local_iron_worker_ng = false runtime(:ruby) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class IronWorkerNG::Code::Base
Instance Attribute Details
#builder_remote_build_command ⇒ Object
Returns the value of attribute builder_remote_build_command.
6 7 8 |
# File 'lib/iron_worker_ng/code/builder.rb', line 6 def builder_remote_build_command @builder_remote_build_command end |
Instance Method Details
#bundle(container, local = false) ⇒ Object
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/iron_worker_ng/code/builder.rb', line 23 def bundle(container, local = false) @exec = IronWorkerNG::Feature::Common::MergeExec::Feature.new(self, '__builder__.rb', {}) super(container, local) if builder_remote_build_command container.get_output_stream(@dest_dir + '__builder__.sh') do |builder| builder.write <<BUILDER_SH # #{IronWorkerNG.full_version} #{builder_remote_build_command} BUILDER_SH end end install_iron_worker_ng = '' if not @use_local_iron_worker_ng install_iron_worker_ng = "system('gem install iron_worker_ng -v #{IronWorkerNG::VERSION}')" end container.get_output_stream(@dest_dir + '__builder__.rb') do |builder| builder.write <<BUILDER_RUBY # #{IronWorkerNG.full_version} require 'json' File.open('.gemrc', 'w') do |gemrc| gemrc.puts('gem: --no-ri --no-rdoc') end #{install_iron_worker_ng} require 'iron_worker_ng' IronWorkerNG::Feature::Ruby::MergeGem.merge_binary = true code = IronWorkerNG::Code::Base.new(params[:code_name]) if not File.exists?('bundler.magic') deps = code.features.reject { |f| f.class != IronWorkerNG::Feature::Ruby::MergeGemDependency::Feature } deps.each do |dep| if dep.name == 'bundler' and dep.version != '>= 0' system('touch bundler.magic') system('gem uninstall bundler') system("gem install bundler -v '\#{dep.version}'") success = system("ruby __runner__.rb \#{ARGV.join(' ')}") exit(success ? 0 : 1) end end end if File.exists?('__builder__.sh') pre_build_list = Dir.glob('__build__/**/**') exit 1 unless system('cd __build__ && sh ../__builder__.sh && cd ..') post_build_list = Dir.glob('__build__/**/**') (post_build_list.sort - pre_build_list.sort).each do |new_file| code.file(new_file, File.dirname(new_file[10 .. -1])) if File.file?(new_file) end end code.install(true) require 'bundler/setup' 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 |