Class: IronWorkerNG::Code::Ruby
- Includes:
- Feature::Ruby::MergeExec::InstanceMethods, Feature::Ruby::MergeGem::InstanceMethods, Feature::Ruby::MergeGemfile::InstanceMethods
- Defined in:
- lib/iron_worker_ng/code/ruby.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes included from Feature::Ruby::MergeGem::InstanceMethods
Attributes inherited from Base
#base_dir, #dest_dir, #features
Instance Method Summary collapse
Methods included from Feature::Ruby::MergeExec::InstanceMethods
Methods included from Feature::Ruby::MergeGemfile::InstanceMethods
Methods included from Feature::Ruby::MergeGem::InstanceMethods
included, #merge_gem, #merge_gem_fixate
Methods inherited from Base
#create_zip, #fixate, #hash_string, #initialize, #name, #name=, register_feature, register_type, registered_features, registered_types, #remote_build_command, #remote_build_command=, #runtime, #runtime=
Methods included from Feature::Common::MergeDir::InstanceMethods
Methods included from Feature::Common::MergeFile::InstanceMethods
Methods included from Initializer::InstanceMethods
#guess_name_for_path, #initialize_code
Constructor Details
This class inherits a constructor from IronWorkerNG::Code::Base
Instance Method Details
#bundle(zip) ⇒ 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 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 |
# File 'lib/iron_worker_ng/code/ruby.rb', line 12 def bundle(zip) super(zip) zip.get_output_stream(@dest_dir + '__runner__.rb') do |runner| runner.write <<RUBY_RUNNER # iron_worker_ng-#{IronWorkerNG.full_version} module IronWorkerNG #{File.read(File.dirname(__FILE__) + '/../../3rdparty/hashie/merge_initializer.rb')} #{File.read(File.dirname(__FILE__) + '/../../3rdparty/hashie/indifferent_access.rb')} end class IronWorkerNGHash < Hash include IronWorkerNG::Hashie::Extensions::MergeInitializer include IronWorkerNG::Hashie::Extensions::IndifferentAccess end root = nil payload_file = nil task_id = nil 0.upto($*.length - 2) do |i| root = $*[i + 1] if $*[i] == '-d' payload_file = $*[i + 1] if $*[i] == '-payload' task_id = $*[i + 1] if $*[i] == '-id' end ENV['GEM_PATH'] = ([root + '__gems__'] + (ENV['GEM_PATH'] || '').split(':')).join(':') $:.unshift("\#{root}") require 'json' @iron_task_id = task_id @payload = File.read(payload_file) params = {} begin params = JSON.parse(@payload) rescue end @params = IronWorkerNGHash.new(params) def payload @payload end def params @params end def iron_task_id @iron_task_id end require '#{File.basename(@exec.path)}' unless #{@exec.klass == nil} exec_class = Kernel.const_get('#{@exec.klass}') exec_inst = exec_class.new params.keys.each do |param| if param.class == String if exec_inst.respond_to?(param + '=') exec_inst.send(param + '=', params[param]) end end end exec_inst.run end RUBY_RUNNER end end |
#run_code ⇒ Object
89 90 91 92 93 |
# File 'lib/iron_worker_ng/code/ruby.rb', line 89 def run_code <<RUN_CODE ruby __runner__.rb "$@" RUN_CODE end |