Sha256: 7f8d5b2fb272f93e1872f521702b0bda209e6d999bee0ffca0c74ca10b536c07

Contents?: true

Size: 1.29 KB

Versions: 1

Compression:

Stored size: 1.29 KB

Contents

module Gmaps4rails
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path('../../templates', __FILE__)

      desc 'Creates a Gmaps4rails initializer and copies the assets to the public folder.'

      def copy_locale
        if Gmaps4rails.pipeline_enabled?
          directory assets_source_path, assets_destination_path
          copy_file "../../../public/stylesheets/gmaps4rails.css", "vendor/assets/stylesheets/gmaps4rails.css"
        else
          %w( base google openlayers all ).each do |filename|
            copy_file js_source_path(filename), js_destination_path(filename)
          end
          copy_file "../../../public/stylesheets/gmaps4rails.css", "public/stylesheets/gmaps4rails.css"
        end
      end

      def show_readme
        readme 'README' if behavior == :invoke
      end

      private

      def assets_source_path
        '../../../vendor/assets/javascripts/gmaps4rails/'
      end
      
      def assets_destination_path
        'vendor/assets/javascripts/gmaps4rails'
      end
      
      def js_source_path(filename)
        "../../../public/javascripts/gmaps4rails/#{filename}.js"
      end
      
      def js_destination_path(filename)
        "public/javascripts/gmaps4rails/#{filename}.js"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gmaps4rails-2.0.0.pre lib/generators/gmaps4rails/install_generator.rb