class Atlas::UrlBuilder

A class which takes (and extends) Atlas tags and builds URLs from them.

This allows us to refer to items using the same identifiers as Vagrant, with a few extras.

Attributes

tag[R]

Public Class Methods

new(tag) click to toggle source
# File lib/atlas/url_builder.rb, line 25
def initialize(tag)
  user, box, version, provider = tag.split(%r{\/})

  @tag = { user: user, box: box, version: version, provider: provider }
end
url_for(user = nil, box = nil, version = nil, provider = nil) click to toggle source
# File lib/atlas/url_builder.rb, line 9
def self.url_for(user = nil, box = nil, version = nil, provider = nil)
  url = ''

  if user && !box
    return  "/user/#{user}"
  else
    url << "/box/#{user}"
  end

  url << "/#{box}" if box
  url << "/version/#{version}" if version
  url << "/provider/#{provider}" if provider

  url
end