Class: Bundler::Dsl

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/eval_gemfile.rb,
lib/bundler/component.rb

Instance Method Summary collapse

Instance Method Details

#component(name, namespace: "engines") ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bundler/component.rb', line 6

def component(name, namespace: "engines")
  Dir.chdir(__dir__) do
    component_group = name.to_sym
    group :default, component_group do
      gem name, path: "#{namespace}/#{name}"

      if File.readable?("#{namespace}/#{name}/Gemfile.runtime")
        eval_gemfile "#{namespace}/#{name}/Gemfile.runtime"
      end
    end

    group component_group do
      expanded_spec_path = Pathname.new("#{namespace}/#{name}/#{name}.gemspec").expand_path(@gemfile&.parent)

      spec = Gem::Specification.load(expanded_spec_path.to_s)

      spec.dependencies.select { |s| s.type == :development }.each do |dep|
        current = @dependencies.find { |current_dep| current_dep.name == dep.name }

        if current
          next if current.source.is_a?(Bundler::Source::Path)
        end

        gem dep.name, *dep.requirement.to_s.split(/,\s*/)
      end
    end
  end
end

#eval_gemfile(gemfile, contents = nil) ⇒ Object



6
7
8
9
10
11
# File 'lib/bundler/eval_gemfile.rb', line 6

def eval_gemfile(gemfile, contents = nil)
  expanded_gemfile_path = Pathname.new(gemfile).expand_path(@gemfile&.parent)
  return if @gemfiles.any? { |path| path == expanded_gemfile_path }

  eval_gemfile_original(gemfile, contents)
end

#eval_gemfile_originalObject



4
# File 'lib/bundler/eval_gemfile.rb', line 4

alias eval_gemfile_original eval_gemfile