Module: Bundler::Inject::DslPatch
- Defined in:
- lib/bundler/inject/dsl_patch.rb
Instance Method Summary collapse
- #ensure_gem(name, *args) ⇒ Object
- #override_gem(name, *args) ⇒ Object
- #to_definition(lockfile, unlock) ⇒ Object
Instance Method Details
#ensure_gem(name, *args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bundler/inject/dsl_patch.rb', line 17 def ensure_gem(name, *args) current = find_dependency(name) if !current gem(name, *args) else version, opts = extract_version_opts(args) version = [">= 0"] if version.empty? if opts.any? || (version != [">= 0"] && Gem::Requirement.new(version) != current.requirement) override_gem(name, *args) end end end |
#override_gem(name, *args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bundler/inject/dsl_patch.rb', line 4 def override_gem(name, *args) raise "Trying to override unknown gem #{name.inspect}" unless (dependency = find_dependency(name.to_s)) calling_loc = caller_locations.detect { |loc| !loc.path.include?("lib/bundler") } calling_file = "#{calling_loc.path}:#{calling_loc.lineno}" remove_dependencies_and_sources(dependency) (name, args, calling_file) gem(name, *args).tap do warn_override_gem(calling_file, name, args) end end |
#to_definition(lockfile, unlock) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bundler/inject/dsl_patch.rb', line 30 def to_definition(lockfile, unlock) calling_loc = caller_locations(1, 1).first if calling_loc.path.include?("bundler/dsl.rb") && calling_loc.base_label == "evaluate" load_global_bundler_d # @gemfiles doesn't exist on Bundler <= 1.15, and we can't get at @gemfile # by this point, but there's a high probability it's just "Gemfile", # or slightly more accurately, the lockfile name without the ".lock" bit. targets = defined?(@gemfiles) ? @gemfiles : [Pathname.new(lockfile.to_s.chomp(".lock"))] targets.reverse_each do |gemfile| load_local_bundler_d(File.dirname(gemfile)) end end super end |