Class: ExtensionMailerGenerator
- Inherits:
-
MailerGenerator
- Object
- MailerGenerator
- ExtensionMailerGenerator
- Defined in:
- lib/generators/extension_mailer/extension_mailer_generator.rb
Instance Attribute Summary collapse
-
#extension_name ⇒ Object
Returns the value of attribute extension_name.
Instance Method Summary collapse
- #add_options!(opt) ⇒ Object
- #banner ⇒ Object
- #destination_root ⇒ Object
- #extension_path ⇒ Object
- #extension_uses_rspec? ⇒ Boolean
-
#initialize(runtime_args, runtime_options = {}) ⇒ ExtensionMailerGenerator
constructor
A new instance of ExtensionMailerGenerator.
- #manifest ⇒ Object
- #rspec_manifest ⇒ Object
Constructor Details
#initialize(runtime_args, runtime_options = {}) ⇒ ExtensionMailerGenerator
Returns a new instance of ExtensionMailerGenerator.
8 9 10 11 12 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 8 def initialize(runtime_args, = {}) runtime_args = runtime_args.dup @extension_name = runtime_args.shift super(runtime_args, ) end |
Instance Attribute Details
#extension_name ⇒ Object
Returns the value of attribute extension_name.
5 6 7 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 5 def extension_name @extension_name end |
Instance Method Details
#add_options!(opt) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 61 def (opt) opt.separator '' opt.separator 'Options:' opt.on("--with-test-unit", "Use Test::Unit tests instead sof RSpec.") { |v| [:with_test_unit] = v } end |
#banner ⇒ Object
45 46 47 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 45 def "Usage: #{$0} #{spec.name} ExtensionName #{spec.name.camelize}Name [options]" end |
#destination_root ⇒ Object
53 54 55 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 53 def destination_root File.join(Rails.root, extension_path) end |
#extension_path ⇒ Object
49 50 51 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 49 def extension_path File.join('vendor', 'extensions', @extension_name.underscore) end |
#extension_uses_rspec? ⇒ Boolean
57 58 59 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 57 def extension_uses_rspec? File.exist?(File.join(destination_root, 'spec')) && ![:with_test_unit] end |
#manifest ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 14 def manifest if extension_uses_rspec? rspec_manifest else super end end |
#rspec_manifest ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/extension_mailer/extension_mailer_generator.rb', line 22 def rspec_manifest record do |m| # Check for class naming collisions. m.class_collisions class_path, class_name # Mailer, view, test, and fixture directories. m.directory File.join('app/models', class_path) m.directory File.join('app/views', file_path) # Mailer class and unit test. m.template "mailer:mailer.rb", File.join('app/models', class_path, "#{file_name}.rb") # View template and fixture for each action. actions.each do |action| relative_path = File.join(file_path, action) view_path = File.join('app/views', "#{relative_path}.erb") m.template "mailer:view.erb", view_path, :assigns => { :action => action, :path => view_path } end end end |