Sha256: 5e1bdfe0d71f03572893fcc7465be283adf777df3ff06a9893f380c419c33189

Contents?: true

Size: 772 Bytes

Versions: 4

Compression:

Stored size: 772 Bytes

Contents

require 'parser/current'
require 'dev_scripts/support/block'
require 'dev_scripts/support/method_call'

module DevScripts
  module Support
    class ExpandedBlock < String
      def initialize(line:)
        parsed = Parser::CurrentRuby.parse(line).children
        spacing = line.match(/\A\s*/)[0]
        end_spacing = line.match(/\s*\z/)[0]
        block_string = DevScripts::Support::Block.new(parsed[1], parsed[2])
        block_lines = block_string.split("\n")

        self << spacing + DevScripts::Support::MethodCall.new(parsed[0])
        self << ' '
        self << block_lines[0]
        self << "\n"
        self << spacing + block_lines[1]
        self << "\n"
        self << spacing + block_lines[2]
        self << end_spacing
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dev_scripts-0.2.1 lib/dev_scripts/support/expanded_block.rb
dev_scripts-0.2.0 lib/dev_scripts/support/expanded_block.rb
dev_scripts-0.1.9 lib/dev_scripts/support/expanded_block.rb
dev_scripts-0.1.7 lib/dev_scripts/support/expanded_block.rb