class Gondler::Package
Attributes
alternate_name[R]
branch[R]
commit[R]
fix[R]
flag[R]
group[R]
name[R]
os[R]
path[R]
tag[R]
Public Class Methods
new(name, options = {})
click to toggle source
# File lib/gondler/package.rb, line 9 def initialize(name, options = {}) @name = name @branch = options[:branch] @tag = options[:tag] @commit = options[:commit] @os = options[:os] @group = options[:group] @fix = options[:fix] || false @flag = options[:flag] @path = options[:path] @alternate_name = options[:alternate_name] || options[:alias_as] || options[:as] end
Public Instance Methods
checkout()
click to toggle source
# File lib/gondler/package.rb, line 75 def checkout @name.split('/').reduce(src_path) do |path, dir| path += dir if File.directory?(path + '.git') break checkout_with_git(path) elsif File.directory?(path + '.hg') break checkout_with_hg(path) end path end end
checkout_with_git(path)
click to toggle source
# File lib/gondler/package.rb, line 87 def checkout_with_git(path) Dir.chdir(path) do `git checkout -q #{target}` end end
checkout_with_hg(path)
click to toggle source
# File lib/gondler/package.rb, line 93 def checkout_with_hg(path) Dir.chdir(path) do `hg update #{target}` end end
get()
click to toggle source
# File lib/gondler/package.rb, line 63 def get if @path get_by_path else get_by_package end if alternate_name link_alternate_name end end
install()
click to toggle source
# File lib/gondler/package.rb, line 99 def install args = %w(go install) args << @flag if @flag args << @name result = `#{args.join(' ')} 2>&1` unless $CHILD_STATUS.success? raise InstallError.new("#{@name} install error\n" + result) end end
installable?()
click to toggle source
# File lib/gondler/package.rb, line 50 def installable? ( (os.nil? || os.include?(Gondler.env.os)) && (group.empty? || (Gondler.without & group).empty?) ) end
resolve()
click to toggle source
# File lib/gondler/package.rb, line 57 def resolve get checkout if target install end
target()
click to toggle source
# File lib/gondler/package.rb, line 46 def target @commit || @branch || @tag end
to_s()
click to toggle source
# File lib/gondler/package.rb, line 111 def to_s "#{@name}" + (target ? " (#{target})" : '') end
Private Instance Methods
env_path()
click to toggle source
# File lib/gondler/package.rb, line 117 def env_path Pathname.new(Gondler.env.path) end
get_by_package()
click to toggle source
# File lib/gondler/package.rb, line 137 def get_by_package args = %w(go get -d -u) args << '-fix' if @fix args << @name result = `#{args.join(' ')} 2>&1` unless $CHILD_STATUS.success? raise InstallError.new("#{@name} download error\n" + result) end end
get_by_path()
click to toggle source
# File lib/gondler/package.rb, line 125 def get_by_path target = src_path.join(@name) FileUtils.mkdir_p(target.dirname) FileUtils.remove_entry_secure(target) if target.exist? if @path.to_s.start_with?('/') # absolute path source = @path else # relative path from Gomfile source = env_path.dirname.join(@path).relative_path_from(target.dirname) end File.symlink(source, target) end
link_alternate_name()
click to toggle source
# File lib/gondler/package.rb, line 149 def link_alternate_name actual_path = src_path.join(@name) alternate_path = src_path.join(alternate_name) alternate_path.mkpath FileUtils.remove_entry_secure(alternate_path) unless alternate_path.symlink? alternate_path.make_symlink(actual_path) end
src_path()
click to toggle source
# File lib/gondler/package.rb, line 121 def src_path env_path + 'src' end