<s> """<STR_LIT>""" <EOL> import os <EOL> import re <EOL> import shlex <EOL> import sublime <EOL> from . import linter , persist , util <EOL> CMD_RE = re . compile ( r'<STR_LIT>' ) <EOL> class RubyLinter ( linter . Linter ) : <EOL> """<STR_LIT>""" <EOL> comment_re = r'<STR_LIT>' <EOL> @ classmethod <EOL> def initialize ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( ) . initialize ( ) <EOL> if cls . executable_path is not None : <EOL> return <EOL> if not callable ( cls . cmd ) and cls . cmd : <EOL> cls . executable_path = cls . lookup_executables ( cls . cmd ) <EOL> elif cls . executable : <EOL> cls . executable_path = cls . lookup_executables ( cls . executable ) <EOL> if not cls . executable_path : <EOL> cls . disabled = True <EOL> @ classmethod <EOL> def reinitialize ( cls ) : <EOL> """<STR_LIT>""" <EOL> cls . executable_path = None <EOL> cls . initialize ( ) <EOL> @ classmethod <EOL> def lookup_executables ( cls , cmd ) : <EOL> """<STR_LIT>""" <EOL> ruby = None <EOL> rbenv = util . which ( '<STR_LIT>' ) <EOL> if not rbenv : <EOL> ruby = util . which ( '<STR_LIT>' ) <EOL> if not ruby : <EOL> ruby = util . which ( '<STR_LIT>' ) <EOL> if not rbenv and not ruby : <EOL> persist . printf ( <EOL> '<STR_LIT>' <EOL> . format ( cls . name , cmd [ <NUM_LIT:0> ] ) <EOL> ) <EOL> return [ ] <EOL> if isinstance ( cmd , str ) : <EOL> cmd = shlex . split ( cmd ) <EOL> match = CMD_RE . match ( cmd [ <NUM_LIT:0> ] ) <EOL> if match : <EOL> gem = match . group ( '<STR_LIT>' ) <EOL> elif cmd [ <NUM_LIT:0> ] != '<STR_LIT>' : <EOL> gem = cmd [ <NUM_LIT:0> ] <EOL> else : <EOL> gem = '<STR_LIT>' <EOL> if gem : <EOL> gem_path = util . which ( gem ) <EOL> if gem_path : <EOL> if ( rbenv and <EOL> ( '<STR_LIT>' . format ( os . sep ) in gem_path or <EOL> ( os . altsep and '<STR_LIT>' . format ( os . altsep in gem_path ) ) ) ) : <EOL> ruby_cmd = [ gem_path ] <EOL> elif ( sublime . platform ( ) == '<STR_LIT>' ) : <EOL> ruby_cmd = [ gem_path ] <EOL> else : <EOL> ruby_cmd = [ ruby , gem_path ] <EOL> else : <EOL> persist . printf ( <EOL> '<STR_LIT>' <EOL> . format ( cls . name , gem ) <EOL> ) <EOL> return [ ] <EOL> else : <EOL> ruby_cmd = [ ruby ] <EOL> if cls . env is None : <EOL> if rbenv : <EOL> cls . env = { } <EOL> else : <EOL> gem_home = util . get_environment_variable ( '<STR_LIT>' ) <EOL> if gem_home : <EOL> cls . env = { '<STR_LIT>' : gem_home } <EOL> else : <EOL> cls . env = { } <EOL> return ruby_cmd </s>
