Module: Rwm::GemfileDsl

Defined in:
lib/rwm/gemfile.rb

Instance Method Summary collapse

Instance Method Details

#rwm_lib(name, **opts) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rwm/gemfile.rb', line 51

def rwm_lib(name, **opts)
  name = name.to_s
  @rwm_resolved ||= Set.new
  return if @rwm_resolved.include?(name)

  path = File.join(rwm_workspace_root, "libs", name)

  unless File.directory?(path)
    raise "rwm_lib '#{name}': no library found at libs/#{name}. " \
          "Libraries must live in libs/. Create one with: rwm new lib #{name}"
  end

  @rwm_resolved.add(name)
  Rwm.resolved_libs.add(name) unless @rwm_scanning

  gem(name, **opts, path: path)

  # Resolve transitive workspace deps from the target lib's Gemfile
  target_gemfile = File.join(path, "Gemfile")
  return unless File.exist?(target_gemfile)

  scan_transitive_deps(target_gemfile).each { |dep_name| rwm_lib(dep_name) }
end

#rwm_workspace_rootObject



41
42
43
44
45
46
47
48
49
# File 'lib/rwm/gemfile.rb', line 41

def rwm_workspace_root
  @rwm_workspace_root ||= begin
    out, _, status = Open3.capture3("git", "rev-parse", "--show-toplevel")
    root = status.success? ? out.strip : ""
    raise "rwm: not inside a git repository" if root.empty?
    Rwm.workspace_root ||= root
    root
  end
end