Class: Gaku::DockerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/gaku/docker/docker_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_pathsObject



13
14
15
16
17
18
19
# File 'lib/generators/gaku/docker/docker_generator.rb', line 13

def self.source_paths
  paths = superclass.source_paths
  paths << File.expand_path('../templates', "../../#{__FILE__}")
  paths << File.expand_path('../templates', "../#{__FILE__}")
  paths << File.expand_path('../templates', __FILE__)
  paths.flatten
end

Instance Method Details

#add_routeObject



30
31
32
# File 'lib/generators/gaku/docker/docker_generator.rb', line 30

def add_route
  route "mount Gaku::Core::Engine, at: '/'"
end

#copy_database_ymlObject



21
22
23
# File 'lib/generators/gaku/docker/docker_generator.rb', line 21

def copy_database_yml
  copy_file 'config/database.yml', 'config/database.yml'
end

#copy_wait_binObject



25
26
27
28
# File 'lib/generators/gaku/docker/docker_generator.rb', line 25

def copy_wait_bin
  copy_file 'bin/check_postgres.sh', 'bin/check_postgres.sh'
  chmod "bin/check_postgres.sh", 0755
end

#install_migrationsObject



34
35
36
37
# File 'lib/generators/gaku/docker/docker_generator.rb', line 34

def install_migrations
  say_status :copying, 'migrations'
  rake 'gaku:install:migrations'
end

#setup_assetsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/generators/gaku/docker/docker_generator.rb', line 39

def setup_assets
  @lib_name = 'gaku'
  %w( javascripts stylesheets images ).each do |path|
    empty_directory "app/assets/#{path}/gaku/frontend" if defined? Gaku::Frontend || Rails.env.test?
    empty_directory "app/assets/#{path}/gaku/admin" if defined? Gaku::Admin || Rails.env.test?
  end

  if defined? Gaku::Frontend || Rails.env.test?
    template 'app/assets/javascripts/gaku/frontend/all.js'
    template 'app/assets/stylesheets/gaku/frontend/all.css'
  end

  if defined? Gaku::Admin || Rails.env.test?
    template 'app/assets/javascripts/gaku/admin/all.js'
    template 'app/assets/stylesheets/gaku/admin/all.css'
  end
end