Module: Rfmt
- Defined in:
- lib/rfmt.rb,
lib/rfmt/cli.rb,
lib/rfmt/cache.rb,
lib/rfmt/lsp/uri.rb,
lib/rfmt/version.rb,
lib/rfmt/lsp/server.rb,
lib/rfmt/configuration.rb,
lib/rfmt/lsp/formatter.rb,
lib/rfmt/lsp/workspace.rb,
lib/rfmt/lsp/message_io.rb,
lib/rfmt/lsp/document_store.rb,
lib/rfmt/native_extension_loader.rb
Defined Under Namespace
Modules: Config, LSP, NativeExtensionLoader Classes: CLI, Cache, CacheCommands, Configuration, Error, RfmtError, ValidationError
Constant Summary collapse
- VERSION =
'2.0.0.beta1'
Class Method Summary collapse
-
.format(source, config_path: nil) ⇒ String
Format Ruby source code Parsing, config resolution, and output validation all happen natively in Rust.
-
.format_file(path) ⇒ String
Format a Ruby file.
-
.parse(source) ⇒ String
Parse Ruby code to AST (for debugging).
-
.resolved_config(config_path: nil) ⇒ String
Effective configuration as the Rust formatter resolves it.
-
.version_info ⇒ String
Get version information.
Class Method Details
.format(source, config_path: nil) ⇒ String
Format Ruby source code Parsing, config resolution, and output validation all happen natively in Rust
30 31 32 33 34 35 36 37 38 |
# File 'lib/rfmt.rb', line 30 def self.format(source, config_path: nil) if config_path format_code_with_config(source, config_path.to_s) else format_code(source) end rescue StandardError => e raise wrap_native_error(e) end |
.format_file(path) ⇒ String
Format a Ruby file
57 58 59 60 61 62 |
# File 'lib/rfmt.rb', line 57 def self.format_file(path) source = File.read(path) format(source) rescue Errno::ENOENT raise Error, "File not found: #{path}" end |
.parse(source) ⇒ String
Parse Ruby code to AST (for debugging)
82 83 84 85 86 |
# File 'lib/rfmt.rb', line 82 def self.parse(source) parse_to_json(source) rescue StandardError => e raise wrap_native_error(e) end |
.resolved_config(config_path: nil) ⇒ String
Effective configuration as the Rust formatter resolves it
67 68 69 70 71 |
# File 'lib/rfmt.rb', line 67 def self.resolved_config(config_path: nil) resolved_config_yaml(config_path&.to_s) rescue StandardError => e raise wrap_native_error(e) end |
.version_info ⇒ String
Get version information
75 76 77 |
# File 'lib/rfmt.rb', line 75 def self.version_info "Ruby: #{VERSION}, Rust: #{rust_version}" end |