class Gondler::Gomfile

Attributes

packages[R]

Public Class Methods

new(path) click to toggle source
# File lib/gondler/gomfile.rb, line 5
def initialize(path)
  raise NotFound, path unless File.exist?(path)
  @packages = []
  @itself = nil

  load(path)
end

Public Instance Methods

autodetect() click to toggle source
# File lib/gondler/gomfile.rb, line 68
def autodetect
  deps = `go list -f '{{join .Deps "\\n"}}' ./...`.strip.split(/\n+/)

  deps.each do |dep|
    gom(dep) if external?(dep)
  end
end
gom(name, options = {}) click to toggle source
# File lib/gondler/gomfile.rb, line 45
def gom(name, options = {})
  options[:group] = @now_group if @now_group
  options[:os] = @now_os if @now_os

  package = Gondler::Package.new(name, options)
  @packages.push(package) if package.installable?
end
Also aliased as: package
group(*groups) { || ... } click to toggle source
# File lib/gondler/gomfile.rb, line 54
def group(*groups)
  @now_group = groups
  yield if block_given?
ensure
  @now_group = nil
end
itself(name) click to toggle source
# File lib/gondler/gomfile.rb, line 14
def itself(name)
  @itself = name
end
itself_package() click to toggle source
# File lib/gondler/gomfile.rb, line 18
def itself_package
  if !@itself && Gondler.env.orig_path
    realpath = proc do |path|
      if File.respond_to?(:realpath) # 1.9+
        File.realpath(path)
      else
        path
      end
    end

    orig_src = realpath[File.join(Gondler.env.orig_path, 'src')]
    dir = realpath[File.dirname(@path)]
    if dir.start_with?(orig_src)
      @itself = dir[orig_src.size.succ .. -1]
    end
  end

  if @itself
    Gondler::Package.new(@itself, :path => '.')
  end
end
load(path) click to toggle source
# File lib/gondler/gomfile.rb, line 40
def load(path)
  @path = File.expand_path(path)
  instance_eval(File.read(path))
end
os(*oss) { || ... } click to toggle source
# File lib/gondler/gomfile.rb, line 61
def os(*oss)
  @now_os = oss
  yield if block_given?
ensure
  @now_os = nil
end
package(name, options = {})
Alias for: gom

Private Instance Methods

external?(pkg) click to toggle source
# File lib/gondler/gomfile.rb, line 78
def external?(pkg)
  pkg.include?('.') && (@itself.to_s.empty? || !pkg.include?(@itself.to_s))
end