module Dapp::Dapp::Ruby2Go
Public Instance Methods
_download_ruby2go_bin(progname, bin_path)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 104 def _download_ruby2go_bin(progname, bin_path) lock("downloader.bin.#{progname}", default_timeout: 1800) do return if File.exists? bin_path log_process("Downloading #{progname} dapp dependency") do location = URI("https://dl.bintray.com/dapp/ruby2go/#{::Dapp::VERSION}/#{progname}") tmp_bin_path = File.join(self.class.tmp_base_dir, "#{progname}-#{SecureRandom.uuid}") ::Dapp::Downloader.download(location, tmp_bin_path, show_progress: true, progress_titile: bin_path) checksum_location = URI("https://dl.bintray.com/dapp/ruby2go/#{::Dapp::VERSION}/#{progname}.sha") tmp_bin_checksum_path = tmp_bin_path + ".checksum" ::Dapp::Downloader.download(checksum_location, tmp_bin_checksum_path) if Digest::SHA256.hexdigest(File.read(tmp_bin_path)) != File.read(tmp_bin_checksum_path).strip raise ::Dapp::Error::Dapp, code: :ruby2go_download_failed_bad_checksum, data: {url: location.to_s, checksum_url: checksum_location.to_s, progname: progname} end File.chmod(0755, tmp_bin_path) FileUtils.mkdir_p File.dirname(bin_path) FileUtils.mv tmp_bin_path, bin_path end # log_process end # lock end
_ruby2go(progname, args_hash, tmp_dir: nil)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 57 def _ruby2go(progname, args_hash, tmp_dir: nil) tmp_dir = _ruby2go_tmp_dir if tmp_dir.nil? call_id = SecureRandom.uuid args_file = File.join(tmp_dir, "args.#{call_id}.json") File.open(args_file, "w") {|f| f.write JSON.dump(args_hash)} res_file = File.join(tmp_dir, "res.#{call_id}.json") if bin_path = ENV[_ruby2go_bin_path_env_var_name(progname)] unless File.exists? bin_path raise ::Dapp::Error::Dapp, code: :ruby2go_bin_path_not_found, data: {env_var_name: _ruby2go_bin_path_env_var_name(progname), path: bin_path} end else bin_path = File.join(::Dapp::Dapp.home_dir, "bin", progname, ::Dapp::VERSION, progname) unless File.exists? bin_path _download_ruby2go_bin(progname, bin_path) end end env_hash = ENV.map {|k, v| [k, v]}.to_h begin exec(env_hash, "#{bin_path} -args-from-file #{args_file} -result-to-file #{res_file}") unless (pid = fork) pid, status = Process.waitpid2(pid) rescue Interrupt => _e Process.kill('INT', pid) raise end status_code = status.exitstatus if [0, 16].include?(status_code) res = nil File.open(res_file, "r") {|f| res = JSON.load(f.read)} res else raise ::Dapp::Dapp::Ruby2Go::Error, code: :ruby2go_command_unexpected_exitstatus, data: { progname: progname, status_code: status_code } end end
_ruby2go_bin_path_env_var_name(progname)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 53 def _ruby2go_bin_path_env_var_name(progname) "DAPP_BIN_#{progname.gsub("-", "_").upcase}" end
_ruby2go_tmp_dir()
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 100 def _ruby2go_tmp_dir @_ruby2go_tmp_dir ||= Dir.mktmpdir('dapp-ruby2go-', tmp_base_dir) end
ruby2go_builder(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 15 def ruby2go_builder(args_hash) _ruby2go("builder", args_hash) end
ruby2go_cleanup(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 31 def ruby2go_cleanup(args_hash) _ruby2go("cleanup", args_hash) end
ruby2go_dappdeps(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 23 def ruby2go_dappdeps(args_hash) _ruby2go("dappdeps", args_hash) end
ruby2go_deploy(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 43 def ruby2go_deploy(args_hash) _ruby2go("deploy", args_hash) end
ruby2go_deploy_watcher(args_hash, **kwargs)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 39 def ruby2go_deploy_watcher(args_hash, **kwargs) _ruby2go("deploy-watcher", args_hash, **kwargs) end
ruby2go_docker_registry(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 11 def ruby2go_docker_registry(args_hash) _ruby2go("docker_registry", args_hash) end
ruby2go_git_artifact(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 19 def ruby2go_git_artifact(args_hash) _ruby2go("git-artifact", args_hash) end
ruby2go_git_repo(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 27 def ruby2go_git_repo(args_hash) _ruby2go("git-repo", args_hash) end
ruby2go_image(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 7 def ruby2go_image(args_hash) _ruby2go("image", args_hash) end
ruby2go_init()
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 47 def ruby2go_init @_call_after_before_terminate << proc { FileUtils.rmtree(@_ruby2go_tmp_dir) if @_ruby2go_tmp_dir } end
ruby2go_slug(args_hash)
click to toggle source
# File lib/dapp/dapp/ruby2go.rb, line 35 def ruby2go_slug(args_hash) _ruby2go("slug", args_hash) end