module Common
Public Instance Methods
box_metadata(metadata_file)
click to toggle source
# File lib/bento/common.rb, line 34 def box_metadata(metadata_file) metadata = Hash.new 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"] = Hash.new 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 63 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 59 def builds_yml YAML.load(File.read("builds.yml")) end
compute_metadata_files()
click to toggle source
# File lib/bento/common.rb, line 55 def compute_metadata_files `ls builds/*.json`.split("\n") end
duration(total)
click to toggle source
# File lib/bento/common.rb, line 27 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 19 def info(msg) puts " #{msg}" end
metadata_files()
click to toggle source
# File lib/bento/common.rb, line 51 def metadata_files @metadata_files ||= compute_metadata_files end
os_x?()
click to toggle source
# File lib/bento/common.rb, line 94 def os_x? !!(RUBY_PLATFORM =~ /darwin/) end
private_box?(boxname)
click to toggle source
# File lib/bento/common.rb, line 89 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 98 def unix? !windows? end
vc_account()
click to toggle source
# File lib/bento/common.rb, line 11 def vc_account VagrantCloud::Account.new(ENV["VAGRANT_CLOUD_ORG"], ENV["VAGRANT_CLOUD_TOKEN"]) end
warn(msg)
click to toggle source
# File lib/bento/common.rb, line 23 def warn(msg) puts ">>> #{msg}" end
windows?()
click to toggle source
# File lib/bento/common.rb, line 102 def windows? !!(RUBY_PLATFORM =~ /mswin|mingw|windows/) end