Sha256: c9c3f55fccdc99409261701c6efbf5bdbdcd791f10c9b3ffcb4b55d7747ca22b

Contents?: true

Size: 580 Bytes

Versions: 2

Compression:

Stored size: 580 Bytes

Contents

require 'dev_scripts/script'
require 'dev_scripts/support/expanded_method'
require 'parser/current'

DevScripts::Script.define_script :expand_method_args 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::ExpandedMethod.new(
          ast_node: Parser::CurrentRuby.parse(file_line)
        )
      else
        lines << file_line
      end
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dev_scripts-0.2.1 lib/dev_scripts/scripts/expand_method_args.rb
dev_scripts-0.2.0 lib/dev_scripts/scripts/expand_method_args.rb