Current Path: > > opt > > alt > ruby32 > share > ruby > syntax_suggest
Operation : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64 Software : Apache Server IP : 162.0.232.56 | Your IP: 216.73.216.111 Domains : 1034 Domain(s) Permission : [ 0755 ]
Name | Type | Size | Last Modified | Actions |
---|---|---|---|---|
capture | Directory | - | - | |
api.rb | File | 5281 bytes | April 24 2025 07:53:46. | |
around_block_scan.rb | File | 7067 bytes | April 24 2025 07:53:46. | |
block_expand.rb | File | 4991 bytes | April 24 2025 07:53:46. | |
capture_code_context.rb | File | 6826 bytes | April 24 2025 07:53:46. | |
clean_document.rb | File | 8947 bytes | April 24 2025 07:53:46. | |
cli.rb | File | 3190 bytes | April 24 2025 07:53:46. | |
code_block.rb | File | 2179 bytes | April 24 2025 07:53:46. | |
code_frontier.rb | File | 5752 bytes | April 24 2025 07:53:46. | |
code_line.rb | File | 6615 bytes | April 24 2025 07:53:46. | |
code_search.rb | File | 3908 bytes | April 24 2025 07:53:46. | |
core_ext.rb | File | 3076 bytes | April 24 2025 07:53:46. | |
display_code_with_line_numbers.rb | File | 1812 bytes | April 24 2025 07:53:46. | |
display_invalid_blocks.rb | File | 1795 bytes | April 24 2025 07:53:46. | |
explain_syntax.rb | File | 2465 bytes | April 24 2025 07:53:46. | |
left_right_lex_count.rb | File | 4156 bytes | April 24 2025 07:53:46. | |
lex_all.rb | File | 1145 bytes | April 24 2025 07:53:46. | |
lex_value.rb | File | 1540 bytes | April 24 2025 07:53:46. | |
parse_blocks_from_indent_line.rb | File | 1536 bytes | April 24 2025 07:53:46. | |
pathname_from_message.rb | File | 1454 bytes | April 24 2025 07:53:46. | |
priority_engulf_queue.rb | File | 1295 bytes | April 24 2025 07:53:46. | |
priority_queue.rb | File | 2046 bytes | April 24 2025 07:53:46. | |
ripper_errors.rb | File | 837 bytes | April 24 2025 07:53:46. | |
scan_history.rb | File | 2991 bytes | April 24 2025 07:53:46. | |
unvisited_lines.rb | File | 705 bytes | April 24 2025 07:53:46. | |
version.rb | File | 76 bytes | April 24 2025 07:53:46. |
# frozen_string_literal: true module SyntaxSuggest # Scans up/down from the given block # # You can try out a change, stash it, or commit it to save for later # # Example: # # scanner = ScanHistory.new(code_lines: code_lines, block: block) # scanner.scan( # up: ->(_, _, _) { true }, # down: ->(_, _, _) { true } # ) # scanner.changed? # => true # expect(scanner.lines).to eq(code_lines) # # scanner.stash_changes # # expect(scanner.lines).to_not eq(code_lines) class ScanHistory attr_reader :before_index, :after_index def initialize(code_lines:, block:) @code_lines = code_lines @history = [block] refresh_index end def commit_if_changed if changed? @history << CodeBlock.new(lines: @code_lines[before_index..after_index]) end self end # Discards any changes that have not been committed def stash_changes refresh_index self end # Discard changes that have not been committed and revert the last commit # # Cannot revert the first commit def revert_last_commit if @history.length > 1 @history.pop refresh_index end self end def changed? @before_index != current.lines.first.index || @after_index != current.lines.last.index end # Iterates up and down # # Returns line, kw_count, end_count for each iteration def scan(up:, down:) kw_count = 0 end_count = 0 up_index = before_lines.reverse_each.take_while do |line| kw_count += 1 if line.is_kw? end_count += 1 if line.is_end? up.call(line, kw_count, end_count) end.last&.index kw_count = 0 end_count = 0 down_index = after_lines.each.take_while do |line| kw_count += 1 if line.is_kw? end_count += 1 if line.is_end? down.call(line, kw_count, end_count) end.last&.index @before_index = if up_index && up_index < @before_index up_index else @before_index end @after_index = if down_index && down_index > @after_index down_index else @after_index end self end def next_up return nil if @before_index <= 0 @code_lines[@before_index - 1] end def next_down return nil if @after_index >= @code_lines.length @code_lines[@after_index + 1] end def lines @code_lines[@before_index..@after_index] end private def before_lines @code_lines[0...@before_index] || [] end # Returns an array of all the CodeLines that exist after # the currently scanned block private def after_lines @code_lines[@after_index.next..-1] || [] end private def current @history.last end private def refresh_index @before_index = current.lines.first.index @after_index = current.lines.last.index self end end end
SILENT KILLER Tool