Sha256: 6fff4363848fb670d3f56ff14df101236e13f1a713e5465a4979010ef9927bf9

Contents?: true

Size: 784 Bytes

Versions: 18

Compression:

Stored size: 784 Bytes

Contents

require 'rails/generators/base'

module Clearance
  module Generators
    class ViewsGenerator < Rails::Generators::Base
      source_root Clearance.root

      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

18 entries across 18 versions & 1 rubygems

Version Path
clearance-1.6.1 lib/generators/clearance/views/views_generator.rb
clearance-1.6.0 lib/generators/clearance/views/views_generator.rb
clearance-1.5.1 lib/generators/clearance/views/views_generator.rb
clearance-1.5.0 lib/generators/clearance/views/views_generator.rb
clearance-1.4.3 lib/generators/clearance/views/views_generator.rb
clearance-1.4.2 lib/generators/clearance/views/views_generator.rb
clearance-1.4.1 lib/generators/clearance/views/views_generator.rb
clearance-1.4.0 lib/generators/clearance/views/views_generator.rb
clearance-1.3.0 lib/generators/clearance/views/views_generator.rb
clearance-1.2.1 lib/generators/clearance/views/views_generator.rb
clearance-1.2.0 lib/generators/clearance/views/views_generator.rb
clearance-1.1.0 lib/generators/clearance/views/views_generator.rb
clearance-1.0.1 lib/generators/clearance/views/views_generator.rb
clearance-1.0.0 lib/generators/clearance/views/views_generator.rb
clearance-1.0.0.rc8 lib/generators/clearance/views/views_generator.rb
clearance-1.0.0.rc7 lib/generators/clearance/views/views_generator.rb
clearance-1.0.0.rc6 lib/generators/clearance/views/views_generator.rb
clearance-1.0.0.rc4 lib/generators/clearance/views/views_generator.rb