Class: Gem::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/rubygems_ext.rb,
lib/bundler/shared_helpers.rb

Direct Known Subclasses

Bundler::Dependency

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#groupsObject

Returns the value of attribute groups



134
135
136
# File 'lib/bundler/rubygems_ext.rb', line 134

def groups
  @groups
end

#sourceObject

Returns the value of attribute source



134
135
136
# File 'lib/bundler/rubygems_ext.rb', line 134

def source
  @source
end

Instance Method Details

#encode_with(coder) ⇒ Object



138
139
140
141
142
# File 'lib/bundler/rubygems_ext.rb', line 138

def encode_with(coder)
  to_yaml_properties.each do |ivar|
    coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
  end
end

#matches_spec?(spec) ⇒ Boolean

Backport of performance enhancement added to Rubygems 1.4



158
159
160
161
162
163
164
# File 'lib/bundler/rubygems_ext.rb', line 158

def matches_spec?(spec)
  # name can be a Regexp, so use ===
  return false unless name === spec.name
  return true  if requirement.none?

  requirement.satisfied_by?(spec.version)
end

#requirementObject



12
13
14
# File 'lib/bundler/shared_helpers.rb', line 12

def requirement
  version_requirements
end

#to_lockObject



148
149
150
151
152
153
154
155
# File 'lib/bundler/rubygems_ext.rb', line 148

def to_lock
  out = String.new("  #{name}")
  unless requirement == Gem::Requirement.default
    reqs = requirement.requirements.map {|o, v| "#{o} #{v}" }.sort.reverse
    out << " (#{reqs.join(", ")})"
  end
  out
end

#to_yaml_propertiesObject



144
145
146
# File 'lib/bundler/rubygems_ext.rb', line 144

def to_yaml_properties
  instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
end