Module: Nomono::GemfileDsl
- Defined in:
- lib/nomono/dsl.rb
Instance Method Summary collapse
-
#eval_nomono_gems(gems:, requirements: {}, **opts) ⇒ Object
Requirements are caller facts, not checkout versions.
-
#nomono_gems(gems:, **opts) ⇒ Object
Instance Method Details
#eval_nomono_gems(gems:, requirements: {}, **opts) ⇒ Object
Requirements are caller facts, not checkout versions. An existing direct
dependency keeps its constraints and metadata; explicit facts only narrow
them. A new dependency with no facts retains Bundler’s default >= 0.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/nomono/dsl.rb', line 41 def eval_nomono_gems(gems:, requirements: {}, **opts) # Bundler's plugin scan evaluates the whole Gemfile with a plugins-only # DSL: some Bundlers undef gem and gemspec, newer ones define gem as an # explicit no-op. Either way no dependency is collected, so there is no # declaration graph to override here. return if respond_to?(:dependencies) && nomono_plugin_scan_dsl? nomono_gems(gems: gems, **opts).each do |gem_name, gem_path| # Keep lightweight non-Bundler consumers of the macro working too. unless respond_to?(:dependencies) gem(gem_name, *Array(requirements[gem_name]), path: gem_path) next end constraints = Array(requirements[gem_name]) + nomono_gemspec_requirements(gem_name) current = dependencies.find { |dep| dep.name == gem_name } if current local_source = path(gem_path) {} replacement = nomono_local_dependency(current, local_source, gem_path, constraints) dependencies[dependencies.index(current)] = replacement else gem(gem_name, *Array(requirements[gem_name]), path: gem_path) replacement = dependencies.last # A plugins-only DSL silently drops the declaration; nothing was # collected, so there is no override to register. next unless replacement && replacement.name == gem_name end @nomono_overrides ||= {} previous = @nomono_overrides[gem_name] @nomono_overrides[gem_name] = { source: replacement.source, path: gem_path, declaration: previous ? previous[:declaration] : !current.nil? } singleton_class.prepend(LocalDeclarations) unless singleton_class < LocalDeclarations end end |