Sha256: 95a53e2d595c8a09a0da52f2df5b303b281c6bc21c3a41e9f2977fa122539806
Contents?: true
Size: 1.55 KB
Versions: 6
Compression:
Stored size: 1.55 KB
Contents
module ActionWidget module Extensions module Rails module Generators class Base < ::Rails::Generators::Base def self.namespace(name=nil) super.sub(/extensions:rails:/, '') end end class Widget < Base source_root File.expand_path('../../../../../support/templates', __FILE__) argument :widget_name, :type => :string class_option :rspec, :type => :boolean, :default => true, :description => "Generates rspec file" def generate_widget_implementation_file template('widget.rb.erb', "app/widgets/#{widget_implementation_filename}") end def generate_widget_spec_file if defined?(::RSpec) && options.rspec? template('widget_spec.rb.erb', "spec/widgets/#{widget_spec_filename}") end end private def widget_spec_filename "#{widget_helper_name}_spec.rb" end def widget_implementation_filename "#{widget_helper_name}.rb" end def widget_class_name name = /[Ww]idget$/.match(widget_name) ? widget_name : "#{widget_name}Widget" name = name.titleize name = name.gsub(" ", '') name = name.gsub("/", '::') name end def widget_helper_name widget_class_name.underscore end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems