Class: Mastiff::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/mastiff/install/install_generator.rb

Overview

class UploaderGenerator < Rails::Generators::NamedBase

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



24
25
26
# File 'lib/generators/mastiff/install/install_generator.rb', line 24

def copy_initializer
  template "mastiff.rb", "config/initializers/mastiff.rb"
end

#copy_uploadersObject



49
50
51
52
53
54
55
# File 'lib/generators/mastiff/install/install_generator.rb', line 49

def copy_uploaders
  empty_directory "app/uploaders"
  # In future check param for other file upload/storage integration
  if true
    template "carrierwave/mail_attachment_uploader.rb", "app/uploaders/mail_attachment_uploader.rb"
  end
end

#copy_workersObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/generators/mastiff/install/install_generator.rb', line 29

def copy_workers
  # In future check param for other async processing integrations
  if true
    unless File.exist?('config/sidekiq.yml')
      template "sidekiq/sidekiq.yml", "config/sidekiq.yml"
    else
      append_file 'config/sidekiq.yml' do
        ':concurrency: 50'
        ':queues:'
        '  - default'
        '  - email_queue'
      end

    end
    empty_directory "app/workers"
    template "sidekiq/sync_mail_worker.rb",           "app/workers/sync_mail_worker.rb"
    template "sidekiq/sync_attachment_worker.rb",     "app/workers/sync_attachment_worker.rb"
    template "sidekiq/process_attachment_worker.rb",  "app/workers/process_attachment_worker.rb"
  end
end

#create_data_directoryObject



57
58
59
# File 'lib/generators/mastiff/install/install_generator.rb', line 57

def create_data_directory
   empty_directory "data/attachments/pending"
end