Sha256: ea7a0fe890c09182d14c25543378befc38234456c43625cfc55d3e3a98f6d82f
Contents?: true
Size: 1007 Bytes
Versions: 2
Compression:
Stored size: 1007 Bytes
Contents
require 'rails/generators' class PresenterGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) def create_presenter_file path = "app/presenters/#{file_name}_presenter.rb" if FileTest.exist? path raise FileExistError, "This filename ist used by another presenter:#{path}" end copy_file "presenter_template.rb", path replace_class_name path replace_singular_name path end def create_presenter_test_file path = "test/presenters/#{file_name}_presenter_test.rb" if FileTest.exist? path raise FileExistError, "This filename ist used by another PresenterTest:#{path}" end copy_file "presenter_test_template.rb", path replace_class_name path end private def replace_class_name path gsub_file path, '-classname-' , "#{class_name}" end def replace_singular_name path gsub_file path, 'singular_name' , "#{plural_name.singularize}" end end class FileExistError < StandardError; end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
neo-rails-0.4.1 | lib/generators/presenter/presenter_generator.rb |
neo-rails-0.4.0 | lib/generators/presenter/presenter_generator.rb |