Module: Homebrew::Bundle::GoDumper Private
- Defined in:
- bundle/go_dumper.rb
This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.
Class Method Summary collapse
- .dump ⇒ String private
- .packages ⇒ Array<String> private
- .reset! ⇒ void private
Class Method Details
.dump ⇒ String
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
46 47 48 |
# File 'bundle/go_dumper.rb', line 46 def self.dump packages.map { |name| "go \"#{name}\"" }.join("\n") end |
.packages ⇒ Array<String>
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'bundle/go_dumper.rb', line 13 def self.packages @packages ||= T.let(nil, T.nilable(T::Array[String])) @packages ||= if Bundle.go_installed? go = Bundle.which_go gobin = `#{go} env GOBIN`.chomp gopath = `#{go} env GOPATH`.chomp bin_dir = gobin.empty? ? "#{gopath}/bin" : gobin return [] unless File.directory?(bin_dir) binaries = Dir.glob("#{bin_dir}/*").select { |f| File.executable?(f) && !File.directory?(f) } binaries.filter_map do |binary| output = `#{go} version -m "#{binary}" 2>/dev/null` next if output.empty? # Parse the output to find the path line # Format: "\tpath\tgithub.com/user/repo" lines = output.split("\n") path_line = lines.find { |line| line.strip.start_with?("path\t") } next unless path_line # Extract the package path (second field after splitting by tab) # The line format is: "\tpath\tgithub.com/user/repo" parts = path_line.split("\t") parts[2]&.strip if parts.length >= 3 end.compact.uniq else [] end end |
.reset! ⇒ void
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
This method returns an undefined value.
8 9 10 |
# File 'bundle/go_dumper.rb', line 8 def self.reset! @packages = nil end |