Sha256: b6e1a4ec3104f54cb776bc54aa894fa4f0b11aba2a3066d4f3ed7a0ef01adff4
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
# encoding: UTF-8 require 'generators/dry_crud/dry_crud_generator_base' module DryCrud # Copies one file of dry_crud to the rails application. class FileGenerator < ::DryCrudGeneratorBase desc "Copy one file from dry_crud to the application.\nFILENAME is a part of the name of the file to copy. Must match exactly one file." argument :filename, type: :string, desc: 'Name or part of the filename to copy. Must match exactly one file.' def copy_matching_file files = matching_files case files.size when 1 copy_files(@root_folder => files) when 0 puts "No file containing '#{filename}' found in dry_crud." else puts "Please be more specific. All the following files match '#{filename}':" files.each do |f| puts " * #{f}" end end end private def matching_files all_template_files.collect do |root, files| files.select do |f| included = f.include?(filename) @root_folder = root if included included end end.flatten end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry_crud-3.0.0 | lib/generators/dry_crud/file_generator.rb |
dry_crud-2.1.2 | lib/generators/dry_crud/file_generator.rb |