Sha256: 9f2d821f7db9887c8210c4f4f493df70265eda4327232413b5eaf4775f6a8b5f
Contents?: true
Size: 728 Bytes
Versions: 2
Compression:
Stored size: 728 Bytes
Contents
# frozen_string_literal: true require "erb" require "zeitwerk" require "phlexing" require "dry/files" require "tqdm" def add_autoload_entries(module_file, resources) # rubocop:disable Style/TopLevelMethodDefinition autoload_content = resources.map do |resource| (" " * 6) + "autoload :#{resource.name}, \"#{resource.relative_file_path}\"" end lines = File.readlines(module_file) start = lines.index { |line| line.include?("# autogenerated:start") } finish = lines.index { |line| line.include?("# autogenerated:finish") } # Remove existing lines lines.slice!(start + 1..finish - 1) # Place new lines lines.insert(start + 1, "#{autoload_content.join("\n")}\n") File.write(module_file, lines.join) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
protos-icon-0.4.1 | generators/helpers.rb |
protos-icon-0.4.0 | generators/helpers.rb |