Class: Mapfish::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Mapfish::Generators::InstallGenerator
- Defined in:
- lib/generators/mapfish/install/install_generator.rb
Instance Method Summary collapse
- #add_environment_config ⇒ Object
- #add_geodatabase_config ⇒ Object
- #add_mapfish_initializer ⇒ Object
- #add_query_header_template ⇒ Object
- #add_search_rules_initializer ⇒ Object
- #copy_map_templates ⇒ Object
- #copy_print_configs ⇒ Object
- #install_migrations ⇒ Object
- #rm_application_controller ⇒ Object
- #run_migrations ⇒ Object
- #seed_database ⇒ Object
- #setup_mapconfig ⇒ Object
Instance Method Details
#add_environment_config ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 73 def add_environment_config env_config = %Q{ #Parts for building a Mapserver URL # Example: http://localhost/cgi-bin/mapserv.fcgi?map=#{Rails.root}/mapconfig/#{["default-site-name"]}/naturalearth.map) MAPSERV_SERVER = 'http://localhost' #nil for current application server MAPSERV_URL = '/cgi-bin/mapserv' MAPSERV_CGI_URL = '/cgi-bin/mapserv' MAPPATH = '#{Rails.root}/mapconfig' #Internal URL of print servlet (nil: print-standalone) PRINT_URL = nil #'http://localhost:8080/mapfish_print/print/myapp' #path to standalone Mapfish Print JARs (if PRINT_URL = nil) # PRINT_STANDALONE_JARS = '$PATH_TO/mapfish-print/core/lib/*' } %w[development test production].each do |env| append_to_file("config/environments/#{env}.rb", env_config) end end |
#add_geodatabase_config ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 10 def add_geodatabase_config path = "#{Rails.root}/config/geodatabase.yml" if File.exists?(path) puts "Skipping config/geodatabase.yml creation, as file already exists!" else puts "Adding sample geodatabase config (config/geodatabase.yml)..." template "geodatabase.yml", path end end |
#add_mapfish_initializer ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 49 def add_mapfish_initializer path = "#{Rails.root}/config/initializers/mapfish.rb" if File.exists?(path) puts "Skipping config/initializers/mapfish.rb creation, as file already exists!" else puts "Adding mapfish initializer (config/initializers/mapfish.rb)..." template "initializer.rb", path end end |
#add_query_header_template ⇒ Object
105 106 107 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 105 def add_query_header_template create_file "app/views/topisc/_query_header.html.erb", "" end |
#add_search_rules_initializer ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 59 def add_search_rules_initializer path = "#{Rails.root}/config/initializers/search_rules.rb" if File.exists?(path) puts "Skipping config/initializers/search_rules.rb creation, as file already exists!" else puts "Adding search_rules initializer (config/initializers/search_rules.rb)..." template "search_rules.rb", path end end |
#copy_map_templates ⇒ Object
100 101 102 103 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 100 def copy_map_templates puts "Copying templates for map import..." directory "../../../../../lib/tasks/templates", "lib/tasks/templates", :verbose => false end |
#copy_print_configs ⇒ Object
92 93 94 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 92 def copy_print_configs directory "print", "print" end |
#install_migrations ⇒ Object
20 21 22 23 24 25 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 20 def install_migrations puts "Copying over migrations..." Dir.chdir(Rails.root) do `rake mapfish:install:migrations` end end |
#rm_application_controller ⇒ Object
69 70 71 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 69 def rm_application_controller remove_file "#{Rails.root}/app/controllers/application_controller.rb" end |
#run_migrations ⇒ Object
27 28 29 30 31 32 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 27 def run_migrations unless ["no-migrate"] puts "Running rake db:migrate" `rake db:migrate` end end |
#seed_database ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 34 def seed_database unless ["no-migrate"] puts "Creating admin user and default site" ENV['DEFAULT_SITE'] = ["default-site-name"] ENV['ADMIN_PWD'] = SecureRandom.hex(4) begin GbMapfishAppserver::Engine.load_seed puts "Generated user for administraton" puts "User: 'admin' - Password: '#{ENV['ADMIN_PWD']}'" rescue puts "Couldn't load seed data - already done?" end end end |
#setup_mapconfig ⇒ Object
96 97 98 |
# File 'lib/generators/mapfish/install/install_generator.rb', line 96 def setup_mapconfig empty_directory "mapconfig/#{["default-site-name"]}" end |