Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#file_system_path(gem_name) ⇒ Object



13
14
15
# File 'lib/path_gem/gemfile_ext.rb', line 13

def file_system_path(gem_name)
  File.join(File.expand_path(gem_dir), gem_name)
end

#gem_dirObject



27
28
29
30
31
32
33
# File 'lib/path_gem/gemfile_ext.rb', line 27

def gem_dir
  if respond_to? :path_gem_dir
    send :path_gem_dir
  else
    ENV['PATH_GEM_DIR'] || (print_gem_dir_error && raise)
  end
end

#git_path(gem_name, options) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/path_gem/gemfile_ext.rb', line 17

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

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

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

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



1
2
3
# File 'lib/path_gem/gemfile_ext.rb', line 1

def path_gem(gem_name, options={})
  gem gem_name, path_options(gem_name, options)
end

#path_gem_envObject



43
44
45
46
47
48
49
# File 'lib/path_gem/gemfile_ext.rb', line 43

def path_gem_env
  if respond_to? :path_gem_env
    send :path_gem_env
  else
    ENV['PATH_GEM_ENV'] || "production"
  end
end

#path_gem_gitObject



35
36
37
38
39
40
41
# File 'lib/path_gem/gemfile_ext.rb', line 35

def path_gem_git
  if respond_to? :path_gem_git
    send :path_gem_git
  else
    ENV['PATH_GEM_GIT']
  end
end

#path_options(gem_name, options) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/path_gem/gemfile_ext.rb', line 5

def path_options(gem_name, options)
  if path_gem_env != "development"
    return { :git => git_path(gem_name, options) }.merge(options)
  else
    return { :path => file_system_path(gem_name) }
  end
end


51
52
53
# File 'lib/path_gem/gemfile_ext.rb', line 51

def print_gem_dir_error
  puts "The PATH_GEM_DIR environment variable must be set to the path that contains gem project directories"
end