Sha256: e267ff384c98e4e579cb53bb2f0458331eac5aee25682d6682382b653589fea5
Contents?: true
Size: 1.48 KB
Versions: 3
Compression:
Stored size: 1.48 KB
Contents
# encoding: UTF-8 begin require 'generators/dry_crud/dry_crud_generator_base' rescue LoadError => e # 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].downcase == 'haml' ? '.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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dry_crud-3.0.0 | lib/generators/dry_crud/dry_crud_generator.rb |
dry_crud-2.1.2 | lib/generators/dry_crud/dry_crud_generator.rb |
dry_crud-2.1.1 | lib/generators/dry_crud/dry_crud_generator.rb |