Sha256: aeeb896e377a4ffc77c9432577ce97ad01695c565a2cbd0f7eedaefd3992d57c
Contents?: true
Size: 1.1 KB
Versions: 3
Compression:
Stored size: 1.1 KB
Contents
# Include all language parsers here module BetterRailsDebugger::Parser class Analyzer def initialize(path, options) @path = path @options = options end def self.analise(path, options) self.new(path, options).run end def run # Check if file exist or not raise ArgumentError.new "File #{@path} does not exist" if !File.exist? @path # Detect lang by file ext lang = get_lang_from_path raise ArgumentError.new "Sorry, we do not support that language" if lang != 'ruby' # Only ruby by the moment # Create lang instance with options lang_instance = get_lang_instance lang # parse end # get file ext and return language as 'ruby', 'javascript', 'php' or nil if unknown def get_lang_from_path case File.extname(@path).downcase when '.rb' 'ruby' when '.js' 'javascript' when '.php' 'php' else nil end end def get_lang_instance(lang) "BetterRailsDebugger::#{lang.classify}::Parser".constantize.new @path, @options end end end
Version data entries
3 entries across 3 versions & 1 rubygems