Sha256: 04c313e97cb90b109c4950fc10691e9c8b0c0ec146f32519f723d5436c664782

Contents?: true

Size: 982 Bytes

Versions: 2

Compression:

Stored size: 982 Bytes

Contents

module Gap
    class Exec
        def initialize(sam = Gap::Main)
            @sam = sam
        end

        def exec(cmdline, input)
            md5 = MD5.hexdigest(cmdline) + MD5.hexdigest(input)
            inputfile  = _file md5, ".input"
            outputfile = _file md5, ".output"
            outf = md5 + ".output"
            key = [Samsara::Meta.new(:Exec), outf]
            @sam.gen key do
                @sam.writefile inputfile, input
                system "#{cmdline} < #{inputfile} > #{outputfile}"
                @sam.readfile outputfile
            end
        end

        def marshal(cmdline, input)
            Marshal.load exec(cmdline, input)
        end

        DEFAULT_EXEC = Exec.new
        def self.exec(*a)
            DEFAULT_EXEC.exec(*a)
        end

        def self.marshal(*a)
            DEFAULT_EXEC.marshal(*a)
        end

        private
        def _file(name, ext = "")
            "temp/exec_" << name << ext
        end

    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gap50-0.1.1 lib/gap50/gap/exec.rb
gap50-0.1.0 lib/gap50/gap/exec.rb