instance method
add_source
Ruby on Rails 5.2.8.1
Since v3.0.20Signature
add_source(source, options = {}, &block)
Add the given source to Gemfile
If block is given, gem entries in block are wrapped into the source group.
add_source "http://gems.github.com/" add_source "http://gems.github.com/" do gem "rspec-rails" end
Parameters
-
sourcereq -
optionsopt = {} -
blockblock
Source
# File railties/lib/rails/generators/actions.rb, line 78
def add_source(source, options = {}, &block)
log :source, source
in_root do
if block
append_file "Gemfile", "\nsource #{quote(source)} do", force: true
@in_group = true
instance_eval(&block)
@in_group = false
append_file "Gemfile", "\nend\n", force: true
else
prepend_file "Gemfile", "source #{quote(source)}\n", verbose: false
end
end
end
Defined in railties/lib/rails/generators/actions.rb line 78
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Generators::Actions