Sha256: aa9f7523930dbbb42bf3e60b11aa92447aa8ac6b7cb4543f3625998026ce8ab3
Contents?: true
Size: 1.81 KB
Versions: 5
Compression:
Stored size: 1.81 KB
Contents
require 'rubygems' require 'active_support/core_ext' # Description: # Generates an RTML Widget. See the Rtml::Widget class documentation for more # information. # # Example: # ./script/generate rtml_widget Thing [entry_point_1 entry_point_2] # # This will create: # lib/rtml/widgets/thing.rb # # And Test::Unit tests: # test/unit/rtml/widgets/thing_test.rb # # -or- # # RSpec and/or Cucumber tests: # spec/rtml/widgets/thing_spec.rb # features/rtml/widgets/thing.feature # class RtmlWidgetGenerator < RubiGen::Base attr_reader :name attr_reader :entry_points, :human_name, :class_name, :file_name def initialize(runtime_args, runtime_options = {}) super usage if args.empty? @name = args.shift @class_name = @name.camelize @entry_points = args.dup @entry_points << class_name.underscore.sub(/^.*\//, '') if @entry_points.empty? @file_name = class_name.underscore @human_name = file_name.humanize end def manifest record do |m| m.directory "lib/rtml/widgets" m.template 'default_widget.erb', "lib/rtml/widgets/#{file_name}.rb" if File.directory?(File.join("spec")) || File.directory?(File.join("features")) if File.directory?(File.join("spec")) m.directory "spec/rtml/widgets" m.template "default_widget_spec.erb", "spec/rtml/widgets/#{file_name}_spec.rb" end if File.directory?(File.join("features")) m.directory "features/rtml/widgets" m.template "default_widget.feature.erb", "features/rtml/widgets/#{file_name}.feature" end else # we only need unit tests neither cucumber nor rspec is available. m.directory "test/unit/rtml/widgets" m.template 'default_widget_test.erb', "test/unit/rtml/widgets/#{file_name}_test.rb" end end end end
Version data entries
5 entries across 5 versions & 1 rubygems