Skip to content

Instantly share code, notes, and snippets.

@calavera
Created December 6, 2010 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calavera/730210 to your computer and use it in GitHub Desktop.
Save calavera/730210 to your computer and use it in GitHub Desktop.
class MirahInterpreter < CommandInterpreter
$Extension
def self.getExtension
@@extension ||= DescriptorImpl.new(MirahInterpreter.class)
end
$DataBoundConstructor
def initialize(command:String, verbose:boolean)
super(command)
@verbose = verbose
end
def buildCommandLine(script:FilePath)
verbose_arg = @verbose ? '--verbose' : ''
list = ['mirah', verbose_arg, script.getRemote]
strings = String[list.size]
list.size.times { |i| strings[i] = String(list.get(i)) }
strings
end
def isVerbose
@verbose
end
def getFileExtension
".mirah"
end
def getDescriptor
@@extension
end
def getContents
getCommand
end
class DescriptorImpl < BuilderStepDescriptor
def initialize(clazz:Class)
super(clazz)
end
def newInstance(req:StaplerRequest, data:JSONObject):Builder
MirahInterpreter.new(data.getString('command'), data.getBoolean('verbose'))
end
def getDisplayName
"Execute Mirah script"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment