Sha256: 860b8c621e44a6bf60e671e388e1162b8e49f814fdd31a3694d5c94685a2d596

Contents?: true

Size: 999 Bytes

Versions: 4

Compression:

Stored size: 999 Bytes

Contents

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

      desc "Creates a Roboto locale files to your application."

      def copy_locale
        empty_directory "config/robots"
        env_list = Dir.glob("#{destination_root}/config/environments/*")
        env_list.each do |env_file|
          env_name = File.basename(env_file, ".rb")
          unless (env_name == "production" &&  FileTest.exists?("public/robots.txt"))
            copy_file "robots.txt", "config/robots/#{env_name}.txt"
          end
        end
        if FileTest.exists?("public/robots.txt")
         copy_file File.join(destination_root + "/public/robots.txt"), "config/robots/production.txt"
         remove_file "public/robots.txt"
        end
      end

      def add_roboto_route
        route "mount_roboto"
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
roboto-1.0.1 lib/generators/roboto/install_generator.rb
roboto-1.0.0 lib/generators/roboto/install_generator.rb
roboto-0.2.0 lib/generators/roboto/install_generator.rb
roboto-0.1.0 lib/generators/roboto/install_generator.rb