lib/vernacular.rb in vernacular-0.1.2 vs lib/vernacular.rb in vernacular-1.0.0
- old
+ new
@@ -1,41 +1,35 @@
+# frozen_string_literal: true
+
require 'date'
require 'digest'
-require 'parser'
-require 'tempfile'
+require 'fileutils'
require 'uri'
-require 'vernacular/ast_modifier'
-require 'vernacular/ast_parser'
require 'vernacular/configuration_hash'
require 'vernacular/regex_modifier'
require 'vernacular/source_file'
+require 'vernacular/version'
Dir[File.expand_path('vernacular/modifiers/*', __dir__)].each do |file|
require file
end
# Allows extending ruby's syntax and compilation process
module Vernacular
- PARSER_PATH = File.expand_path('vernacular/parser.rb', __dir__).freeze
-
# Module that gets included into `RubyVM::InstructionSequence` in order to
# hook into the require process.
module InstructionSequenceMixin
def load_iseq(filepath)
- ::Vernacular::SourceFile.load_iseq(filepath) if filepath != PARSER_PATH
+ ::Vernacular::SourceFile.load_iseq(filepath)
end
end
# Module that gets included into `Bootsnap::CompileCache::ISeq` in order to
# hook into the bootsnap compilation process.
module BootsnapMixin
def input_to_storage(contents, filepath)
- if filepath == PARSER_PATH
- raise ::Bootsnap::CompileCache::Uncompilable, "can't compile parser"
- end
-
contents = ::Vernacular.modify(contents)
iseq = RubyVM::InstructionSequence.compile(contents, filepath, filepath)
iseq.to_binary
rescue SyntaxError
raise ::Bootsnap::CompileCache::Uncompilable, 'syntax error'
@@ -76,10 +70,10 @@
end
source
end
def iseq_path_for(source_path)
- source_path.gsub(/[^A-Za-z0-9\._-]/) { |c| '%02x' % c.ord }
+ source_path.gsub(/[^A-Za-z0-9\._-]/) { |c| format('%02x', c.ord) }
.gsub('.rb', '.yarb')
end
private