• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Nu-hin / remote_ruby / 19836456948

01 Dec 2025 08:27PM UTC coverage: 95.157% (-0.08%) from 95.234%
19836456948

push

github

Nu-hin
Fix README.md parameters section

1120 of 1177 relevant lines covered (95.16%)

141.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/lib/remote_ruby/source_extractor.rb
1
# frozen_string_literal: true
2

3
require 'method_source'
20✔
4
require 'remote_ruby/parser_factory'
20✔
5

6
module RemoteRuby
20✔
7
  # Receives a block and extracts Ruby code (as a string) with this block's
8
  # source
9
  class SourceExtractor
20✔
10
    def extract(&block)
20✔
11
      RemoteRuby::ParserFactory.require_parser
900✔
12
      ast = Parser::CurrentRuby.parse(block.source)
900✔
13
      block_node = find_block(ast)
900✔
14

15
      return '' unless block_node
900✔
16

17
      _, body = parse(block_node)
900✔
18
      Unparser.unparse(body)
900✔
19
    end
20

21
    private
20✔
22

23
    def find_block(node)
20✔
24
      return nil unless node.is_a? AST::Node
1,820✔
25
      return node if node.type == :block
1,360✔
26

27
      node.children.each do |child|
460✔
28
        res = find_block(child)
920✔
29
        return res if res
920✔
30
      end
31

32
      nil
33
    end
34

35
    def parse(node)
20✔
36
      args = node.children[1].children
900✔
37
      body = node.children[2]
900✔
38
      [args, body]
900✔
39
    end
40
  end
41
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc