Class: Quorum::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Helpers::Colors
Defined in:
lib/generators/quorum/install_generator.rb

Constant Summary collapse

DEPENDENCIES =
["makeblastdb", "seqret"]

Instance Method Summary collapse

Methods included from Helpers::Colors

#blue, #bold, #color, #green, #grey, #magenta, #red, #white, #yellow

Instance Method Details

#add_mount_engineObject



58
59
60
# File 'lib/generators/quorum/install_generator.rb', line 58

def add_mount_engine
  route @quorum unless mount_engine_exists?
end

#add_resque_mount_engineObject



66
67
68
# File 'lib/generators/quorum/install_generator.rb', line 66

def add_resque_mount_engine
  route @resque unless resque_mount_engine_exists?
end

#change_file_permissionsObject



30
31
32
33
34
# File 'lib/generators/quorum/install_generator.rb', line 30

def change_file_permissions
  Dir.glob(File.join("quorum", "bin", "*")).each do |f|
    File.new(f, "r").chmod(0755)
  end
end

#check_dependenciesObject



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/generators/quorum/install_generator.rb', line 70

def check_dependencies
  puts ""
  puts "Checking Quorum system dependencies..."
  messages = []
  DEPENDENCIES.each do |b|
    system("which #{b} > /dev/null 2>&1")
    messages << b if $?.exitstatus > 0
  end
  unless messages.empty?
    puts bold(
      red("*** Warning: Quorum system dependencies not found ***")
    )
    puts bold(
      red("Please add the below to your PATH.")
    )
    messages.each { |m| puts bold(red(m)) }
  else
    puts "All good! Yay!!"
  end
end

#copy_localeObject



26
27
28
# File 'lib/generators/quorum/install_generator.rb', line 26

def copy_locale
  copy_file "../../../config/locales/en.yml", "config/locales/quorum.en.yml"
end

#copy_quorumObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/quorum/install_generator.rb', line 14

def copy_quorum
  template "quorum_initializer.rb",
    "config/initializers/quorum_initializer.rb"
  template "quorum_settings.yml", "config/quorum_settings.yml"
  template "search", "quorum/bin/search"
  template "fetch", "quorum/bin/fetch"
  template "trollop.rb", "quorum/lib/trollop.rb"
  template "logger.rb", "quorum/lib/logger.rb"
  template "blast.rb", "quorum/lib/search_tools/blast.rb"
  template "blast_db.rb", "quorum/lib/fetch_tools/blast_db.rb"
end

#create_quorum_log_dirObject



40
41
42
# File 'lib/generators/quorum/install_generator.rb', line 40

def create_quorum_log_dir
  Dir.mkdir("quorum/log") unless File.directory?("quorum/log")
end

#create_quorum_tmp_dirObject



36
37
38
# File 'lib/generators/quorum/install_generator.rb', line 36

def create_quorum_tmp_dir
  Dir.mkdir("quorum/tmp") unless File.directory?("quorum/tmp")
end

#mount_engine_exists?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/generators/quorum/install_generator.rb', line 54

def mount_engine_exists?
  @routes.include?(@quorum)
end

#read_routes_fileObject



49
50
51
52
# File 'lib/generators/quorum/install_generator.rb', line 49

def read_routes_file
  @routes = File.open(File.join("config", "routes.rb"), "r")
  @routes = @routes.read
end

#resque_mount_engine_exists?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/generators/quorum/install_generator.rb', line 62

def resque_mount_engine_exists?
  @routes.include?(@resque)
end

#set_mount_enginesObject



44
45
46
47
# File 'lib/generators/quorum/install_generator.rb', line 44

def set_mount_engines
  @quorum = %Q(mount Quorum::Engine => "/quorum")
  @resque = %Q(mount Resque::Server.new, :at => "/quorum/resque")
end

#show_readmeObject



91
92
93
# File 'lib/generators/quorum/install_generator.rb', line 91

def show_readme
  readme "README"
end