Class: Heya::CampaignGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Heya::CampaignGenerator
- Defined in:
- lib/generators/heya/campaign/campaign_generator.rb
Instance Method Summary collapse
Instance Method Details
#copy_campaign_template ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/generators/heya/campaign/campaign_generator.rb', line 10 def copy_campaign_template application_campaign = "app/campaigns/application_campaign.rb" unless File.exist?(application_campaign) template File.("../install/templates/application_campaign.rb", __dir__), application_campaign end template "campaign.rb", "app/campaigns/#{file_name.underscore}_campaign.rb" end |
#copy_test_templates ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/generators/heya/campaign/campaign_generator.rb', line 51 def copy_test_templates return if skip_previews? if preview_path template "preview.rb", preview_path.join("#{file_name.underscore}_campaign_preview.rb") end end |
#copy_view_templates ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/heya/campaign/campaign_generator.rb', line 18 def copy_view_templates return if skip_views? selection = if defined?(Maildown) puts <<~MSG What type of views would you like to generate? 1. Multipart (text/html) 2. Maildown (markdown) MSG ask(">") else "1" end template_method = case selection when "1" method(:action_mailer_template) when "2" method(:maildown_template) else abort "Error: must be a number [1-2]" end steps.each do |step| step, _wait = step.split(":") @step = step template_method.call(step) end end |