github.com/jerryclinesmith/packer@v0.3.7/website/config.rb (about) 1 require "net/http" 2 3 raise "PACKER_VERSION must be set." if !ENV["PACKER_VERSION"] 4 5 #------------------------------------------------------------------------- 6 # Download the list of Packer downloads 7 #------------------------------------------------------------------------- 8 9 $packer_files = {} 10 $packer_os = [] 11 12 if !ENV["PACKER_DISABLE_DOWNLOAD_FETCH"] 13 raise "BINTRAY_API_KEY must be set." if !ENV["BINTRAY_API_KEY"] 14 http = Net::HTTP.new("dl.bintray.com", 80) 15 req = Net::HTTP::Get.new("/mitchellh/packer") 16 req.basic_auth "mitchellh", ENV["BINTRAY_API_KEY"] 17 response = http.request(req) 18 19 response.body.split("\n").each do |line| 20 next if line !~ /\/mitchellh\/packer\/(#{Regexp.quote(ENV["PACKER_VERSION"])}.+?)'/ 21 filename = $1.to_s 22 os = filename.split("_")[1] 23 next if os == "SHA256SUMS" 24 25 $packer_files[os] ||= [] 26 $packer_files[os] << filename 27 end 28 29 $packer_os = ["darwin", "linux", "windows"] & $packer_files.keys 30 $packer_os += $packer_files.keys 31 $packer_os.uniq! 32 33 $packer_files.each do |key, value| 34 value.sort! 35 end 36 end 37 38 #------------------------------------------------------------------------- 39 # Configure Middleman 40 #------------------------------------------------------------------------- 41 42 set :css_dir, 'stylesheets' 43 set :js_dir, 'javascripts' 44 set :images_dir, 'images' 45 46 # Use the RedCarpet Markdown engine 47 set :markdown_engine, :redcarpet 48 set :markdown, 49 :fenced_code_blocks => true, 50 :with_toc_data => true 51 52 # Build-specific configuration 53 configure :build do 54 activate :asset_hash 55 activate :minify_css 56 activate :minify_html 57 activate :minify_javascript 58 end 59 60 #------------------------------------------------------------------------- 61 # Helpers 62 #------------------------------------------------------------------------- 63 helpers do 64 def download_arch(file) 65 parts = file.split("_") 66 return "" if parts.length != 3 67 parts[2].split(".")[0] 68 end 69 70 def download_os_human(os) 71 if os == "darwin" 72 return "Mac OS X" 73 elsif os == "freebsd" 74 return "FreeBSD" 75 elsif os == "openbsd" 76 return "OpenBSD" 77 elsif os == "Linux" 78 return "Linux" 79 elsif os == "windows" 80 return "Windows" 81 else 82 return os 83 end 84 end 85 86 def download_url(file) 87 "https://dl.bintray.com/mitchellh/packer/#{file}" 88 end 89 90 def latest_version 91 ENV["PACKER_VERSION"] 92 end 93 end