Sha256: e663b0f9df0b5ffbb942580991a6e8cb4b3a4e9448d2fbb42d4f6d875d796cdc
Contents?: true
Size: 1.44 KB
Versions: 2
Compression:
Stored size: 1.44 KB
Contents
# frozen_string_literal: true class Heya::CampaignGenerator < Rails::Generators::NamedBase source_root File.expand_path("templates", __dir__) argument :steps, type: :array, default: [] def copy_campaign_template template "application_campaign.rb", "app/campaigns/application_campaign.rb" template "campaign.rb", "app/campaigns/#{file_name.underscore}_campaign.rb" end def copy_view_templates 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 = step template_method.call(step) end end private def action_mailer_template(step) template "message.text.erb", "app/views/heya/campaign_mailer/#{file_name.underscore}_campaign/#{step.underscore.to_sym}.text.erb" template "message.html.erb", "app/views/heya/campaign_mailer/#{file_name.underscore}_campaign/#{step.underscore.to_sym}.html.erb" end def maildown_template(step) template "message.md.erb", "app/views/heya/campaign_mailer/#{file_name.underscore}_campaign/#{step.underscore.to_sym}.md.erb" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
heya-0.2.0 | lib/generators/heya/campaign/campaign_generator.rb |
heya-0.1.0 | lib/generators/heya/campaign/campaign_generator.rb |