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

Version Path
gb_mapfish_appserver-2.0.0 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.1.1 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.1.0 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.0.6 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.0.5 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.0.4 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.0.3 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.0.2 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.0.1 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-1.0.0 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.7 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.6 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.5 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.4 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.3 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.2 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.1 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.9.0 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.8.7 lib/generators/mapfish/viewer/viewer_generator.rb
gb_mapfish_appserver-0.8.6 lib/generators/mapfish/viewer/viewer_generator.rb