Sha256: a859b38657316846d6a56cb554dbd7c586c5511766ed0f869b50a6b24e22bc4b

Contents?: true

Size: 1.11 KB

Versions: 27

Compression:

Stored size: 1.11 KB

Contents

require 'rails/generators/base'

module Phcmembers

	module Generators

		module ViewPathTemplates
			extend ActiveSupport::Concern

			included do
				class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (layouts, phcmembers)"

				public_task :copy_views
			end

			def copy_views
				if options[:views]
					options[:views].each do |directory|
						view_directory directory.to_sym
					end
				else
					view_directory :layouts
					view_directory :phcmembers
				end
			end

			protected

			def view_directory(name, _target_path = nil)
				directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
					content
				end
			end

			def target_path
				@target_path ||= "app/views"
			end
		end

		class SharedViewsGenerator < Rails::Generators::Base
			include ViewPathTemplates
			source_root File.expand_path("../../../../app/views", __FILE__)
			desc "Copies phcmembers views to your application."
			hide!
		end

		class ViewsGenerator < Rails::Generators::Base
			desc "Copies phcmembers views to your application."
			invoke SharedViewsGenerator
		end
	end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
phcmembers-2.2.0 lib/generators/phcmembers/views_generator.rb
phcmembers-2.1.3 lib/generators/phcmembers/views_generator.rb
phcmembers-2.1.2 lib/generators/phcmembers/views_generator.rb
phcmembers-2.1.1 lib/generators/phcmembers/views_generator.rb
phcmembers-2.1.0 lib/generators/phcmembers/views_generator.rb
phcmembers-2.0.0 lib/generators/phcmembers/views_generator.rb
phcmembers-1.9.9 lib/generators/phcmembers/views_generator.rb
phcmembers-1.9.5 lib/generators/phcmembers/views_generator.rb
phcmembers-1.9.0 lib/generators/phcmembers/views_generator.rb
phcmembers-1.8.1 lib/generators/phcmembers/views_generator.rb
phcmembers-1.8.0 lib/generators/phcmembers/views_generator.rb
phcmembers-1.7.8 lib/generators/phcmembers/views_generator.rb
phcmembers-1.7.6 lib/generators/phcmembers/views_generator.rb
phcmembers-1.7.5 lib/generators/phcmembers/views_generator.rb
phcmembers-1.7.0 lib/generators/phcmembers/views_generator.rb
phcmembers-1.6.0 lib/generators/phcmembers/views_generator.rb
phcmembers-1.5.0 lib/generators/phcmembers/views_generator.rb
phcmembers-1.0.2 lib/generators/phcmembers/views_generator.rb
phcmembers-1.0.1 lib/generators/phcmembers/views_generator.rb
phcmembers-1.0.0 lib/generators/phcmembers/views_generator.rb