Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#_file_system_path(gem_name) ⇒ Object



31
32
33
# File 'lib/prox_gem/prox_gem.rb', line 31

def _file_system_path(gem_name)
  File.join(File.expand_path(_gem_dir), gem_name)
end

#_gem_dirObject



23
24
25
# File 'lib/prox_gem/prox_gem.rb', line 23

def _gem_dir
  ENV['PROX_GEM_DIR'] || (_print_gem_dir_error && raise)
end

#_git_path(gem_name, options) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/prox_gem/prox_gem.rb', line 35

def _git_path(gem_name, options)
  prefix = options.delete :prefix

  repo_name = gem_name.gsub '_', '-'

  path = "#{_prox_gem_git_uri}/"
  path << "#{prefix}/" if prefix
  path << "#{repo_name}.git"
end

#_options(gem_name, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/prox_gem/prox_gem.rb', line 6

def _options(gem_name, options={})
  mode = _prox_gem_mode
  if mode == "path"
    return { :path => _file_system_path(gem_name) }
  elsif mode == "git"    
    return { :git => _git_path(gem_name, options) }.merge(options)
  elsif mode == 'off'
    return options
  else
    _print_mode_error && raise
  end
end

#_print_gem_dir_errorObject



49
50
51
# File 'lib/prox_gem/prox_gem.rb', line 49

def _print_gem_dir_error
  puts 'The PROX_GEM_DIR environment variable must be set to the path that contains gem project directories'
end

#_print_git_repo_uri_errorObject



53
54
55
# File 'lib/prox_gem/prox_gem.rb', line 53

def _print_git_repo_uri_error
  puts 'The PROX_GEM_GIT_URI environment variable must be set to the URI of the Git repository where the gem project is housed'
end

#_print_mode_error(mode) ⇒ Object



45
46
47
# File 'lib/prox_gem/prox_gem.rb', line 45

def _print_mode_error(mode)
  puts "The PROX_GEM_MODE \"#{mode}\" environment variable is wrong. It must be one of \"path\", \"git\", or \"off\"."
end

#_prox_gem_git_uriObject



27
28
29
# File 'lib/prox_gem/prox_gem.rb', line 27

def _prox_gem_git_uri
  ENV['PROX_GEM_GIT_URI'] || (_print_git_repo_uri_error && raise)
end

#_prox_gem_modeObject



19
20
21
# File 'lib/prox_gem/prox_gem.rb', line 19

def _prox_gem_mode
  ENV['PROX_GEM_MODE'] || "off"
end

#prox_gem(gem_name, options = {}) ⇒ Object



1
2
3
4
# File 'lib/prox_gem/prox_gem.rb', line 1

def prox_gem(gem_name, options={})
  opts = _options(gem_name, options)
  gem gem_name, opts
end