Module: GemOf

Defined in:
lib/gem_of.rb,
lib/version.rb,
lib/gem_of/rake_tasks.rb

Overview

Namespace for Gem methods

Defined Under Namespace

Modules: Version Classes: DocsTasks, GemTasks, Gems, LintTasks, RakeTasks, TestTasks, YardStickTasks

Class Method Summary collapse

Class Method Details

.location_forString

string for use as parameter to the #gem method reverse compat

Examples:

gem "beaker", GemOf.location_of(ENV["BEAKER_VERSION"] || "~> 1")

Parameters:

  • place (String)

    location string from an env_var

  • fake_version (String)

    uh… a git sha?

Returns:

  • (String)

    string for use as parameter to the #gem method forms file or git urls, typically from user env_vars



110
111
112
113
114
115
116
117
118
119
# File 'lib/gem_of.rb', line 110

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

.location_of(place, fake_version = nil) ⇒ String

string for use as parameter to the #gem method

Examples:

gem "beaker", GemOf.location_of(ENV["BEAKER_VERSION"] || "~> 1")

Parameters:

  • place (String)

    location string from an env_var

  • fake_version (String) (defaults to: nil)

    uh… a git sha?

Returns:

  • (String)

    string for use as parameter to the #gem method forms file or git urls, typically from user env_vars



100
101
102
103
104
105
106
107
108
109
# 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