Sha256: 487777422dd794d0e776e12044852bf39ca4b87d54149a735d3541eb3d1ef362
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
class EventMachineGenerator < Rails::Generator::NamedBase def initialize(runtime_args, runtime_options = {}) super @event_name = runtime_args.shift @controller_name = runtime_args.shift @controller_action = runtime_args.shift unless valid_options? puts "Invalid arguments!" puts banner exit end end def manifest record do |m| m.directory "app/events" m.directory "test/functional/events" m.template "event.rb", File.join('app/events', "#{@event_name}Event".underscore + ".rb"), :assigns => { :controller => @controller_name, :action => @controller_action } m.template "functional_test.rb", File.join('test/functional/events', "#{@event_name}Event".underscore + "_test.rb"), :assigns => { :controller => @controller_name, :action => @controller_action, :event => "#{@event_name}Event" } end end def banner "Usage: #{$0} event EventName Controller Action" "Example: #{$0} event media_rated Admin::ContentController rate" end private def valid_options? [@event_name, @controller_name, @controller_action].all? { |v| !v.blank? } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
event_machine-0.2.0 | generators/event_machine/event_machine_generator.rb |