gem"rspec",group::testgem"technoweenie-restful-authentication",lib:"restful-authentication",source:"http://gems.github.com/"gem"rails","3.0",git:"https://github.com/rails/rails"gem"RedCloth",">= 4.1.0","< 4.2.0"gem"rspec",comment:"Put this comment above the gem declaration"
# File railties/lib/rails/generators/actions.rb, line 22
def gem(*args)
options = args.extract_options!
name, *versions = args
# Set the message to be shown in logs. Uses the git repo if one is given,
# otherwise use name (version).
parts, message = [ quote(name) ], name.dup
# Output a comment above the gem declaration.
comment = options.delete(:comment)
if versions = versions.any? ? versions : options.delete(:version)
_versions = Array(versions)
_versions.each do |version|
parts << quote(version)
end
message << " (#{_versions.join(", ")})"
end
message = options[:git] if options[:git]
log :gemfile, message
parts << quote(options) unless options.empty?
in_root do
str = []
if comment
comment.each_line do |comment_line|
str << indentation
str << "# #{comment_line}"
end
str << "\n"
end
str << indentation
str << "gem #{parts.join(", ")}"
append_file_with_newline "Gemfile", str.join, verbose: false
end
end