Sha256: b28830f639805a1ec6824feaf9574612f83d5d1bbc6e9d5f371aa1b5c34f46e8
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require 'cocaine' require 'shellwords' module Seek module SampleTemplates # Generator class for creating templates. # Generally this shouldn't be used directly, but instead should be used # through Seek::SampleTemplates.generate(..) class Generator JAR_VERSION = '0.3'.freeze JAR_PATH = File.dirname(__FILE__) + "/../../../jars/sample-template-generator-#{JAR_VERSION}.jar" DEFAULT_MEMORY_ALLOCATION = '512M'.freeze BUFFER_SIZE = 250_000 # 1/4 a megabyte attr_reader :json, :path, :memory_allocation def initialize(path, json, memory_allocation = DEFAULT_MEMORY_ALLOCATION) @path = path @json = json @memory_allocation = memory_allocation end def generate run_with_cocaine end private def command command = "java -Xmx#{@memory_allocation} -jar #{JAR_PATH}" command += " -f #{Shellwords.escape(path)}" command += " -j #{Shellwords.escape(json)}" command end def run_with_cocaine output = Cocaine::CommandLine.new(command).run output.strip rescue Cocaine::ExitStatusError => exception raise exception.message end end end end
Version data entries
3 entries across 3 versions & 2 rubygems