mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Factor out AppBase::GemfileEntry#to_s
This commit is contained in:
parent
9dcdeb5c04
commit
a08a0960de
5 changed files with 15 additions and 26 deletions
|
@ -268,6 +268,13 @@ module Rails
|
|||
version
|
||||
end
|
||||
end
|
||||
|
||||
def to_s
|
||||
[ ("# #{comment}\n" if comment),
|
||||
("# " if commented_out), "gem \"#{name}\"", (", \"#{version}\"" if version),
|
||||
*options.map { |key, val| ", #{key}: #{val.inspect}" }
|
||||
].compact.join
|
||||
end
|
||||
end
|
||||
|
||||
def rails_prerelease?
|
||||
|
|
|
@ -2,14 +2,10 @@ source "https://rubygems.org"
|
|||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||
|
||||
ruby <%= "\"#{RUBY_VERSION}\"" -%>
|
||||
<% gemfile_entries.each do |gem| -%>
|
||||
<% if gem.comment %>
|
||||
|
||||
# <%= gem.comment %>
|
||||
<% gemfile_entries.each do |gemfile_entry| %>
|
||||
<%= gemfile_entry %>
|
||||
<% end -%>
|
||||
<%= gem.commented_out ? "# " : "" %>gem "<%= gem.name %>"<%= %(, "#{gem.version}") if gem.version -%>
|
||||
<% if gem.options.any? -%>, <%= gem.options.map { |k,v| "#{k}: #{v.inspect}" }.join(", ") %><% end -%>
|
||||
<% end %>
|
||||
<% unless options.minimal? -%>
|
||||
|
||||
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
|
||||
|
|
|
@ -17,17 +17,8 @@ end
|
|||
<% if rails_prerelease? -%>
|
||||
# Your gem is dependent on a prerelease version of Rails. Once you can lock this
|
||||
# dependency down to a specific version, move it to your gemspec.
|
||||
<% max_width = gemfile_entries.map { |g| g.name.length }.max -%>
|
||||
<% gemfile_entries.each do |gem| -%>
|
||||
<% if gem.comment -%>
|
||||
|
||||
# <%= gem.comment %>
|
||||
<% end -%>
|
||||
<%= gem.commented_out ? "# " : "" %>gem "<%= gem.name %>"<%= %(, "#{gem.version}") if gem.version -%>
|
||||
<% if gem.options.any? -%>
|
||||
, <%= gem.options.map { |k,v|
|
||||
"#{k}: #{v.inspect}" }.join(", ") %>
|
||||
<% end -%>
|
||||
<% gemfile_entries.each do |gemfile_entry| -%>
|
||||
<%= gemfile_entry %>
|
||||
<% end -%>
|
||||
|
||||
<% end -%>
|
||||
|
|
|
@ -11,9 +11,10 @@ module Rails
|
|||
include GeneratorsTestHelper
|
||||
|
||||
setup do
|
||||
copy_gemfile(
|
||||
GemfileEntry.new("sqlite3", nil, "Use sqlite3 as the database for Active Record")
|
||||
)
|
||||
copy_gemfile <<~ENTRY
|
||||
# Use sqlite3 as the database for Active Record
|
||||
gem 'sqlite3'
|
||||
ENTRY
|
||||
end
|
||||
|
||||
test "change to invalid database" do
|
||||
|
|
|
@ -20,12 +20,6 @@ module GeneratorsTestHelper
|
|||
include ActiveSupport::Testing::Stream
|
||||
include ActiveSupport::Testing::MethodCallAssertions
|
||||
|
||||
GemfileEntry = Struct.new(:name, :version, :comment, :options, :commented_out) do
|
||||
def initialize(name, version, comment, options = {}, commented_out = false)
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
def self.included(base)
|
||||
base.class_eval do
|
||||
destination File.expand_path("../fixtures/tmp", __dir__)
|
||||
|
|
Loading…
Reference in a new issue