Sha256: 086eaa0fd40ba6efff743901c89fab433eb20b6aac76d312bd6e231296c9dc6c
Contents?: true
Size: 1.11 KB
Versions: 28
Compression:
Stored size: 1.11 KB
Contents
require 'rails/generators' module Mapfish module Generators class ViewerGenerator < Rails::Generators::Base class_option "name", :type => :string, :required => true class_option "repo", :type => :string, :required => true source_root File.expand_path("../templates", __FILE__) def clone_viewer @viewer = options["name"] puts "Cloning viewer..." dir = Dir.mktmpdir begin git :clone => "--depth=1 #{options['repo']} #{dir}" Dir.glob("#{dir}/*").each do |fn| if File.directory?(fn) name = File.basename(fn).sub(/.+?(build)?$/, "#{@viewer}\\1") puts "Copy viewer to 'public/apps/#{name}/..." directory fn, "public/apps/#{name}", :verbose => false end end ensure FileUtils.rm_rf dir end end def generate_viewer_html @viewer = options["name"] dest = "app/views/apps/#{@viewer}.html.erb" template "viewer.html.erb", dest puts "Please adapt javascript and css references in '#{dest}'" end end end end
Version data entries
28 entries across 28 versions & 1 rubygems