class Object
Constants
- Ripper
-
This class provides a compatibility layer between prism and
Ripper. It functions by parsing the entire tree first and then walking it and executing each of theRippercallbacks as it goes. To use this class, you treatPrism::Translation::Rippereffectively as you would treat theRipperclass.Note that this class will serve the most common use cases, but Ripper’s API is extensive and undocumented. It relies on reporting the state of the parser at any given time. We do our best to replicate that here, but because it is a different architecture it is not possible to perfectly replicate the behavior of
Ripper.The main known difference is that we may omit dispatching some events in some cases. This impacts the following events:
-
on_assign_error
-
on_comma
-
on_ignored_nl
-
on_ignored_sp
-
on_kw
-
on_label_end
-
on_lbrace
-
on_lbracket
-
on_lparen
-
on_nl
-
on_op
-
on_operator_ambiguous
-
on_rbrace
-
on_rbracket
-
on_rparen
-
on_semicolon
-
on_sp
-
on_symbeg
-
on_tstring_beg
-
on_tstring_end
-
Public Class Methods
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/input.rb, line 6 def initialize(...) super require_relative "../lib/bake/format" end
Released under the MIT License. Copyright, 2022-2025, by Samuel Williams.
Source
# File vendor/bundle/ruby/4.0.0/gems/psych-5.3.1/lib/psych/core_ext.rb, line 3 def self.yaml_tag url Psych.add_tag(url, self) end
Public Instance Methods
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extconf.rb, line 116 def add_libprism_source(path) $VPATH << path src_list path end
Source
# File vendor/bundle/ruby/4.0.0/gems/console-1.34.3/bake/console.rb, line 14 def debug require_relative "../lib/console" Console.logger.debug! end
Increase the verbosity of the logger to debug.
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/input.rb, line 46 def file_type(path) if extension = File.extname(path) extension.sub!(/\A\./, "") return if extension.empty? return extension.to_sym end end
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/input.rb, line 38 def format_for(file, name) if file.respond_to?(:path) and path = file.path name ||= file_type(path) end Bake::Format[name] end
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extconf.rb, line 37 def generate_templates Dir.chdir(File.expand_path("../..", __dir__)) do if !File.exist?("include/prism/ast.h") && Dir.exist?(".git") system(RbConfig.ruby, "templates/template.rb", exception: true) end end end
If this gem is being build from a git source, then we need to run templating if it hasn’t been run yet. In normal packaging, we would have shipped the templated files with the gem, so this wouldn’t be necessary.
Source
# File vendor/bundle/ruby/4.0.0/gems/bigdecimal-4.0.1/ext/bigdecimal/extconf.rb, line 4 def have_builtin_func(name, check_expr, opt = "", &b) checking_for checking_message(name.funcall_style, nil, opt) do if try_compile(<<SRC, opt, &b) int foo; int main() { #{check_expr}; return 0; } SRC $defs.push(format("-DHAVE_BUILTIN_%s", name.tr_cpp)) true else false end end end
Source
# File vendor/bundle/ruby/4.0.0/gems/console-1.34.3/bake/console.rb, line 7 def info require_relative "../lib/console" Console.logger.info! end
Increase the verbosity of the logger to info.
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/input.rb, line 15 def input(file: $stdin, format: nil) if format = format_for(file, format) format.input(file) else raise "Unable to determine input format of #{file}!" end end
Parse an input file (defaulting to stdin) in the specified format. The format can be extracted from the file extension if left unspecified. @parameter file [Input] The input file. @parameter format [Symbol] The input format, e.g. json, yaml.
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extconf.rb, line 48 def make(env, target) puts "Running make #{target} with #{env.inspect}" Dir.chdir(File.expand_path("../..", __dir__)) do system( env, RUBY_PLATFORM.match?(/openbsd|freebsd/) ? "gmake" : "make", target, exception: true ) end end
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/output.rb, line 27 def null(input:) # This is a no-op, used to indicate that no output should be produced. return input end
Do not produce any output.
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/output.rb, line 15 def output(input:, file: $stdout, format: nil) if format = format_for(file, format) format.output(file, input) else raise "Unable to determine output format!" end # Allow chaining of output processing: return input end
Dump the last result to the specified file (defaulting to stdout) in the specified format (defaulting to Ruby’s pretty print). @parameter file [Output] The input file. @parameter format [Symbol] The output format.
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/output.rb, line 33 def output?(recipe) true end
This command produces output, and therefore doesn’t need default output handling.
Source
# File vendor/bundle/ruby/4.0.0/gems/bake-0.24.1/bake/input.rb, line 26 def parse(text, format: :json) file = StringIO.new(text) if format = format_for(nil, format) format.input(file) else raise "Unable to determine input format!" end end
Parse some input text in the specified format (defaulting to JSON). @parameter text [String] The input text. @parameter format [Symbol] The input format, e.g. json, yaml.
Source
# File vendor/bundle/ruby/4.0.0/gems/prism-1.9.0/ext/prism/extconf.rb, line 110 def src_list(path) srcdir = path.dup RbConfig.expand(srcdir) # mutates srcdir :-/ Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] end
Source
# File vendor/bundle/ruby/4.0.0/gems/webrick-1.9.2/lib/webrick/httpservlet/cgi_runner.rb, line 12 def sysread(io, size) buf = +"" while size > 0 tmp = io.sysread(size) buf << tmp size -= tmp.bytesize end return buf end
cgi_runner.rb – CGI launcher.
Author: IPR – Internet Programming with Ruby – writers Copyright © 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU Copyright © 2002 Internet Programming with Ruby writers. All rights reserved.
$IPR: cgi_runner.rb,v 1.9 2002/09/25 11:33:15 gotoyuzo Exp $
Source
# File vendor/bundle/ruby/4.0.0/gems/psych-5.3.1/lib/psych/core_ext.rb, line 12 def to_yaml options = {} Psych.dump self, options end
Convert an object to YAML. See Psych.dump for more information on the available options.