github.com/LanceLRQ/deer-common@v0.0.9-0.20210319081233-e8222ac018a8/provider/ruby.go (about) 1 /* Ruby Compiler Provider 2 * (C) 2019 LanceLRQ 3 * 4 * This code is licenced under the GPLv3. 5 */ 6 package provider 7 8 import ( 9 "fmt" 10 ) 11 12 type RubyCompileProvider struct { 13 CodeCompileProvider 14 } 15 16 func NewRubyCompileProvider() *RubyCompileProvider { 17 return &RubyCompileProvider{ 18 CodeCompileProvider{ 19 isReady: false, 20 realTime: true, 21 Name: "ruby", 22 }, 23 } 24 } 25 26 func (prov *RubyCompileProvider) Init(code string, workDir string) error { 27 prov.codeContent = code 28 prov.workDir = workDir 29 30 err := prov.checkWorkDir() 31 if err != nil { 32 return err 33 } 34 35 err = prov.initFiles(".rb", "") 36 return err 37 } 38 39 func (prov *RubyCompileProvider) Compile() (result bool, errmsg string) { 40 result, errmsg = prov.shell(fmt.Sprintf(CompileCommands.Ruby, prov.codeFilePath)) 41 if result { 42 prov.isReady = true 43 } 44 return 45 } 46 47 func (prov *RubyCompileProvider) GetRunArgs() (args []string) { 48 args = []string{"/usr/bin/ruby", prov.codeFilePath} 49 return 50 } 51 52 func (prov *RubyCompileProvider) IsCompileError(remsg string) bool { 53 return false 54 }