Class: Heya::CampaignGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/heya/campaign/campaign_generator.rb

Instance Method Summary collapse

Instance Method Details

#copy_campaign_templateObject



8
9
10
11
12
13
14
# File 'lib/generators/heya/campaign/campaign_generator.rb', line 8

def copy_campaign_template
  application_campaign = "app/campaigns/application_campaign.rb"
  unless File.exist?(application_campaign)
    template File.expand_path("../install/templates/application_campaign.rb", __dir__), application_campaign
  end
  template "campaign.rb", "app/campaigns/#{file_name.underscore}_campaign.rb"
end

#copy_test_templatesObject



47
48
49
50
51
# File 'lib/generators/heya/campaign/campaign_generator.rb', line 47

def copy_test_templates
  if preview_path
    template "preview.rb", preview_path.join("#{file_name.underscore}_campaign_preview.rb")
  end
end

#copy_view_templatesObject



16
17
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
# File 'lib/generators/heya/campaign/campaign_generator.rb', line 16

def copy_view_templates
  selection =
    if defined?(Maildown)
      puts "        What type of views would you like to generate?\n          1. Multipart (text/html)\n          2. Maildown (markdown)\n      MSG\n\n      ask(\">\")\n    else\n      \"1\"\n    end\n\n  template_method =\n    case selection\n    when \"1\"\n      method(:action_mailer_template)\n    when \"2\"\n      method(:maildown_template)\n    else\n      abort \"Error: must be a number [1-2]\"\n    end\n\n  steps.each do |step|\n    step, _wait = step.split(\":\")\n    @step = step\n    template_method.call(step)\n  end\nend\n"