Class: Gem::Specification

Inherits:
Object show all
Includes:
Bundler::MatchPlatform
Defined in:
lib/bundler/resolver.rb,
lib/bundler/rubygems_ext.rb,
lib/bundler/rubygems_ext.rb

Constant Summary

Constants included from Bundler::GemHelpers

Bundler::GemHelpers::GENERICS, Bundler::GemHelpers::GENERIC_CACHE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Bundler::MatchPlatform

#match_platform

Methods included from Bundler::GemHelpers

#generic

Instance Attribute Details

#locationObject

Returns the value of attribute location.



15
16
17
# File 'lib/bundler/rubygems_ext.rb', line 15

def location
  @location
end

#relative_loaded_fromObject

Returns the value of attribute relative_loaded_from.



15
16
17
# File 'lib/bundler/rubygems_ext.rb', line 15

def relative_loaded_from
  @relative_loaded_from
end

#sourceObject

Returns the value of attribute source.



15
16
17
# File 'lib/bundler/rubygems_ext.rb', line 15

def source
  @source
end

Instance Method Details

#add_bundler_dependencies(*groups) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/bundler/rubygems_ext.rb', line 73

def add_bundler_dependencies(*groups)
  Bundler.ui.warn "#add_bundler_dependencies is deprecated and will " \
    "be removed in Bundler 1.0. Instead, please use the #gemspec method " \
    "in your Gemfile, which will pull in any dependencies specified in " \
    "your gemspec"

  groups = [:default] if groups.empty?
  Bundler.definition.dependencies.each do |dep|
    if dep.groups.include?(:development)
      self.add_development_dependency(dep.name, dep.requirement.to_s)
    elsif (dep.groups & groups).any?
      self.add_dependency(dep.name, dep.requirement.to_s)
    end
  end
end

#full_gem_pathObject



20
21
22
23
24
# File 'lib/bundler/rubygems_ext.rb', line 20

def full_gem_path
  source.respond_to?(:path) ?
    Pathname.new(loaded_from).dirname.expand_path(Bundler.root).to_s :
    rg_full_gem_path
end

#gem_dirObject



44
45
46
# File 'lib/bundler/rubygems_ext.rb', line 44

def gem_dir
  full_gem_path
end

#git_versionObject



52
53
54
55
56
57
# File 'lib/bundler/rubygems_ext.rb', line 52

def git_version
  if @loaded_from && File.exist?(File.join(full_gem_path, ".git"))
    sha = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip }
    " #{sha[0..6]}"
  end
end

#groupsObject



48
49
50
# File 'lib/bundler/rubygems_ext.rb', line 48

def groups
  @groups ||= []
end

#load_pathsObject



32
33
34
35
36
37
38
39
40
# File 'lib/bundler/rubygems_ext.rb', line 32

def load_paths
  require_paths.map do |require_path|
    if require_path.include?(full_gem_path)
      require_path
    else
      File.join(full_gem_path, require_path)
    end
  end
end

#loaded_fromObject



26
27
28
29
30
# File 'lib/bundler/rubygems_ext.rb', line 26

def loaded_from
  relative_loaded_from ?
    source.path.join(relative_loaded_from).to_s :
    rg_loaded_from
end

#nondevelopment_dependenciesObject



69
70
71
# File 'lib/bundler/rubygems_ext.rb', line 69

def nondevelopment_dependencies
  dependencies - development_dependencies
end

#required_byObject



11
12
13
# File 'lib/bundler/resolver.rb', line 11

def required_by
  @required_by ||= []
end

#rg_full_gem_pathObject



17
# File 'lib/bundler/rubygems_ext.rb', line 17

alias_method :rg_full_gem_path, :full_gem_path

#rg_loaded_fromObject



18
# File 'lib/bundler/rubygems_ext.rb', line 18

alias_method :rg_loaded_from,   :loaded_from

#to_gemfile(path = nil) ⇒ Object



59
60
61
62
63
64
65
66
67
# File 'lib/bundler/rubygems_ext.rb', line 59

def to_gemfile(path = nil)
  gemfile = "source :gemcutter\n"
  gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
  unless development_dependencies.empty?
    gemfile << "\n"
    gemfile << dependencies_to_gemfile(development_dependencies, :development)
  end
  gemfile
end