Example

# File railties/lib/rails/generators/actions.rb, line 52def gem(*args)options=args.extract_options!name,version=args# Deal with deprecated options{:env=>:group,:only=>:group,:lib=>:require,:require_as=>:require}.eachdo|old,new|nextunlessoptions[old]options[new]=options.delete(old)ActiveSupport::Deprecation.warn"#{old.inspect} option in gem is deprecated, use #{new.inspect} instead"end# Deal with deprecated sourceifsource=options.delete(:source)ActiveSupport::Deprecation.warn":source option in gem is deprecated, use add_source method instead"add_source(source)end# Set the message to be shown in logs. Uses the git repo if one is given,# otherwise use name (version).parts,message=[name.inspect],nameifversion||=options.delete(:version)parts<<version.inspectmessage<<" (#{version})"endmessage=options[:git]ifoptions[:git]log:gemfile,messageoptions.eachdo|option,value|parts<<":#{option} => #{value.inspect}"endin_rootdoappend_file"Gemfile","gem #{parts.join(", ")}\n",:verbose=>falseendend