module Common
Public Instance Methods
box_metadata(metadata_file)
click to toggle source
# File lib/bento/common.rb, line 35 def box_metadata(metadata_file) metadata = {} file = File.read(metadata_file) json = JSON.parse(file) # metadata needed for upload: boxname, version, provider, box filename metadata["name"] = json["name"] metadata["version"] = json["version"] metadata["box_basename"] = json["box_basename"] metadata["tools"] = json["tools"] metadata["providers"] = {} json["providers"].each do |provider| metadata["providers"][provider["name"]] = provider.reject { |k, _| k == "name" } end metadata end
build_list()
click to toggle source
# File lib/bento/common.rb, line 60 def build_list bit32 = [] bit64 = [] builds_yml["public"].each do |platform, versions| versions.each do |version, archs| archs.each do |arch| folder = case platform when "opensuse-leap" "opensuse" when "oracle" "oraclelinux" else platform end case arch when "i386" bit32 << "#{folder}/#{platform}-#{version}-#{arch}" else bit64 << "#{folder}/#{platform}-#{version}-#{arch}" end end end end bit64 + bit32 end
builds_yml()
click to toggle source
# File lib/bento/common.rb, line 56 def builds_yml YAML.load(File.read("builds.yml")) end
duration(total)
click to toggle source
# File lib/bento/common.rb, line 28 def duration(total) total = 0 if total.nil? minutes = (total / 60).to_i seconds = (total - (minutes * 60)) format("%dm%.2fs", minutes, seconds) end
info(msg)
click to toggle source
# File lib/bento/common.rb, line 20 def info(msg) puts " #{msg}" end
macos?()
click to toggle source
# File lib/bento/common.rb, line 91 def macos? !!(RUBY_PLATFORM =~ /darwin/) end
metadata_files()
click to toggle source
# File lib/bento/common.rb, line 52 def metadata_files @metadata_files ||= Dir.glob("builds/*.json") end
private_box?(boxname)
click to toggle source
# File lib/bento/common.rb, line 86 def private_box?(boxname) proprietary_os_list = %w{macos windows sles solaris rhel} proprietary_os_list.any? { |p| boxname.include?(p) } end
unix?()
click to toggle source
# File lib/bento/common.rb, line 95 def unix? !windows? end
vc_account()
click to toggle source
# File lib/bento/common.rb, line 11 def vc_account raise "You must set the 'VAGRANT_CLOUD_ORG' and 'VAGRANT_CLOUD_TOKEN' tokens to interact with the Vagrant Cloud!" unless ENV["VAGRANT_CLOUD_ORG"] && ENV["VAGRANT_CLOUD_TOKEN"] VagrantCloud::Account.new(ENV["VAGRANT_CLOUD_ORG"], ENV["VAGRANT_CLOUD_TOKEN"]) end
warn(msg)
click to toggle source
# File lib/bento/common.rb, line 24 def warn(msg) puts ">>> #{msg}" end
windows?()
click to toggle source
# File lib/bento/common.rb, line 99 def windows? !!(RUBY_PLATFORM =~ /mswin|mingw|windows/) end