Sha256: f9e65e7e7ce58b9b9b89452355ae31701c243d254a3a1644016b40f1a50ed4f4

Contents?: true

Size: 814 Bytes

Versions: 38

Compression:

Stored size: 814 Bytes

Contents

require 'rails/generators/base'

module Clearance
  module Generators
    class ViewsGenerator < Rails::Generators::Base
      source_root File.expand_path("../../../../..", __FILE__)

      def create_views
        views.each do |view|
          copy_file view
        end
      end

      def create_locales
        locales.each do |locale|
          copy_file locale
        end
      end

      private

      def views
        files_within_root('.', 'app/views/**/*.*')
      end

      def locales
        files_within_root('.', 'config/locales/**/*.*')
      end

      def files_within_root(prefix, glob)
        root = "#{self.class.source_root}/#{prefix}"

        Dir["#{root}/#{glob}"].sort.map do |full_path|
          full_path.sub(root, '.').gsub('/./', '/')
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
clearance-2.9.3 lib/generators/clearance/views/views_generator.rb
clearance-2.9.2 lib/generators/clearance/views/views_generator.rb
clearance-2.9.1 lib/generators/clearance/views/views_generator.rb
clearance-2.9.0 lib/generators/clearance/views/views_generator.rb
clearance-2.8.0 lib/generators/clearance/views/views_generator.rb
clearance-2.7.2 lib/generators/clearance/views/views_generator.rb
clearance-2.7.0 lib/generators/clearance/views/views_generator.rb
clearance-2.6.2 lib/generators/clearance/views/views_generator.rb
clearance-2.6.1 lib/generators/clearance/views/views_generator.rb
clearance-2.6.0 lib/generators/clearance/views/views_generator.rb
clearance-2.5.0 lib/generators/clearance/views/views_generator.rb
clearance-2.4.0 lib/generators/clearance/views/views_generator.rb
clearance-2.3.1 lib/generators/clearance/views/views_generator.rb
clearance-2.3.0 lib/generators/clearance/views/views_generator.rb
clearance-2.2.1 lib/generators/clearance/views/views_generator.rb
clearance-2.2.0 lib/generators/clearance/views/views_generator.rb
clearance-2.1.0 lib/generators/clearance/views/views_generator.rb
clearance-2.0.0 lib/generators/clearance/views/views_generator.rb
clearance-2.0.0.beta2 lib/generators/clearance/views/views_generator.rb
clearance-2.0.0.beta1 lib/generators/clearance/views/views_generator.rb