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-1.17.0 lib/generators/clearance/views/views_generator.rb
clearance-1.16.2 lib/generators/clearance/views/views_generator.rb
clearance-1.16.1 lib/generators/clearance/views/views_generator.rb
clearance-1.16.0 lib/generators/clearance/views/views_generator.rb
clearance-1.15.1 lib/generators/clearance/views/views_generator.rb
clearance-1.15.0 lib/generators/clearance/views/views_generator.rb
clearance-1.14.2 lib/generators/clearance/views/views_generator.rb
clearance-1.14.1 lib/generators/clearance/views/views_generator.rb
clearance-1.14.0 lib/generators/clearance/views/views_generator.rb
clearance-1.13.0 lib/generators/clearance/views/views_generator.rb
clearance-1.12.1 lib/generators/clearance/views/views_generator.rb
clearance-1.12.0 lib/generators/clearance/views/views_generator.rb
clearance-1.11.0 lib/generators/clearance/views/views_generator.rb
clearance-1.10.1 lib/generators/clearance/views/views_generator.rb
clearance-1.9.0 lib/generators/clearance/views/views_generator.rb
clearance-1.8.1 lib/generators/clearance/views/views_generator.rb
clearance-1.8.0 lib/generators/clearance/views/views_generator.rb
clearance-1.7.0 lib/generators/clearance/views/views_generator.rb