module GemOf

Namespace for Gem methods

Public Class Methods

location_for(place, fake_version = nil)
Alias for: location_of
location_of(place, fake_version = nil) click to toggle source

string for use as parameter to the gem method @return [String] string for use as parameter to the gem method

forms file or git urls, typically from user env_vars

@param place [String] location string from an env_var @param fake_version [String] uh… a git sha? @api public @example

gem "beaker", GemOf.location_of(ENV["BEAKER_VERSION"] || "~> 1")
# File lib/gem_of.rb, line 100
def location_of(place, fake_version = nil)
  if place =~ /^(git:[^#]*)#(.*)/
    [fake_version, { git: Regexp.last_match[1],
                     branch: Regexp.last_match[2] }].compact
  elsif place =~ %r{^file:\/\/(.*)}
    [">= 0", { path: File.expand_path(Regexp.last_match[1]) }]
  else
    [place]
  end
end
Also aliased as: location_for

Private Instance Methods

location_for(place, fake_version = nil)
Alias for: location_of
location_of(place, fake_version = nil) click to toggle source

string for use as parameter to the gem method @return [String] string for use as parameter to the gem method

forms file or git urls, typically from user env_vars

@param place [String] location string from an env_var @param fake_version [String] uh… a git sha? @api public @example

gem "beaker", GemOf.location_of(ENV["BEAKER_VERSION"] || "~> 1")
# File lib/gem_of.rb, line 100
def location_of(place, fake_version = nil)
  if place =~ /^(git:[^#]*)#(.*)/
    [fake_version, { git: Regexp.last_match[1],
                     branch: Regexp.last_match[2] }].compact
  elsif place =~ %r{^file:\/\/(.*)}
    [">= 0", { path: File.expand_path(Regexp.last_match[1]) }]
  else
    [place]
  end
end
Also aliased as: location_for