Sha256: c3d8da74a91be86b02ac15d8ab3dd4d810916d913da6de262002bd7dd2fba939

Contents?: true

Size: 495 Bytes

Versions: 4

Compression:

Stored size: 495 Bytes

Contents

require 'dev_scripts/script'
require 'dev_scripts/support/expanded_block'

DevScripts::Script.define_script :expand_block do
  args :file_path, :line_number

  execute do
    lines = []

    File.foreach(file_path).with_index do |file_line, index|
      if index + 1 == line_number.to_i
        lines << DevScripts::Support::ExpandedBlock.new(line: file_line)
      else
        lines << file_line
      end
    end

    File.open(file_path, 'w') { |file| file.write(lines.join('')) }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dev_scripts-0.2.1 lib/dev_scripts/scripts/expand_block.rb
dev_scripts-0.2.0 lib/dev_scripts/scripts/expand_block.rb
dev_scripts-0.1.9 lib/dev_scripts/scripts/expand_block.rb
dev_scripts-0.1.7 lib/dev_scripts/scripts/expand_block.rb