Sha256: e10c6e4040a70e24bc2f3a7d37c5acd7db8df65c3471445a34d430cab21c6800
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
begin require 'generators/dry_crud/dry_crud_generator_base' rescue LoadError => _ # rubocop:disable Lint/HandleExceptions # ok, we are in the rake task end # Copies all dry_crud files to the rails application. class DryCrudGenerator < DryCrudGeneratorBase desc 'Copy all dry_crud files to the application.' class_options %w[templates -t] => 'erb' class_options %w[tests] => 'testunit' # copy everything to application def install_dry_crud copy_files(all_template_files) Dir.chdir(self.class.template_root) do copy_crud_test_model end readme 'INSTALL' end private def should_copy?(file_source) !file_source.end_with?(exclude_template) && !file_source.start_with?(exclude_test_dir) && file_source != 'INSTALL' end def copy_crud_test_model unless exclude_test_dir == 'spec' template(File.join('test', 'support', 'crud_test_model.rb'), File.join('spec', 'support', 'crud_test_model.rb')) template(File.join('test', 'support', 'crud_test_models_controller.rb'), File.join('spec', 'support', 'crud_test_models_controller.rb')) template(File.join('test', 'support', 'crud_test_helper.rb'), File.join('spec', 'support', 'crud_test_helper.rb')) end end def exclude_template options[:templates].casecmp('haml').zero? ? '.erb' : '.haml' end def exclude_test_dir case options[:tests].downcase when 'rspec' then 'test' when 'all' then 'exclude_nothing' else 'spec' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry_crud-5.2.0 | lib/generators/dry_crud/dry_crud_generator.rb |