Skip to content

Commit efd062d

Browse files
committed
Added jbarnette@gmail.com's developer dependencies
git-svn-id: svn+ssh://rubyforge.org/var/svn/rubygems/trunk@1711 3d4018f9-ac1a-0410-99e9-8a154d859a19
1 parent b861bd7 commit efd062d

14 files changed

+158
-30
lines changed

lib/rubygems.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def self.activate(gem, *version_requirements)
152152
@loaded_specs[spec.name] = spec
153153

154154
# Load dependent gems first
155-
spec.dependencies.each do |dep_gem|
155+
spec.runtime_dependencies.each do |dep_gem|
156156
activate dep_gem
157157
end
158158

lib/rubygems/commands/install_command.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def execute
6262
:install_dir => options[:install_dir],
6363
:security_policy => options[:security_policy],
6464
:wrappers => options[:wrappers],
65-
:bin_dir => options[:bin_dir]
65+
:bin_dir => options[:bin_dir],
66+
:development => options[:development],
6667
}
6768

6869
exit_code = 0

lib/rubygems/commands/lock_command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def execute
8080
say "gem '#{spec.name}', '= #{spec.version}'" unless locked[spec.name]
8181
locked[spec.name] = true
8282

83-
spec.dependencies.each do |dep|
83+
spec.runtime_dependencies.each do |dep|
8484
next if locked[dep.name]
8585
candidates = Gem.source_index.search dep.name, dep.requirement_list
8686

lib/rubygems/custom_require.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module Kernel
2626
def require(path) # :nodoc:
2727
gem_original_require path
2828
rescue LoadError => load_error
29-
if load_error.message =~ /\A[Nn]o such file to load -- #{Regexp.escape path}\z/ and
29+
if load_error.message =~ /#{Regexp.escape path}\z/ and
3030
spec = Gem.searcher.find(path) then
3131
Gem.activate(spec.name, "= #{spec.version}")
3232
gem_original_require path

lib/rubygems/dependency.rb

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@
99
##
1010
# The Dependency class holds a Gem name and a Gem::Requirement
1111
class Gem::Dependency
12+
TYPES = [
13+
:runtime,
14+
:development
15+
]
1216

1317
attr_accessor :name
1418

19+
attr_reader :type
20+
1521
attr_writer :version_requirements
1622

1723
def <=>(other)
@@ -24,8 +30,15 @@ def <=>(other)
2430
# name:: [String] name of the Gem
2531
# version_requirements:: [String Array] version requirement (e.g. ["> 1.2"])
2632
#
27-
def initialize(name, version_requirements)
33+
def initialize(name, version_requirements, type=:runtime)
2834
@name = name
35+
36+
unless TYPES.include? type
37+
raise ArgumentError, "Valid types are #{TYPES.inspect}, not #{@type.inspect}"
38+
end
39+
40+
@type = type
41+
2942
@version_requirements = Gem::Requirement.create version_requirements
3043
@version_requirement = nil # Avoid warnings.
3144
end
@@ -48,17 +61,18 @@ def normalize
4861
end
4962

5063
def to_s # :nodoc:
51-
"#{name} (#{version_requirements})"
64+
"#{name} (#{version_requirements}#{", #{type}" if type != :runtime})"
5265
end
5366

5467
def ==(other) # :nodoc:
5568
self.class === other &&
5669
self.name == other.name &&
70+
self.type == other.type &&
5771
self.version_requirements == other.version_requirements
5872
end
5973

6074
def hash
61-
name.hash + version_requirements.hash
75+
name.hash + type.hash + version_requirements.hash
6276
end
6377

6478
end

lib/rubygems/dependency_installer.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def initialize(options = {})
4444
options = DEFAULT_OPTIONS.merge options
4545

4646
@bin_dir = options[:bin_dir]
47+
@development = options[:development]
4748
@domain = options[:domain]
4849
@env_shebang = options[:env_shebang]
4950
@force = options[:force]
@@ -120,7 +121,10 @@ def gather_dependencies
120121
next if spec.nil? or seen[spec.name]
121122
seen[spec.name] = true
122123

123-
spec.dependencies.each do |dep|
124+
deps = spec.runtime_dependencies
125+
deps |= spec.development_dependencies if @development
126+
127+
deps.each do |dep|
124128
results = find_gems_with_sources(dep).reverse # local gems first
125129

126130
results.each do |dep_spec, source_uri|
@@ -222,7 +226,8 @@ def install dep_or_name, version = Gem::Requirement.default
222226
:install_dir => @install_dir,
223227
:security_policy => @security_policy,
224228
:wrappers => @wrappers,
225-
:bin_dir => @bin_dir
229+
:bin_dir => @bin_dir,
230+
:development => @development
226231

227232
spec = inst.install
228233

lib/rubygems/dependency_list.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def find_name(full_name)
6969
# Are all the dependencies in the list satisfied?
7070
def ok?
7171
@specs.all? do |spec|
72-
spec.dependencies.all? do |dep|
72+
spec.runtime_dependencies.all? do |dep|
7373
@specs.find { |s| s.satisfies_requirement? dep }
7474
end
7575
end

lib/rubygems/install_update_options.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ def add_install_update_options
8989
'foo_exec18') do |value, options|
9090
options[:format_executable] = value
9191
end
92+
93+
add_option(:"Install/Update", "--development",
94+
"Install any additional development",
95+
"dependencies") do |value, options|
96+
options[:development] = true
97+
end
9298
end
9399

94100
# Default options for the gem install command.

lib/rubygems/installer.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def initialize(gem, options={})
7676
@security_policy = options[:security_policy]
7777
@wrappers = options[:wrappers]
7878
@bin_dir = options[:bin_dir]
79+
@development = options[:development]
7980

8081
begin
8182
@format = Gem::Format.from_file_by_path @gem, @security_policy
@@ -119,7 +120,10 @@ def install
119120
end
120121

121122
unless @ignore_dependencies then
122-
@spec.dependencies.each do |dep_gem|
123+
deps = @spec.runtime_dependencies
124+
deps |= @spec.development_dependencies if @development
125+
126+
deps.each do |dep_gem|
123127
ensure_dependency @spec, dep_gem
124128
end
125129
end

lib/rubygems/server.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ def run
421421
total_file_count += spec.files.size
422422
deps = spec.dependencies.collect { |dep|
423423
{ "name" => dep.name,
424+
"type" => dep.type,
424425
"version" => dep.version_requirements.to_s, }
425426
}
426427
deps = deps.sort_by { |dep| [dep["name"].downcase, dep["version"]] }

0 commit comments

Comments
 (0)