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
|
version
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
def rails_prerelease?
|
def rails_prerelease?
|
||||||
|
|
|
@ -2,14 +2,10 @@ source "https://rubygems.org"
|
||||||
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||||
|
|
||||||
ruby <%= "\"#{RUBY_VERSION}\"" -%>
|
ruby <%= "\"#{RUBY_VERSION}\"" -%>
|
||||||
<% gemfile_entries.each do |gem| -%>
|
|
||||||
<% if gem.comment %>
|
|
||||||
|
|
||||||
# <%= gem.comment %>
|
<% gemfile_entries.each do |gemfile_entry| %>
|
||||||
|
<%= gemfile_entry %>
|
||||||
<% end -%>
|
<% 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? -%>
|
<% unless options.minimal? -%>
|
||||||
|
|
||||||
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
|
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
|
||||||
|
|
|
@ -17,17 +17,8 @@ end
|
||||||
<% if rails_prerelease? -%>
|
<% if rails_prerelease? -%>
|
||||||
# Your gem is dependent on a prerelease version of Rails. Once you can lock this
|
# 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.
|
# 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 |gemfile_entry| -%>
|
||||||
<% gemfile_entries.each do |gem| -%>
|
<%= gemfile_entry %>
|
||||||
<% 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 -%>
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
|
|
|
@ -11,9 +11,10 @@ module Rails
|
||||||
include GeneratorsTestHelper
|
include GeneratorsTestHelper
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
copy_gemfile(
|
copy_gemfile <<~ENTRY
|
||||||
GemfileEntry.new("sqlite3", nil, "Use sqlite3 as the database for Active Record")
|
# Use sqlite3 as the database for Active Record
|
||||||
)
|
gem 'sqlite3'
|
||||||
|
ENTRY
|
||||||
end
|
end
|
||||||
|
|
||||||
test "change to invalid database" do
|
test "change to invalid database" do
|
||||||
|
|
|
@ -20,12 +20,6 @@ module GeneratorsTestHelper
|
||||||
include ActiveSupport::Testing::Stream
|
include ActiveSupport::Testing::Stream
|
||||||
include ActiveSupport::Testing::MethodCallAssertions
|
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)
|
def self.included(base)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
destination File.expand_path("../fixtures/tmp", __dir__)
|
destination File.expand_path("../fixtures/tmp", __dir__)
|
||||||
|
|
Loading…
Reference in a new issue