rubygems-update 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +5 -1
- data/History.txt +101 -4
- data/LICENSE.txt +42 -37
- data/MIT.txt +20 -0
- data/Manifest.txt +5 -4
- data/Rakefile +6 -7
- data/lib/rubygems.rb +175 -278
- data/lib/rubygems/builder.rb +7 -6
- data/lib/rubygems/command_manager.rb +16 -2
- data/lib/rubygems/commands/build_command.rb +13 -11
- data/lib/rubygems/commands/cert_command.rb +1 -1
- data/lib/rubygems/commands/cleanup_command.rb +10 -19
- data/lib/rubygems/commands/contents_command.rb +5 -5
- data/lib/rubygems/commands/dependency_command.rb +17 -40
- data/lib/rubygems/commands/fetch_command.rb +1 -1
- data/lib/rubygems/commands/install_command.rb +2 -1
- data/lib/rubygems/commands/lock_command.rb +4 -4
- data/lib/rubygems/commands/outdated_command.rb +18 -6
- data/lib/rubygems/commands/pristine_command.rb +25 -15
- data/lib/rubygems/commands/query_command.rb +9 -6
- data/lib/rubygems/commands/setup_command.rb +1 -1
- data/lib/rubygems/commands/specification_command.rb +8 -23
- data/lib/rubygems/commands/stale_command.rb +2 -1
- data/lib/rubygems/commands/unpack_command.rb +7 -5
- data/lib/rubygems/commands/update_command.rb +2 -4
- data/lib/rubygems/commands/which_command.rb +5 -9
- data/lib/rubygems/config_file.rb +9 -7
- data/lib/rubygems/custom_require.rb +6 -4
- data/lib/rubygems/defaults.rb +30 -14
- data/lib/rubygems/dependency.rb +44 -1
- data/lib/rubygems/dependency_installer.rb +37 -41
- data/lib/rubygems/dependency_list.rb +20 -9
- data/lib/rubygems/deprecate.rb +3 -3
- data/lib/rubygems/doc_manager.rb +10 -11
- data/lib/rubygems/ext/rake_builder.rb +1 -1
- data/lib/rubygems/gem_path_searcher.rb +19 -4
- data/lib/rubygems/gem_runner.rb +1 -1
- data/lib/rubygems/indexer.rb +117 -123
- data/lib/rubygems/installer.rb +101 -94
- data/lib/rubygems/installer_test_case.rb +28 -30
- data/lib/rubygems/local_remote_options.rb +1 -1
- data/lib/rubygems/mock_gem_ui.rb +10 -3
- data/lib/rubygems/package.rb +0 -26
- data/lib/rubygems/package/tar_input.rb +5 -6
- data/lib/rubygems/package_task.rb +1 -1
- data/lib/rubygems/path_support.rb +72 -0
- data/lib/rubygems/platform.rb +12 -2
- data/lib/rubygems/remote_fetcher.rb +7 -6
- data/lib/rubygems/requirement.rb +3 -0
- data/lib/rubygems/security.rb +1 -1
- data/lib/rubygems/server.rb +67 -67
- data/lib/rubygems/source_index.rb +58 -29
- data/lib/rubygems/spec_fetcher.rb +5 -1
- data/lib/rubygems/specification.rb +1422 -877
- data/lib/rubygems/test_case.rb +114 -64
- data/lib/rubygems/test_utilities.rb +4 -3
- data/lib/rubygems/text.rb +1 -1
- data/lib/rubygems/uninstaller.rb +37 -44
- data/test/rubygems/test_gem.rb +131 -102
- data/test/rubygems/test_gem_builder.rb +18 -1
- data/test/rubygems/test_gem_command_manager.rb +2 -0
- data/test/rubygems/test_gem_commands_build_command.rb +31 -3
- data/test/rubygems/test_gem_commands_cleanup_command.rb +51 -0
- data/test/rubygems/test_gem_commands_dependency_command.rb +1 -10
- data/test/rubygems/test_gem_commands_fetch_command.rb +5 -4
- data/test/rubygems/test_gem_commands_help_command.rb +58 -0
- data/test/rubygems/test_gem_commands_install_command.rb +25 -24
- data/test/rubygems/test_gem_commands_list_command.rb +1 -4
- data/test/rubygems/test_gem_commands_outdated_command.rb +10 -9
- data/test/rubygems/test_gem_commands_pristine_command.rb +63 -22
- data/test/rubygems/test_gem_commands_push_command.rb +1 -1
- data/test/rubygems/test_gem_commands_query_command.rb +15 -82
- data/test/rubygems/test_gem_commands_sources_command.rb +8 -9
- data/test/rubygems/test_gem_commands_specification_command.rb +10 -6
- data/test/rubygems/test_gem_commands_stale_command.rb +4 -4
- data/test/rubygems/test_gem_commands_unpack_command.rb +20 -21
- data/test/rubygems/test_gem_commands_update_command.rb +19 -23
- data/test/rubygems/test_gem_commands_which_command.rb +7 -4
- data/test/rubygems/test_gem_dependency.rb +14 -8
- data/test/rubygems/test_gem_dependency_installer.rb +87 -33
- data/test/rubygems/test_gem_dependency_list.rb +7 -3
- data/test/rubygems/test_gem_doc_manager.rb +3 -3
- data/test/rubygems/test_gem_format.rb +1 -1
- data/test/rubygems/test_gem_gem_path_searcher.rb +45 -29
- data/test/rubygems/test_gem_indexer.rb +48 -47
- data/test/rubygems/test_gem_install_update_options.rb +6 -5
- data/test/rubygems/test_gem_installer.rb +61 -37
- data/test/rubygems/test_gem_path_support.rb +58 -0
- data/test/rubygems/test_gem_platform.rb +5 -5
- data/test/rubygems/test_gem_remote_fetcher.rb +18 -21
- data/test/rubygems/test_gem_server.rb +23 -15
- data/test/rubygems/test_gem_source_index.rb +165 -127
- data/test/rubygems/test_gem_spec_fetcher.rb +42 -49
- data/test/rubygems/test_gem_specification.rb +104 -74
- data/test/rubygems/test_gem_text.rb +15 -0
- data/test/rubygems/test_gem_uninstaller.rb +15 -26
- data/test/rubygems/test_kernel.rb +1 -2
- metadata +64 -14
- metadata.gz.sig +0 -0
- data/GPL.txt +0 -340
- data/pkgs/sources/lib/sources.rb +0 -3
- data/pkgs/sources/sources.gemspec +0 -14
- data/test/rubygems/functional.rb +0 -92
@@ -73,16 +73,13 @@ class Gem::SourceIndex
|
|
73
73
|
|
74
74
|
def self.load_specification(file_name)
|
75
75
|
Deprecate.skip_during do
|
76
|
-
Gem::Specification.load file_name
|
76
|
+
Gem::Specification.load Gem::Path.new(file_name)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
80
|
##
|
81
81
|
# Constructs a source index instance from the provided specifications, which
|
82
82
|
# is a Hash of gem full names and Gem::Specifications.
|
83
|
-
#--
|
84
|
-
# TODO merge @gems and @prerelease_gems and provide a separate method
|
85
|
-
# #prerelease_gems
|
86
83
|
|
87
84
|
def initialize specs_or_dirs = []
|
88
85
|
@gems = {}
|
@@ -90,8 +87,9 @@ class Gem::SourceIndex
|
|
90
87
|
|
91
88
|
case specs_or_dirs
|
92
89
|
when Hash then
|
93
|
-
|
94
|
-
|
90
|
+
specs_or_dirs.each do |full_name, spec|
|
91
|
+
add_spec spec
|
92
|
+
end
|
95
93
|
when Array, String then
|
96
94
|
self.spec_dirs = Array(specs_or_dirs)
|
97
95
|
refresh!
|
@@ -102,15 +100,15 @@ class Gem::SourceIndex
|
|
102
100
|
end
|
103
101
|
|
104
102
|
def all_gems
|
105
|
-
|
103
|
+
gems
|
106
104
|
end
|
107
105
|
|
108
106
|
def prerelease_gems
|
109
|
-
@gems.reject{ |name, gem| !gem.version.prerelease? }
|
107
|
+
@gems.reject { |name, gem| !gem.version.prerelease? }
|
110
108
|
end
|
111
109
|
|
112
110
|
def released_gems
|
113
|
-
@gems.reject{ |name, gem| gem.version.prerelease? }
|
111
|
+
@gems.reject { |name, gem| gem.version.prerelease? }
|
114
112
|
end
|
115
113
|
|
116
114
|
##
|
@@ -120,7 +118,7 @@ class Gem::SourceIndex
|
|
120
118
|
@gems.clear
|
121
119
|
|
122
120
|
spec_dirs.reverse_each do |spec_dir|
|
123
|
-
spec_files = Dir
|
121
|
+
spec_files = Dir[File.join(spec_dir, "*.gemspec")]
|
124
122
|
|
125
123
|
spec_files.each do |spec_file|
|
126
124
|
gemspec = Deprecate.skip_during do
|
@@ -165,8 +163,6 @@ class Gem::SourceIndex
|
|
165
163
|
result[name] << spec
|
166
164
|
end
|
167
165
|
|
168
|
-
# TODO: why is this a hash while @gems is an array? Seems like
|
169
|
-
# structural similarity would be good.
|
170
166
|
result.values.flatten
|
171
167
|
end
|
172
168
|
|
@@ -252,7 +248,10 @@ class Gem::SourceIndex
|
|
252
248
|
|
253
249
|
def find_name(gem_name, requirement = Gem::Requirement.default)
|
254
250
|
dep = Gem::Dependency.new gem_name, requirement
|
255
|
-
|
251
|
+
|
252
|
+
Deprecate.skip_during do
|
253
|
+
search dep
|
254
|
+
end
|
256
255
|
end
|
257
256
|
|
258
257
|
##
|
@@ -264,9 +263,9 @@ class Gem::SourceIndex
|
|
264
263
|
# +gem_pattern+, and a Gem::Requirement for +platform_only+. This
|
265
264
|
# behavior is deprecated and will be removed.
|
266
265
|
|
267
|
-
def search(gem_pattern,
|
266
|
+
def search(gem_pattern, platform_or_requirement = false)
|
268
267
|
requirement = nil
|
269
|
-
only_platform = false
|
268
|
+
only_platform = false # FIX: WTF is this?!?
|
270
269
|
|
271
270
|
# TODO - Remove support and warning for legacy arguments after 2008/11
|
272
271
|
unless Gem::Dependency === gem_pattern
|
@@ -275,9 +274,9 @@ class Gem::SourceIndex
|
|
275
274
|
|
276
275
|
case gem_pattern
|
277
276
|
when Regexp then
|
278
|
-
requirement =
|
277
|
+
requirement = platform_or_requirement || Gem::Requirement.default
|
279
278
|
when Gem::Dependency then
|
280
|
-
only_platform =
|
279
|
+
only_platform = platform_or_requirement
|
281
280
|
requirement = gem_pattern.requirement
|
282
281
|
|
283
282
|
gem_pattern = if Regexp === gem_pattern.name then
|
@@ -288,7 +287,7 @@ class Gem::SourceIndex
|
|
288
287
|
/^#{Regexp.escape gem_pattern.name}$/
|
289
288
|
end
|
290
289
|
else
|
291
|
-
requirement =
|
290
|
+
requirement = platform_or_requirement || Gem::Requirement.default
|
292
291
|
gem_pattern = /#{gem_pattern}/i
|
293
292
|
end
|
294
293
|
|
@@ -349,16 +348,6 @@ class Gem::SourceIndex
|
|
349
348
|
def dump
|
350
349
|
Marshal.dump(self)
|
351
350
|
end
|
352
|
-
|
353
|
-
extend Deprecate
|
354
|
-
deprecate :all_gems, :none, 2011, 10
|
355
|
-
|
356
|
-
class << self
|
357
|
-
extend Deprecate
|
358
|
-
deprecate :from_installed_gems, :none, 2011, 10
|
359
|
-
deprecate :from_gems_in, :none, 2011, 10
|
360
|
-
deprecate :load_specification, :none, 2011, 10
|
361
|
-
end
|
362
351
|
end
|
363
352
|
|
364
353
|
# :stopdoc:
|
@@ -371,5 +360,45 @@ module Gem
|
|
371
360
|
Cache = SourceIndex
|
372
361
|
|
373
362
|
end
|
374
|
-
# :startdoc:
|
375
363
|
|
364
|
+
class Gem::SourceIndex
|
365
|
+
extend Deprecate
|
366
|
+
|
367
|
+
deprecate :all_gems, :none, 2011, 10
|
368
|
+
|
369
|
+
deprecate :==, :none, 2011, 11 # noisy
|
370
|
+
deprecate :add_specs, :none, 2011, 11 # noisy
|
371
|
+
deprecate :each, :none, 2011, 11
|
372
|
+
deprecate :gems, :none, 2011, 11
|
373
|
+
deprecate :load_gems_in, :none, 2011, 11
|
374
|
+
deprecate :refresh!, :none, 2011, 11
|
375
|
+
deprecate :spec_dirs=, "Specification.dirs=", 2011, 11 # noisy
|
376
|
+
deprecate :add_spec, "Specification.add_spec", 2011, 11
|
377
|
+
deprecate :find_name, "Specification.find_by_name", 2011, 11
|
378
|
+
deprecate :gem_signature, :none, 2011, 11
|
379
|
+
deprecate :index_signature, :none, 2011, 11
|
380
|
+
deprecate :initialize, :none, 2011, 11
|
381
|
+
deprecate :latest_specs, "Specification.latest_specs", 2011, 11
|
382
|
+
deprecate :length, "Specification.all.length", 2011, 11
|
383
|
+
deprecate :outdated, :none, 2011, 11
|
384
|
+
deprecate :prerelease_gems, :none, 2011, 11
|
385
|
+
deprecate :prerelease_specs, :none, 2011, 11
|
386
|
+
deprecate :released_gems, :none, 2011, 11
|
387
|
+
deprecate :released_specs, :none, 2011, 11
|
388
|
+
deprecate :remove_spec, "Specification.remove_spec", 2011, 11
|
389
|
+
deprecate :search, :none, 2011, 11
|
390
|
+
deprecate :size, "Specification.all.size", 2011, 11
|
391
|
+
deprecate :spec_dirs, "Specification.dirs", 2011, 11
|
392
|
+
deprecate :specification, "Specification.find", 2011, 11
|
393
|
+
|
394
|
+
class << self
|
395
|
+
extend Deprecate
|
396
|
+
|
397
|
+
deprecate :from_gems_in, :none, 2011, 10
|
398
|
+
deprecate :from_installed_gems, :none, 2011, 10
|
399
|
+
deprecate :installed_spec_directories, "Specification.dirs", 2011, 11
|
400
|
+
deprecate :load_specification, :none, 2011, 10
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
# :startdoc:
|
@@ -85,6 +85,7 @@ class Gem::SpecFetcher
|
|
85
85
|
all = false,
|
86
86
|
matching_platform = true,
|
87
87
|
prerelease = false)
|
88
|
+
|
88
89
|
specs_and_sources, errors = find_matching_with_errors(dependency,
|
89
90
|
all,
|
90
91
|
matching_platform,
|
@@ -138,7 +139,10 @@ class Gem::SpecFetcher
|
|
138
139
|
# matching released versions are returned. If +matching_platform+
|
139
140
|
# is false, gems for all platforms are returned.
|
140
141
|
|
141
|
-
def find_matching_with_errors(dependency,
|
142
|
+
def find_matching_with_errors(dependency,
|
143
|
+
all = false,
|
144
|
+
matching_platform = true,
|
145
|
+
prerelease = false)
|
142
146
|
found = {}
|
143
147
|
|
144
148
|
rejected_specs = {}
|
@@ -28,11 +28,6 @@ class Date; end # for ruby_code if date.rb wasn't required
|
|
28
28
|
|
29
29
|
class Gem::Specification
|
30
30
|
|
31
|
-
##
|
32
|
-
# Allows deinstallation of gems with legacy platforms.
|
33
|
-
|
34
|
-
attr_accessor :original_platform # :nodoc:
|
35
|
-
|
36
31
|
##
|
37
32
|
# The the version number of a specification that does not specify one
|
38
33
|
# (i.e. RubyGems 0.7 or earlier).
|
@@ -88,7 +83,7 @@ class Gem::Specification
|
|
88
83
|
@@default_value = {
|
89
84
|
:authors => [],
|
90
85
|
:autorequire => nil,
|
91
|
-
:bindir =>
|
86
|
+
:bindir => 'bin',
|
92
87
|
:cert_chain => [],
|
93
88
|
:date => TODAY,
|
94
89
|
:dependencies => [],
|
@@ -104,7 +99,7 @@ class Gem::Specification
|
|
104
99
|
:platform => Gem::Platform::RUBY,
|
105
100
|
:post_install_message => nil,
|
106
101
|
:rdoc_options => [],
|
107
|
-
:require_paths => [
|
102
|
+
:require_paths => ['lib'],
|
108
103
|
:required_ruby_version => Gem::Requirement.default,
|
109
104
|
:required_rubygems_version => Gem::Requirement.default,
|
110
105
|
:requirements => [],
|
@@ -123,279 +118,374 @@ class Gem::Specification
|
|
123
118
|
@@default_value[k].nil?
|
124
119
|
}
|
125
120
|
|
126
|
-
|
127
|
-
|
128
|
-
end
|
121
|
+
######################################################################
|
122
|
+
# :section: Required gemspec attributes
|
129
123
|
|
130
124
|
##
|
131
|
-
#
|
125
|
+
# This gem's name
|
132
126
|
|
133
|
-
|
134
|
-
@@default_value[name]
|
135
|
-
end
|
127
|
+
attr_accessor :name
|
136
128
|
|
137
129
|
##
|
138
|
-
#
|
130
|
+
# This gem's version
|
139
131
|
|
140
|
-
|
141
|
-
@@required_attributes.dup
|
142
|
-
end
|
132
|
+
attr_reader :version
|
143
133
|
|
144
134
|
##
|
145
|
-
#
|
135
|
+
# Paths in the gem to add to $LOAD_PATH when this gem is activated.
|
136
|
+
#
|
137
|
+
# The default ['lib'] is typically sufficient.
|
146
138
|
|
147
|
-
|
148
|
-
@@required_attributes.include? name.to_sym
|
149
|
-
end
|
139
|
+
attr_accessor :require_paths
|
150
140
|
|
151
141
|
##
|
152
|
-
#
|
142
|
+
# The version of RubyGems used to create this gem.
|
143
|
+
#
|
144
|
+
# Do not set this, it is set automatically when the gem is packaged.
|
153
145
|
|
154
|
-
|
155
|
-
@@array_attributes.dup
|
156
|
-
end
|
146
|
+
attr_accessor :rubygems_version
|
157
147
|
|
158
148
|
##
|
159
|
-
# Specification
|
149
|
+
# The Gem::Specification version of this gemspec.
|
150
|
+
#
|
151
|
+
# Do not set this, it is set automatically when the gem is packaged.
|
160
152
|
|
161
|
-
|
162
|
-
@@non_nil_attributes.dup
|
163
|
-
end
|
153
|
+
attr_accessor :specification_version
|
164
154
|
|
165
155
|
##
|
166
|
-
#
|
167
|
-
|
168
|
-
#
|
169
|
-
#
|
156
|
+
# A short summary of this gem's description. Displayed in `gem list -d`.
|
157
|
+
#
|
158
|
+
# The description should be more detailed than the summary. For example,
|
159
|
+
# you might wish to copy the entire README into the description.
|
170
160
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
@name,
|
176
|
-
@version,
|
177
|
-
date,
|
178
|
-
@summary,
|
179
|
-
@required_ruby_version,
|
180
|
-
@required_rubygems_version,
|
181
|
-
@original_platform,
|
182
|
-
@dependencies,
|
183
|
-
@rubyforge_project,
|
184
|
-
@email,
|
185
|
-
@authors,
|
186
|
-
@description,
|
187
|
-
@homepage,
|
188
|
-
true, # has_rdoc
|
189
|
-
@new_platform,
|
190
|
-
@licenses
|
191
|
-
]
|
192
|
-
end
|
161
|
+
attr_reader :summary
|
162
|
+
|
163
|
+
######################################################################
|
164
|
+
# :section: Optional gemspec attributes
|
193
165
|
|
194
166
|
##
|
195
|
-
#
|
167
|
+
# Autorequire was used by old RubyGems to automatically require a file.
|
168
|
+
#
|
169
|
+
# Deprecated: It is neither supported nor functional.
|
196
170
|
|
197
|
-
|
198
|
-
array = Marshal.load str
|
171
|
+
attr_accessor :autorequire
|
199
172
|
|
200
|
-
|
201
|
-
|
173
|
+
##
|
174
|
+
# The path in the gem for executable scripts. Usually 'bin'
|
202
175
|
|
203
|
-
|
176
|
+
attr_accessor :bindir
|
204
177
|
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
MARSHAL_FIELDS[current_version]
|
209
|
-
else
|
210
|
-
MARSHAL_FIELDS[spec.specification_version]
|
211
|
-
end
|
178
|
+
##
|
179
|
+
# The certificate chain used to sign this gem. See Gem::Security for
|
180
|
+
# details.
|
212
181
|
|
213
|
-
|
214
|
-
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
215
|
-
end
|
182
|
+
attr_accessor :cert_chain
|
216
183
|
|
217
|
-
|
218
|
-
|
219
|
-
spec.instance_variable_set :@name, array[2]
|
220
|
-
spec.instance_variable_set :@version, array[3]
|
221
|
-
spec.instance_variable_set :@date, array[4]
|
222
|
-
spec.instance_variable_set :@summary, array[5]
|
223
|
-
spec.instance_variable_set :@required_ruby_version, array[6]
|
224
|
-
spec.instance_variable_set :@required_rubygems_version, array[7]
|
225
|
-
spec.instance_variable_set :@original_platform, array[8]
|
226
|
-
spec.instance_variable_set :@dependencies, array[9]
|
227
|
-
spec.instance_variable_set :@rubyforge_project, array[10]
|
228
|
-
spec.instance_variable_set :@email, array[11]
|
229
|
-
spec.instance_variable_set :@authors, array[12]
|
230
|
-
spec.instance_variable_set :@description, array[13]
|
231
|
-
spec.instance_variable_set :@homepage, array[14]
|
232
|
-
spec.instance_variable_set :@has_rdoc, array[15]
|
233
|
-
spec.instance_variable_set :@new_platform, array[16]
|
234
|
-
spec.instance_variable_set :@platform, array[16].to_s
|
235
|
-
spec.instance_variable_set :@license, array[17]
|
236
|
-
spec.instance_variable_set :@loaded, false
|
184
|
+
##
|
185
|
+
# A long description of this gem
|
237
186
|
|
238
|
-
|
239
|
-
end
|
187
|
+
attr_reader :description
|
240
188
|
|
241
189
|
##
|
242
|
-
#
|
190
|
+
# Sets the default executable for this gem.
|
191
|
+
#
|
192
|
+
# Deprecated: You must now specify the executable name to Gem.bin_path.
|
243
193
|
|
244
|
-
|
245
|
-
dependencies.select { |d| d.type == :runtime }
|
246
|
-
end
|
194
|
+
attr_writer :default_executable
|
247
195
|
|
248
196
|
##
|
249
|
-
#
|
197
|
+
# A contact email for this gem
|
198
|
+
#
|
199
|
+
# If you are providing multiple authors and multiple emails they should be
|
200
|
+
# in the same order such that:
|
201
|
+
#
|
202
|
+
# Hash[*spec.authors.zip(spec.emails).flatten]
|
203
|
+
#
|
204
|
+
# Gives a hash of author name to email address.
|
250
205
|
|
251
|
-
|
252
|
-
dependencies.select { |d| d.type == :development }
|
253
|
-
end
|
206
|
+
attr_accessor :email
|
254
207
|
|
255
|
-
|
256
|
-
|
257
|
-
end
|
208
|
+
##
|
209
|
+
# The URL of this gem's home page
|
258
210
|
|
259
|
-
|
260
|
-
@test_files = [] unless defined? @test_files
|
261
|
-
@test_files << val
|
262
|
-
end
|
211
|
+
attr_accessor :homepage
|
263
212
|
|
264
213
|
##
|
265
|
-
#
|
266
|
-
# This attribute is not persisted.
|
214
|
+
# True when this gemspec has been activated. This attribute is not persisted.
|
267
215
|
|
268
216
|
attr_accessor :loaded
|
269
217
|
|
270
|
-
|
271
|
-
# Path this gemspec was loaded from. This attribute is not persisted.
|
272
|
-
|
273
|
-
attr_accessor :loaded_from
|
218
|
+
alias :loaded? :loaded
|
274
219
|
|
275
220
|
##
|
276
|
-
#
|
277
|
-
# executables list
|
221
|
+
# True when this gemspec has been activated. This attribute is not persisted.
|
278
222
|
|
279
|
-
|
280
|
-
return nil if executables.nil?
|
223
|
+
attr_accessor :activated
|
281
224
|
|
282
|
-
|
283
|
-
Array(executables).map { |e| File.join(@bindir, e) }
|
284
|
-
else
|
285
|
-
executables
|
286
|
-
end
|
287
|
-
rescue
|
288
|
-
return nil
|
289
|
-
end
|
225
|
+
alias :activated? :activated
|
290
226
|
|
291
227
|
##
|
292
|
-
#
|
228
|
+
# Path this gemspec was loaded from. This attribute is not persisted.
|
293
229
|
|
294
|
-
|
295
|
-
@files.select do |file|
|
296
|
-
require_paths.any? do |path|
|
297
|
-
file.index(path) == 0
|
298
|
-
end
|
299
|
-
end
|
300
|
-
end
|
230
|
+
attr_reader :loaded_from
|
301
231
|
|
302
232
|
##
|
303
|
-
#
|
233
|
+
# Allows deinstallation of gems with legacy platforms.
|
304
234
|
|
305
|
-
|
235
|
+
attr_writer :original_platform # :nodoc:
|
306
236
|
|
307
237
|
##
|
308
|
-
#
|
238
|
+
# A message that gets displayed after the gem is installed
|
309
239
|
|
310
|
-
|
311
|
-
not test_files.empty?
|
312
|
-
end
|
240
|
+
attr_accessor :post_install_message
|
313
241
|
|
314
|
-
|
315
|
-
|
316
|
-
|
242
|
+
##
|
243
|
+
# The version of ruby required by this gem
|
244
|
+
|
245
|
+
attr_reader :required_ruby_version
|
317
246
|
|
318
247
|
##
|
319
|
-
#
|
320
|
-
# attributes and yields itself for further
|
321
|
-
# initialization. Optionally takes +name+ and +version+.
|
248
|
+
# The RubyGems version required by this gem
|
322
249
|
|
323
|
-
|
324
|
-
@new_platform = nil
|
325
|
-
@loaded = false
|
326
|
-
@loaded_from = nil
|
327
|
-
@original_platform = nil
|
250
|
+
attr_reader :required_rubygems_version
|
328
251
|
|
329
|
-
|
330
|
-
|
331
|
-
|
252
|
+
##
|
253
|
+
# The rubyforge project this gem lives under. i.e. RubyGems'
|
254
|
+
# rubyforge_project is "rubygems".
|
332
255
|
|
333
|
-
|
334
|
-
default = default_value(key)
|
335
|
-
value = case default
|
336
|
-
when Time, Numeric, Symbol, true, false, nil then default
|
337
|
-
else default.dup
|
338
|
-
end
|
256
|
+
attr_accessor :rubyforge_project
|
339
257
|
|
340
|
-
|
341
|
-
|
258
|
+
##
|
259
|
+
# The key used to sign this gem. See Gem::Security for details.
|
342
260
|
|
343
|
-
|
344
|
-
instance_variable_set :@new_platform, Gem::Platform::RUBY
|
261
|
+
attr_accessor :signing_key
|
345
262
|
|
346
|
-
|
347
|
-
|
263
|
+
def self._all # :nodoc:
|
264
|
+
unless defined?(@@all) && @@all then
|
265
|
+
@@all = self.dirs.reverse.map { |dir|
|
266
|
+
Dir[File.join(dir, "*.gemspec")].map { |path|
|
267
|
+
Gem::Specification.load path
|
268
|
+
}
|
269
|
+
}.flatten
|
270
|
+
_resort!
|
271
|
+
end
|
272
|
+
@@all
|
273
|
+
end
|
348
274
|
|
349
|
-
|
275
|
+
def self._resort! # :nodoc:
|
276
|
+
@@all.sort! { |a, b|
|
277
|
+
names = a.name <=> b.name
|
278
|
+
next names if names.nonzero?
|
279
|
+
b.version <=> a.version
|
280
|
+
}
|
350
281
|
end
|
351
282
|
|
352
283
|
##
|
353
|
-
#
|
284
|
+
# Adds +spec+ to the known specifications, keeping the collection
|
285
|
+
# properly sorted.
|
354
286
|
|
355
|
-
def
|
356
|
-
|
357
|
-
|
358
|
-
|
287
|
+
def self.add_spec spec
|
288
|
+
# TODO: find all extraneous adds
|
289
|
+
# puts
|
290
|
+
# p :add_spec => [spec.full_name, caller.reject { |s| s =~ /minitest/ }]
|
359
291
|
|
360
|
-
|
361
|
-
|
362
|
-
|
292
|
+
# TODO: flush the rest of the crap from the tests
|
293
|
+
# raise "no dupes #{spec.full_name} in #{all_names.inspect}" if
|
294
|
+
# _all.include? spec
|
363
295
|
|
364
|
-
|
365
|
-
val = other_spec.instance_variable_get(name)
|
366
|
-
if val then
|
367
|
-
instance_variable_set name, val.dup
|
368
|
-
else
|
369
|
-
warn "WARNING: #{full_name} has an invalid nil value for #{name}"
|
370
|
-
end
|
371
|
-
rescue TypeError
|
372
|
-
e = Gem::FormatException.new \
|
373
|
-
"#{full_name} has an invalid value for #{name}"
|
296
|
+
raise "nil spec!" unless spec # TODO: remove once we're happy with tests
|
374
297
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
298
|
+
return if _all.include? spec
|
299
|
+
|
300
|
+
_all << spec
|
301
|
+
_resort!
|
379
302
|
end
|
380
303
|
|
381
304
|
##
|
382
|
-
#
|
383
|
-
# from a YAML file, it bypasses the normal Ruby object initialization
|
384
|
-
# routine (#initialize). This method makes up for that and deals with
|
385
|
-
# gems of different ages.
|
386
|
-
#
|
387
|
-
# 'input' can be anything that YAML.load() accepts: String or IO.
|
305
|
+
# Adds multiple specs to the known specifications.
|
388
306
|
|
389
|
-
def self.
|
390
|
-
|
391
|
-
spec = YAML.load input
|
307
|
+
def self.add_specs *specs
|
308
|
+
raise "nil spec!" if specs.any?(&:nil?) # TODO: remove once we're happy
|
392
309
|
|
393
|
-
|
394
|
-
|
395
|
-
|
310
|
+
# TODO: this is much more efficient, but we need the extra checks for now
|
311
|
+
# _all.concat specs
|
312
|
+
# _resort!
|
396
313
|
|
397
|
-
|
398
|
-
|
314
|
+
specs.each do |spec| # TODO: slow
|
315
|
+
add_spec spec
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
##
|
320
|
+
# Returns all specifications. This method is discouraged from use.
|
321
|
+
# You probably want to use one of the Enumerable methods instead.
|
322
|
+
|
323
|
+
def self.all
|
324
|
+
warn "NOTE: Specification.all called from #{caller.first}" unless
|
325
|
+
Deprecate.skip
|
326
|
+
_all
|
327
|
+
end
|
328
|
+
|
329
|
+
##
|
330
|
+
# Sets the known specs to +specs+. Not guaranteed to work for you in
|
331
|
+
# the future. Use at your own risk. Caveat emptor. Doomy doom doom.
|
332
|
+
# Etc etc.
|
333
|
+
#
|
334
|
+
#--
|
335
|
+
# Makes +specs+ the known specs
|
336
|
+
# Listen, time is a river
|
337
|
+
# Winter comes, code breaks
|
338
|
+
#
|
339
|
+
# -- wilsonb
|
340
|
+
|
341
|
+
def self.all= specs
|
342
|
+
@@all = specs
|
343
|
+
end
|
344
|
+
|
345
|
+
##
|
346
|
+
# Return full names of all specs in sorted order.
|
347
|
+
|
348
|
+
def self.all_names
|
349
|
+
self._all.map(&:full_name)
|
350
|
+
end
|
351
|
+
|
352
|
+
##
|
353
|
+
# Return the list of all array-oriented instance variables.
|
354
|
+
#--
|
355
|
+
# Not sure why we need to use so much stupid reflection in here...
|
356
|
+
|
357
|
+
def self.array_attributes
|
358
|
+
@@array_attributes.dup
|
359
|
+
end
|
360
|
+
|
361
|
+
##
|
362
|
+
# Return the list of all instance variables.
|
363
|
+
#--
|
364
|
+
# Not sure why we need to use so much stupid reflection in here...
|
365
|
+
|
366
|
+
def self.attribute_names
|
367
|
+
@@attributes.dup
|
368
|
+
end
|
369
|
+
|
370
|
+
##
|
371
|
+
# Return the directories that Specification uses to find specs.
|
372
|
+
|
373
|
+
def self.dirs
|
374
|
+
@@dirs ||= Gem.path.collect { |dir|
|
375
|
+
File.join dir, "specifications"
|
376
|
+
}
|
377
|
+
end
|
378
|
+
|
379
|
+
##
|
380
|
+
# Set the directories that Specification uses to find specs. Setting
|
381
|
+
# this resets the list of known specs.
|
382
|
+
|
383
|
+
def self.dirs= dirs
|
384
|
+
# TODO: find extra calls to dir=
|
385
|
+
# warn "NOTE: dirs= called from #{caller.first} for #{dirs.inspect}"
|
386
|
+
|
387
|
+
self.reset
|
388
|
+
|
389
|
+
# ugh
|
390
|
+
@@dirs = Array(dirs).map { |dir| File.join dir, "specifications" }
|
391
|
+
end
|
392
|
+
|
393
|
+
extend Enumerable
|
394
|
+
|
395
|
+
##
|
396
|
+
# Enumerate every known spec. See ::dirs= and ::add_spec to set the list of
|
397
|
+
# specs.
|
398
|
+
|
399
|
+
def self.each
|
400
|
+
return enum_for(:each) unless block_given?
|
401
|
+
|
402
|
+
self._all.each do |x|
|
403
|
+
yield x
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
##
|
408
|
+
# Returns every spec that matches +name+ and optional +requirements+.
|
409
|
+
|
410
|
+
def self.find_all_by_name name, *requirements
|
411
|
+
requirements = Gem::Requirement.default if requirements.empty?
|
412
|
+
|
413
|
+
# TODO: maybe try: find_all { |s| spec === dep }
|
414
|
+
|
415
|
+
Gem::Dependency.new(name, *requirements).matching_specs
|
416
|
+
end
|
417
|
+
|
418
|
+
##
|
419
|
+
# Find the best specification matching a +name+ and +requirements+. Raises
|
420
|
+
# if the dependency doesn't resolve to a valid specification.
|
421
|
+
|
422
|
+
def self.find_by_name name, *requirements
|
423
|
+
requirements = Gem::Requirement.default if requirements.empty?
|
424
|
+
|
425
|
+
# TODO: maybe try: find { |s| spec === dep }
|
426
|
+
|
427
|
+
Gem::Dependency.new(name, *requirements).to_spec
|
428
|
+
end
|
429
|
+
|
430
|
+
##
|
431
|
+
# Return the best specification that contains the file matching +path+.
|
432
|
+
|
433
|
+
def self.find_by_path path
|
434
|
+
self.find { |spec|
|
435
|
+
spec.contains_requirable_file? path
|
436
|
+
}
|
437
|
+
end
|
438
|
+
|
439
|
+
##
|
440
|
+
# Return currently unresolved specs that contain the file matching +path+.
|
441
|
+
|
442
|
+
def self.find_in_unresolved path
|
443
|
+
# TODO: do we need these?? Kill it
|
444
|
+
specs = Gem.unresolved_deps.values.map { |dep| dep.to_specs }.flatten
|
445
|
+
|
446
|
+
specs.find_all { |spec| spec.contains_requirable_file? path }
|
447
|
+
end
|
448
|
+
|
449
|
+
##
|
450
|
+
# Search through all unresolved deps and sub-dependencies and return
|
451
|
+
# specs that contain the file matching +path+.
|
452
|
+
|
453
|
+
def self.find_in_unresolved_tree path
|
454
|
+
specs = Gem.unresolved_deps.values.map { |dep| dep.to_specs }.flatten
|
455
|
+
|
456
|
+
specs.reverse_each do |spec|
|
457
|
+
trails = []
|
458
|
+
spec.traverse do |from_spec, dep, to_spec, trail|
|
459
|
+
next unless to_spec.conflicts.empty?
|
460
|
+
trails << trail if to_spec.contains_requirable_file? path
|
461
|
+
end
|
462
|
+
|
463
|
+
next if trails.empty?
|
464
|
+
|
465
|
+
return trails.map(&:reverse).sort.first.reverse
|
466
|
+
end
|
467
|
+
|
468
|
+
[]
|
469
|
+
end
|
470
|
+
|
471
|
+
##
|
472
|
+
# Special loader for YAML files. When a Specification object is loaded
|
473
|
+
# from a YAML file, it bypasses the normal Ruby object initialization
|
474
|
+
# routine (#initialize). This method makes up for that and deals with
|
475
|
+
# gems of different ages.
|
476
|
+
#
|
477
|
+
# +input+ can be anything that YAML.load() accepts: String or IO.
|
478
|
+
|
479
|
+
def self.from_yaml(input)
|
480
|
+
input = normalize_yaml_input input
|
481
|
+
spec = YAML.load input
|
482
|
+
|
483
|
+
if spec && spec.class == FalseClass then
|
484
|
+
raise Gem::EndOfYAMLException
|
485
|
+
end
|
486
|
+
|
487
|
+
unless Gem::Specification === spec then
|
488
|
+
raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
|
399
489
|
end
|
400
490
|
|
401
491
|
unless (spec.instance_variables.include? '@specification_version' or
|
@@ -408,6 +498,27 @@ class Gem::Specification
|
|
408
498
|
spec
|
409
499
|
end
|
410
500
|
|
501
|
+
##
|
502
|
+
# Return the latest specs, optionally including prerelease specs if
|
503
|
+
# +prerelease+ is true.
|
504
|
+
|
505
|
+
def self.latest_specs prerelease = false
|
506
|
+
result = Hash.new { |h,k| h[k] = {} }
|
507
|
+
native = {}
|
508
|
+
|
509
|
+
Gem::Specification._all.reverse_each do |spec|
|
510
|
+
next if spec.version.prerelease? unless prerelease
|
511
|
+
|
512
|
+
native[spec.name] = spec.version if spec.platform == Gem::Platform::RUBY
|
513
|
+
result[spec.name][spec.platform] = spec
|
514
|
+
end
|
515
|
+
|
516
|
+
result.map(&:last).map(&:values).flatten.reject { |spec|
|
517
|
+
minimum = native[spec.name]
|
518
|
+
minimum && spec.version < minimum
|
519
|
+
}
|
520
|
+
end
|
521
|
+
|
411
522
|
##
|
412
523
|
# Loads Ruby format gemspec from +file+.
|
413
524
|
|
@@ -428,7 +539,7 @@ class Gem::Specification
|
|
428
539
|
spec = eval code, binding, file
|
429
540
|
|
430
541
|
if Gem::Specification === spec
|
431
|
-
spec.loaded_from = file
|
542
|
+
spec.loaded_from = file.to_s
|
432
543
|
return spec
|
433
544
|
end
|
434
545
|
|
@@ -442,6 +553,13 @@ class Gem::Specification
|
|
442
553
|
nil
|
443
554
|
end
|
444
555
|
|
556
|
+
##
|
557
|
+
# Specification attributes that must be non-nil
|
558
|
+
|
559
|
+
def self.non_nil_attributes
|
560
|
+
@@non_nil_attributes.dup
|
561
|
+
end
|
562
|
+
|
445
563
|
##
|
446
564
|
# Make sure the YAML specification is properly formatted with dashes
|
447
565
|
|
@@ -452,458 +570,430 @@ class Gem::Specification
|
|
452
570
|
end
|
453
571
|
|
454
572
|
##
|
455
|
-
#
|
573
|
+
# Removes +spec+ from the known specs.
|
456
574
|
|
457
|
-
def
|
458
|
-
|
575
|
+
def self.remove_spec spec
|
576
|
+
# TODO: beat on the tests
|
577
|
+
raise "wtf: #{spec.full_name} not in #{all_names.inspect}" unless
|
578
|
+
_all.include? spec
|
579
|
+
_all.delete spec
|
459
580
|
end
|
460
581
|
|
461
582
|
##
|
462
|
-
#
|
583
|
+
# Is +name+ a required attribute?
|
463
584
|
|
464
|
-
def
|
465
|
-
|
466
|
-
sym.to_s =~ /=$/ then
|
467
|
-
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
|
468
|
-
else
|
469
|
-
super
|
470
|
-
end
|
585
|
+
def self.required_attribute?(name)
|
586
|
+
@@required_attributes.include? name.to_sym
|
471
587
|
end
|
472
588
|
|
473
589
|
##
|
474
|
-
#
|
475
|
-
# Gem. For example:
|
476
|
-
#
|
477
|
-
# spec.add_development_dependency 'jabber4r', '> 0.1', '<= 0.5'
|
478
|
-
#
|
479
|
-
# Development dependencies aren't installed by default and aren't
|
480
|
-
# activated when a gem is required.
|
590
|
+
# Required specification attributes
|
481
591
|
|
482
|
-
def
|
483
|
-
|
592
|
+
def self.required_attributes
|
593
|
+
@@required_attributes.dup
|
484
594
|
end
|
485
595
|
|
486
596
|
##
|
487
|
-
#
|
488
|
-
#
|
489
|
-
#
|
490
|
-
# spec.add_runtime_dependency 'jabber4r', '> 0.1', '<= 0.5'
|
597
|
+
# Reset the list of known specs, running pre and post reset hooks
|
598
|
+
# registered in Gem.
|
491
599
|
|
492
|
-
def
|
493
|
-
|
600
|
+
def self.reset
|
601
|
+
@@dirs = nil
|
602
|
+
# from = caller.first(10).reject { |s| s =~ /minitest/ }
|
603
|
+
# warn ""
|
604
|
+
# warn "NOTE: Specification.reset from #{from.inspect}"
|
605
|
+
Gem.pre_reset_hooks.each { |hook| hook.call }
|
606
|
+
@@all = nil
|
607
|
+
Gem.post_reset_hooks.each { |hook| hook.call }
|
494
608
|
end
|
495
609
|
|
496
610
|
##
|
497
|
-
#
|
611
|
+
# Load custom marshal format, re-initializing defaults as needed
|
498
612
|
|
499
|
-
|
613
|
+
def self._load(str)
|
614
|
+
array = Marshal.load str
|
500
615
|
|
501
|
-
|
502
|
-
|
503
|
-
# is included (name-version-platform) if it is specified and not the
|
504
|
-
# default Ruby platform.
|
616
|
+
spec = Gem::Specification.new
|
617
|
+
spec.instance_variable_set :@specification_version, array[1]
|
505
618
|
|
506
|
-
|
507
|
-
if platform == Gem::Platform::RUBY or platform.nil? then
|
508
|
-
"#{@name}-#{@version}"
|
509
|
-
else
|
510
|
-
"#{@name}-#{@version}-#{platform}"
|
511
|
-
end
|
512
|
-
end
|
619
|
+
current_version = CURRENT_SPECIFICATION_VERSION
|
513
620
|
|
514
|
-
|
515
|
-
|
516
|
-
|
621
|
+
field_count = if spec.specification_version > current_version then
|
622
|
+
spec.instance_variable_set :@specification_version,
|
623
|
+
current_version
|
624
|
+
MARSHAL_FIELDS[current_version]
|
625
|
+
else
|
626
|
+
MARSHAL_FIELDS[spec.specification_version]
|
627
|
+
end
|
517
628
|
|
518
|
-
|
519
|
-
|
520
|
-
"#{@name}-#{@version}"
|
521
|
-
else
|
522
|
-
"#{@name}-#{@version}-#{@original_platform}"
|
629
|
+
if array.size < field_count then
|
630
|
+
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
523
631
|
end
|
632
|
+
|
633
|
+
spec.instance_variable_set :@rubygems_version, array[0]
|
634
|
+
# spec version
|
635
|
+
spec.instance_variable_set :@name, array[2]
|
636
|
+
spec.instance_variable_set :@version, array[3]
|
637
|
+
spec.instance_variable_set :@date, array[4]
|
638
|
+
spec.instance_variable_set :@summary, array[5]
|
639
|
+
spec.instance_variable_set :@required_ruby_version, array[6]
|
640
|
+
spec.instance_variable_set :@required_rubygems_version, array[7]
|
641
|
+
spec.instance_variable_set :@original_platform, array[8]
|
642
|
+
spec.instance_variable_set :@dependencies, array[9]
|
643
|
+
spec.instance_variable_set :@rubyforge_project, array[10]
|
644
|
+
spec.instance_variable_set :@email, array[11]
|
645
|
+
spec.instance_variable_set :@authors, array[12]
|
646
|
+
spec.instance_variable_set :@description, array[13]
|
647
|
+
spec.instance_variable_set :@homepage, array[14]
|
648
|
+
spec.instance_variable_set :@has_rdoc, array[15]
|
649
|
+
spec.instance_variable_set :@new_platform, array[16]
|
650
|
+
spec.instance_variable_set :@platform, array[16].to_s
|
651
|
+
spec.instance_variable_set :@license, array[17]
|
652
|
+
spec.instance_variable_set :@loaded, false
|
653
|
+
|
654
|
+
spec
|
524
655
|
end
|
525
656
|
|
526
|
-
|
527
|
-
|
657
|
+
def <=>(other) # :nodoc:
|
658
|
+
sort_obj <=> other.sort_obj
|
659
|
+
end
|
528
660
|
|
529
|
-
def
|
530
|
-
|
531
|
-
|
532
|
-
|
661
|
+
def == other # :nodoc:
|
662
|
+
self.class === other &&
|
663
|
+
name == other.name &&
|
664
|
+
version == other.version &&
|
665
|
+
platform == other.platform
|
533
666
|
end
|
534
667
|
|
535
668
|
##
|
536
|
-
#
|
537
|
-
|
538
|
-
#
|
669
|
+
# Dump only crucial instance variables.
|
670
|
+
#--
|
671
|
+
# MAINTAIN ORDER!
|
672
|
+
# (down with the man)
|
539
673
|
|
540
|
-
def
|
541
|
-
|
674
|
+
def _dump(limit)
|
675
|
+
Marshal.dump [
|
676
|
+
@rubygems_version,
|
677
|
+
@specification_version,
|
678
|
+
@name,
|
679
|
+
@version,
|
680
|
+
date,
|
681
|
+
@summary,
|
682
|
+
@required_ruby_version,
|
683
|
+
@required_rubygems_version,
|
684
|
+
@original_platform,
|
685
|
+
@dependencies,
|
686
|
+
@rubyforge_project,
|
687
|
+
@email,
|
688
|
+
@authors,
|
689
|
+
@description,
|
690
|
+
@homepage,
|
691
|
+
true, # has_rdoc
|
692
|
+
@new_platform,
|
693
|
+
@licenses
|
694
|
+
]
|
542
695
|
end
|
543
696
|
|
544
697
|
##
|
545
|
-
#
|
698
|
+
# Activate this spec, registering it as a loaded spec and adding
|
699
|
+
# it's lib paths to $LOAD_PATH. Returns true if the spec was
|
700
|
+
# activated, false if it was previously activated. Freaks out if
|
701
|
+
# there are conflicts upon activation.
|
546
702
|
|
547
|
-
def
|
548
|
-
|
549
|
-
raise Gem::Exception, "spec #{full_name} is not from an installed gem"
|
550
|
-
end
|
703
|
+
def activate
|
704
|
+
raise_if_conflicts
|
551
705
|
|
552
|
-
|
553
|
-
end
|
706
|
+
return false if Gem.loaded_specs[self.name]
|
554
707
|
|
555
|
-
|
556
|
-
|
708
|
+
activate_dependencies
|
709
|
+
add_self_to_load_path
|
557
710
|
|
558
|
-
|
559
|
-
|
560
|
-
|
711
|
+
Gem.loaded_specs[self.name] = self
|
712
|
+
self.activated = true
|
713
|
+
|
714
|
+
return true
|
561
715
|
end
|
562
716
|
|
563
717
|
##
|
564
|
-
#
|
718
|
+
# Activate all unambiguously resolved runtime dependencies of this
|
719
|
+
# spec. Add any ambigous dependencies to the unresolved list to be
|
720
|
+
# resolved later, as needed.
|
565
721
|
|
566
|
-
def
|
567
|
-
|
722
|
+
def activate_dependencies
|
723
|
+
self.runtime_dependencies.each do |spec_dep|
|
724
|
+
# TODO: check for conflicts! not just name!
|
725
|
+
next if Gem.loaded_specs.include? spec_dep.name
|
726
|
+
specs = spec_dep.to_specs
|
727
|
+
|
728
|
+
if specs.size == 1 then
|
729
|
+
specs.first.activate
|
730
|
+
else
|
731
|
+
name = spec_dep.name
|
732
|
+
Gem.unresolved_deps[name] = Gem.unresolved_deps[name].merge spec_dep
|
733
|
+
end
|
734
|
+
end
|
735
|
+
|
736
|
+
Gem.unresolved_deps.delete self.name
|
568
737
|
end
|
569
738
|
|
570
739
|
##
|
571
|
-
#
|
572
|
-
#
|
573
|
-
# spec.spec_name # => "example-1.0.gemspec"
|
740
|
+
# Returns an array with bindir attached to each executable in the
|
741
|
+
# +executables+ list
|
574
742
|
|
575
|
-
def
|
576
|
-
|
577
|
-
end
|
743
|
+
def add_bindir(executables)
|
744
|
+
return nil if executables.nil?
|
578
745
|
|
579
|
-
|
580
|
-
|
746
|
+
if @bindir then
|
747
|
+
Array(executables).map { |e| File.join(@bindir, e) }
|
748
|
+
else
|
749
|
+
executables
|
750
|
+
end
|
751
|
+
rescue
|
752
|
+
return nil
|
581
753
|
end
|
582
754
|
|
583
755
|
##
|
584
|
-
#
|
756
|
+
# Adds a dependency on gem +dependency+ with type +type+ that requires
|
757
|
+
# +requirements+. Valid types are currently <tt>:runtime</tt> and
|
758
|
+
# <tt>:development</tt>.
|
585
759
|
|
586
|
-
def
|
587
|
-
|
760
|
+
def add_dependency_with_type(dependency, type, *requirements)
|
761
|
+
requirements = if requirements.empty? then
|
762
|
+
Gem::Requirement.default
|
763
|
+
else
|
764
|
+
requirements.flatten
|
765
|
+
end
|
766
|
+
|
767
|
+
unless dependency.respond_to?(:name) &&
|
768
|
+
dependency.respond_to?(:version_requirements)
|
769
|
+
|
770
|
+
dependency = Gem::Dependency.new(dependency, requirements, type)
|
771
|
+
end
|
772
|
+
|
773
|
+
dependencies << dependency
|
588
774
|
end
|
589
775
|
|
590
|
-
|
776
|
+
private :add_dependency_with_type
|
591
777
|
|
592
778
|
##
|
593
|
-
#
|
779
|
+
# Adds a development dependency named +gem+ with +requirements+ to this
|
780
|
+
# Gem. For example:
|
781
|
+
#
|
782
|
+
# spec.add_development_dependency 'example', '~> 1.1', '>= 1.1.4'
|
594
783
|
#
|
595
|
-
|
596
|
-
|
597
|
-
|
784
|
+
# Development dependencies aren't installed by default and aren't
|
785
|
+
# activated when a gem is required.
|
786
|
+
|
787
|
+
def add_development_dependency(gem, *requirements)
|
788
|
+
add_dependency_with_type(gem, :development, *requirements)
|
598
789
|
end
|
599
790
|
|
600
791
|
##
|
601
|
-
#
|
792
|
+
# Adds a runtime dependency named +gem+ with +requirements+ to this Gem.
|
793
|
+
# For example:
|
794
|
+
#
|
795
|
+
# spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4'
|
602
796
|
|
603
|
-
def
|
604
|
-
|
605
|
-
return false unless self.send(name) == other.send(name)
|
606
|
-
end
|
607
|
-
true
|
797
|
+
def add_runtime_dependency(gem, *requirements)
|
798
|
+
add_dependency_with_type(gem, :runtime, *requirements)
|
608
799
|
end
|
609
800
|
|
610
|
-
|
801
|
+
alias add_dependency add_runtime_dependency
|
611
802
|
|
612
|
-
|
613
|
-
|
614
|
-
hash_code ^ self.send(name).hash
|
615
|
-
}
|
616
|
-
end
|
803
|
+
##
|
804
|
+
# Adds this spec's require paths to LOAD_PATH, in the proper location.
|
617
805
|
|
618
|
-
def
|
619
|
-
|
806
|
+
def add_self_to_load_path
|
807
|
+
paths = require_paths.map do |path|
|
808
|
+
File.join full_gem_path, path
|
809
|
+
end
|
620
810
|
|
621
|
-
|
622
|
-
|
623
|
-
platform = case @original_platform
|
624
|
-
when nil, '' then
|
625
|
-
'ruby'
|
626
|
-
when String then
|
627
|
-
@original_platform
|
628
|
-
else
|
629
|
-
@original_platform.to_s
|
630
|
-
end
|
631
|
-
coder.add 'platform', platform
|
811
|
+
# gem directories must come after -I and ENV['RUBYLIB']
|
812
|
+
insert_index = Gem.load_path_insert_index
|
632
813
|
|
633
|
-
|
634
|
-
|
635
|
-
|
814
|
+
if insert_index then
|
815
|
+
# gem directories must come after -I and ENV['RUBYLIB']
|
816
|
+
$LOAD_PATH.insert(insert_index, *paths)
|
817
|
+
else
|
818
|
+
# we are probably testing in core, -I and RUBYLIB don't apply
|
819
|
+
$LOAD_PATH.unshift(*paths)
|
636
820
|
end
|
637
821
|
end
|
638
822
|
|
639
823
|
##
|
640
|
-
#
|
824
|
+
# Singular reader for #authors
|
641
825
|
|
642
|
-
def
|
643
|
-
|
826
|
+
def author
|
827
|
+
val = authors and val.first
|
828
|
+
end
|
644
829
|
|
645
|
-
|
646
|
-
|
830
|
+
##
|
831
|
+
# Singular writer for #authors
|
647
832
|
|
648
|
-
|
833
|
+
def author= o
|
834
|
+
self.authors = [o]
|
649
835
|
end
|
650
836
|
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
837
|
+
##
|
838
|
+
# The list of author names who wrote this gem.
|
839
|
+
#
|
840
|
+
# If you are providing multiple authors and multiple emails they should be
|
841
|
+
# in the same order such that:
|
842
|
+
#
|
843
|
+
# Hash[*spec.authors.zip(spec.emails).flatten]
|
844
|
+
#
|
845
|
+
# Gives a hash of author name to email address.
|
846
|
+
|
847
|
+
def authors
|
848
|
+
@authors ||= []
|
661
849
|
end
|
662
850
|
|
663
|
-
|
664
|
-
|
851
|
+
##
|
852
|
+
# Sets the list of authors, ensuring it is an array.
|
853
|
+
|
854
|
+
def authors= value
|
855
|
+
@authors = Array(value).flatten.grep(String)
|
665
856
|
end
|
666
857
|
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
858
|
+
##
|
859
|
+
# Returns the full path to the base gem directory.
|
860
|
+
#
|
861
|
+
# eg: /usr/local/lib/ruby/gems/1.8
|
671
862
|
|
672
|
-
|
673
|
-
|
863
|
+
def base_dir
|
864
|
+
return Gem.dir unless loaded_from
|
865
|
+
@base_dir ||= File.dirname File.dirname loaded_from
|
674
866
|
end
|
675
867
|
|
676
868
|
##
|
677
|
-
# Returns
|
678
|
-
#
|
679
|
-
#
|
869
|
+
# Returns the full path to installed gem's bin directory.
|
870
|
+
#
|
871
|
+
# NOTE: do not confuse this with +bindir+, which is just 'bin', not
|
872
|
+
# a full path.
|
680
873
|
|
681
|
-
def
|
682
|
-
|
683
|
-
|
684
|
-
result << "# -*- encoding: utf-8 -*-"
|
685
|
-
result << nil
|
686
|
-
result << "Gem::Specification.new do |s|"
|
874
|
+
def bin_dir
|
875
|
+
@bin_dir ||= File.join gem_dir, bindir # TODO: this is unfortunate
|
876
|
+
end
|
687
877
|
|
688
|
-
|
689
|
-
|
690
|
-
unless platform.nil? or platform == Gem::Platform::RUBY then
|
691
|
-
result << " s.platform = #{ruby_code original_platform}"
|
692
|
-
end
|
693
|
-
result << ""
|
694
|
-
result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version="
|
878
|
+
##
|
879
|
+
# Returns the full path to an executable named +name+ in this gem.
|
695
880
|
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
:platform,
|
700
|
-
:required_rubygems_version,
|
701
|
-
:specification_version,
|
702
|
-
:version,
|
703
|
-
:has_rdoc,
|
704
|
-
]
|
881
|
+
def bin_file name
|
882
|
+
File.join bin_dir, name
|
883
|
+
end
|
705
884
|
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
if current_value != default_value(attr_name) or
|
710
|
-
self.class.required_attribute? attr_name then
|
711
|
-
result << " s.#{attr_name} = #{ruby_code current_value}"
|
712
|
-
end
|
713
|
-
end
|
885
|
+
##
|
886
|
+
# Returns the full path to the cache directory containing this
|
887
|
+
# spec's cached gem.
|
714
888
|
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
result << nil
|
889
|
+
def cache_dir
|
890
|
+
@cache_dir ||= File.join base_dir, "cache"
|
891
|
+
end
|
719
892
|
|
720
|
-
|
893
|
+
##
|
894
|
+
# Returns the full path to the cached gem for this spec.
|
721
895
|
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{req})"
|
726
|
-
end
|
896
|
+
def cache_file
|
897
|
+
@cache_file ||= File.join cache_dir, "#{full_name}.gem"
|
898
|
+
end
|
727
899
|
|
728
|
-
|
900
|
+
alias :cache_gem :cache_file
|
729
901
|
|
730
|
-
|
731
|
-
|
732
|
-
|
902
|
+
##
|
903
|
+
# Return any possible conflicts against the currently loaded specs.
|
904
|
+
|
905
|
+
def conflicts
|
906
|
+
conflicts = {}
|
907
|
+
Gem.loaded_specs.values.each do |spec|
|
908
|
+
bad = self.runtime_dependencies.find_all { |dep|
|
909
|
+
spec.name == dep.name and not spec.satisfies_requirement? dep
|
910
|
+
}
|
911
|
+
|
912
|
+
conflicts[spec] = bad unless bad.empty?
|
733
913
|
end
|
914
|
+
conflicts
|
915
|
+
end
|
734
916
|
|
735
|
-
|
917
|
+
##
|
918
|
+
# Return true if this spec can require +file+.
|
736
919
|
|
737
|
-
|
738
|
-
|
739
|
-
version_reqs_param = dep.requirements_list.inspect
|
740
|
-
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
741
|
-
end
|
742
|
-
result << " end"
|
920
|
+
def contains_requirable_file? file
|
921
|
+
root = full_gem_path
|
743
922
|
|
744
|
-
|
745
|
-
|
923
|
+
require_paths.each do |lib|
|
924
|
+
base = "#{root}/#{lib}/#{file}"
|
925
|
+
Gem.suffixes.each do |suf|
|
926
|
+
path = "#{base}#{suf}"
|
927
|
+
return true if File.file? path
|
928
|
+
end
|
929
|
+
end
|
746
930
|
|
747
|
-
|
931
|
+
return false
|
748
932
|
end
|
749
933
|
|
750
|
-
|
751
|
-
|
934
|
+
##
|
935
|
+
# The date this gem was created. Lazily defaults to TODAY.
|
936
|
+
|
937
|
+
def date
|
938
|
+
@date ||= TODAY
|
752
939
|
end
|
753
940
|
|
754
941
|
##
|
755
|
-
#
|
756
|
-
# very basic sanity check.
|
942
|
+
# The date this gem was created
|
757
943
|
#
|
758
|
-
#
|
759
|
-
# checks..
|
944
|
+
# Do not set this, it is set automatically when the gem is packaged.
|
760
945
|
|
761
|
-
def
|
762
|
-
|
763
|
-
|
764
|
-
|
946
|
+
def date= date
|
947
|
+
# We want to end up with a Time object with one-day resolution.
|
948
|
+
# This is the cleanest, most-readable, faster-than-using-Date
|
949
|
+
# way to do it.
|
950
|
+
@date = case date
|
951
|
+
when String then
|
952
|
+
if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
|
953
|
+
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
954
|
+
else
|
955
|
+
raise(Gem::InvalidSpecificationException,
|
956
|
+
"invalid date format in specification: #{date.inspect}")
|
957
|
+
end
|
958
|
+
when Time, Date then
|
959
|
+
Time.utc(date.year, date.month, date.day)
|
960
|
+
else
|
961
|
+
TODAY
|
962
|
+
end
|
963
|
+
end
|
765
964
|
|
766
|
-
|
767
|
-
|
768
|
-
|
965
|
+
##
|
966
|
+
# The default executable for this gem.
|
967
|
+
#
|
968
|
+
# Deprecated: The name of the gem is assumed to be the name of the
|
969
|
+
# executable now. See Gem.bin_path.
|
769
970
|
|
770
|
-
|
771
|
-
|
772
|
-
|
971
|
+
def default_executable
|
972
|
+
if defined?(@default_executable) and @default_executable
|
973
|
+
result = @default_executable
|
974
|
+
elsif @executables and @executables.size == 1
|
975
|
+
result = Array(@executables).first
|
976
|
+
else
|
977
|
+
result = nil
|
773
978
|
end
|
979
|
+
result
|
980
|
+
end
|
774
981
|
|
775
|
-
|
776
|
-
|
777
|
-
"expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
|
778
|
-
end
|
982
|
+
##
|
983
|
+
# The default value for specification attribute +name+
|
779
984
|
|
780
|
-
|
781
|
-
|
782
|
-
raise Gem::InvalidSpecificationException,
|
783
|
-
"missing value for attribute #{symbol}"
|
784
|
-
end
|
785
|
-
end
|
786
|
-
|
787
|
-
unless String === name then
|
788
|
-
raise Gem::InvalidSpecificationException,
|
789
|
-
"invalid value for attribute name: \"#{name.inspect}\""
|
790
|
-
end
|
791
|
-
|
792
|
-
if require_paths.empty? then
|
793
|
-
raise Gem::InvalidSpecificationException,
|
794
|
-
'specification must have at least one require_path'
|
795
|
-
end
|
796
|
-
|
797
|
-
@files.delete_if do |file| File.directory? file end
|
798
|
-
@test_files.delete_if do |file| File.directory? file end
|
799
|
-
@executables.delete_if do |file|
|
800
|
-
File.directory? File.join(bindir, file)
|
801
|
-
end
|
802
|
-
@extra_rdoc_files.delete_if do |file| File.directory? file end
|
803
|
-
@extensions.delete_if do |file| File.directory? file end
|
804
|
-
|
805
|
-
non_files = files.select do |file|
|
806
|
-
!File.file? file
|
807
|
-
end
|
808
|
-
|
809
|
-
unless not packaging or non_files.empty? then
|
810
|
-
non_files = non_files.map { |file| file.inspect }
|
811
|
-
raise Gem::InvalidSpecificationException,
|
812
|
-
"[#{non_files.join ", "}] are not files"
|
813
|
-
end
|
814
|
-
|
815
|
-
unless specification_version.is_a?(Fixnum)
|
816
|
-
raise Gem::InvalidSpecificationException,
|
817
|
-
'specification_version must be a Fixnum (did you mean version?)'
|
818
|
-
end
|
819
|
-
|
820
|
-
case platform
|
821
|
-
when Gem::Platform, Gem::Platform::RUBY then # ok
|
822
|
-
else
|
823
|
-
raise Gem::InvalidSpecificationException,
|
824
|
-
"invalid platform #{platform.inspect}, see Gem::Platform"
|
825
|
-
end
|
826
|
-
|
827
|
-
self.class.array_attributes.each do |symbol|
|
828
|
-
val = self.send symbol
|
829
|
-
klass = symbol == :dependencies ? Gem::Dependency : String
|
830
|
-
|
831
|
-
unless Array === val and val.all? { |x| klass === x } then
|
832
|
-
raise(Gem::InvalidSpecificationException,
|
833
|
-
"#{symbol} must be an Array of #{klass} instances")
|
834
|
-
end
|
835
|
-
end
|
836
|
-
|
837
|
-
licenses.each { |license|
|
838
|
-
if license.length > 64
|
839
|
-
raise Gem::InvalidSpecificationException,
|
840
|
-
"each license must be 64 characters or less"
|
841
|
-
end
|
842
|
-
}
|
843
|
-
|
844
|
-
# reject lazy developers:
|
845
|
-
|
846
|
-
lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
|
847
|
-
|
848
|
-
unless authors.grep(/FI XME|TO DO/x).empty? then
|
849
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not an author"
|
850
|
-
end
|
851
|
-
|
852
|
-
unless Array(email).grep(/FI XME|TO DO/x).empty? then
|
853
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not an email"
|
854
|
-
end
|
855
|
-
|
856
|
-
if description =~ /FI XME|TO DO/x then
|
857
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not a description"
|
858
|
-
end
|
859
|
-
|
860
|
-
if summary =~ /FI XME|TO DO/x then
|
861
|
-
raise Gem::InvalidSpecificationException, "#{lazy} is not a summary"
|
862
|
-
end
|
863
|
-
|
864
|
-
if homepage and not homepage.empty? and
|
865
|
-
homepage !~ /\A[a-z][a-z\d+.-]*:/i then
|
866
|
-
raise Gem::InvalidSpecificationException,
|
867
|
-
"\"#{homepage}\" is not a URI"
|
868
|
-
end
|
869
|
-
|
870
|
-
# Warnings
|
871
|
-
|
872
|
-
%w[author description email homepage summary].each do |attribute|
|
873
|
-
value = self.send attribute
|
874
|
-
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
|
875
|
-
end
|
876
|
-
|
877
|
-
if description == summary then
|
878
|
-
alert_warning 'description and summary are identical'
|
879
|
-
end
|
880
|
-
|
881
|
-
# TODO: raise at some given date
|
882
|
-
alert_warning "deprecated autorequire specified" if autorequire
|
883
|
-
|
884
|
-
executables.each do |executable|
|
885
|
-
executable_path = File.join bindir, executable
|
886
|
-
shebang = File.read(executable_path, 2) == '#!'
|
887
|
-
|
888
|
-
alert_warning "#{executable_path} is missing #! line" unless shebang
|
889
|
-
end
|
890
|
-
|
891
|
-
true
|
985
|
+
def default_value name
|
986
|
+
@@default_value[name]
|
892
987
|
end
|
893
988
|
|
894
989
|
##
|
895
|
-
#
|
896
|
-
#
|
897
|
-
#
|
898
|
-
#
|
990
|
+
# A list of Gem::Dependency objects this gem depends on.
|
991
|
+
#
|
992
|
+
# Use #add_dependency or #add_development_dependency to add dependencies to
|
993
|
+
# a gem.
|
899
994
|
|
900
|
-
def
|
901
|
-
|
902
|
-
@extra_rdoc_files.uniq!
|
903
|
-
@files ||= []
|
904
|
-
@files.concat(@extra_rdoc_files)
|
905
|
-
end
|
906
|
-
@files.uniq! if @files
|
995
|
+
def dependencies
|
996
|
+
@dependencies ||= []
|
907
997
|
end
|
908
998
|
|
909
999
|
##
|
@@ -914,379 +1004,372 @@ class Gem::Specification
|
|
914
1004
|
|
915
1005
|
def dependent_gems
|
916
1006
|
out = []
|
917
|
-
Gem.
|
918
|
-
|
1007
|
+
Gem::Specification.each do |spec|
|
1008
|
+
spec.dependencies.each do |dep|
|
919
1009
|
if self.satisfies_requirement?(dep) then
|
920
1010
|
sats = []
|
921
1011
|
find_all_satisfiers(dep) do |sat|
|
922
1012
|
sats << sat
|
923
1013
|
end
|
924
|
-
out << [
|
1014
|
+
out << [spec, dep, sats]
|
925
1015
|
end
|
926
1016
|
end
|
927
1017
|
end
|
928
1018
|
out
|
929
1019
|
end
|
930
1020
|
|
931
|
-
|
932
|
-
|
933
|
-
end
|
934
|
-
|
935
|
-
def pretty_print(q) # :nodoc:
|
936
|
-
q.group 2, 'Gem::Specification.new do |s|', 'end' do
|
937
|
-
q.breakable
|
1021
|
+
##
|
1022
|
+
# Returns all specs that matches this spec's runtime dependencies.
|
938
1023
|
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
if current_value != default_value(attr_name) or
|
943
|
-
self.class.required_attribute? attr_name then
|
1024
|
+
def dependent_specs
|
1025
|
+
runtime_dependencies.map { |dep| dep.to_specs }.flatten
|
1026
|
+
end
|
944
1027
|
|
945
|
-
|
1028
|
+
##
|
1029
|
+
# A long description of this gem
|
946
1030
|
|
947
|
-
|
948
|
-
|
1031
|
+
def description= str
|
1032
|
+
@description = str.to_s
|
1033
|
+
end
|
949
1034
|
|
950
|
-
|
951
|
-
|
952
|
-
q.pp current_value
|
953
|
-
end
|
1035
|
+
##
|
1036
|
+
# List of dependencies that are used for development
|
954
1037
|
|
955
|
-
|
956
|
-
|
957
|
-
end
|
958
|
-
end
|
1038
|
+
def development_dependencies
|
1039
|
+
dependencies.select { |d| d.type == :development }
|
959
1040
|
end
|
960
1041
|
|
961
1042
|
##
|
962
|
-
#
|
963
|
-
# +requirements+. Valid types are currently <tt>:runtime</tt> and
|
964
|
-
# <tt>:development</tt>.
|
1043
|
+
# Returns the full path to this spec's documentation directory.
|
965
1044
|
|
966
|
-
def
|
967
|
-
|
968
|
-
|
969
|
-
else
|
970
|
-
requirements.flatten
|
971
|
-
end
|
1045
|
+
def doc_dir
|
1046
|
+
@doc_dir ||= File.join base_dir, 'doc', full_name
|
1047
|
+
end
|
972
1048
|
|
973
|
-
|
974
|
-
|
1049
|
+
def encode_with coder # :nodoc:
|
1050
|
+
mark_version
|
975
1051
|
|
976
|
-
|
977
|
-
|
1052
|
+
coder.add 'name', @name
|
1053
|
+
coder.add 'version', @version
|
1054
|
+
platform = case @original_platform
|
1055
|
+
when nil, '' then
|
1056
|
+
'ruby'
|
1057
|
+
when String then
|
1058
|
+
@original_platform
|
1059
|
+
else
|
1060
|
+
@original_platform.to_s
|
1061
|
+
end
|
1062
|
+
coder.add 'platform', platform
|
978
1063
|
|
979
|
-
|
1064
|
+
attributes = @@attributes.map(&:to_s) - %w[name version platform]
|
1065
|
+
attributes.each do |name|
|
1066
|
+
coder.add name, instance_variable_get("@#{name}")
|
1067
|
+
end
|
980
1068
|
end
|
981
1069
|
|
982
|
-
|
1070
|
+
def eql? other # :nodoc:
|
1071
|
+
self.class === other && same_attributes?(other)
|
1072
|
+
end
|
983
1073
|
|
984
1074
|
##
|
985
|
-
#
|
1075
|
+
# Singular accessor for #executables
|
986
1076
|
|
987
|
-
def
|
988
|
-
|
989
|
-
yield gem if gem.satisfies_requirement? dep
|
990
|
-
end
|
1077
|
+
def executable
|
1078
|
+
val = executables and val.first
|
991
1079
|
end
|
992
1080
|
|
993
|
-
private :find_all_satisfiers
|
994
|
-
|
995
1081
|
##
|
996
|
-
#
|
997
|
-
# object.
|
1082
|
+
# Singular accessor for #executables
|
998
1083
|
|
999
|
-
def
|
1000
|
-
|
1001
|
-
when String then '%q{' + obj + '}'
|
1002
|
-
when Array then obj.inspect
|
1003
|
-
when Gem::Version then obj.to_s.inspect
|
1004
|
-
when Date then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
1005
|
-
when Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
1006
|
-
when Numeric then obj.inspect
|
1007
|
-
when true, false, nil then obj.inspect
|
1008
|
-
when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
|
1009
|
-
when Gem::Requirement then "Gem::Requirement.new(#{obj.to_s.inspect})"
|
1010
|
-
else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
|
1011
|
-
end
|
1084
|
+
def executable=o
|
1085
|
+
self.executables = [o]
|
1012
1086
|
end
|
1013
1087
|
|
1014
|
-
|
1088
|
+
##
|
1089
|
+
# Executables included in the gem.
|
1015
1090
|
|
1016
|
-
|
1091
|
+
def executables
|
1092
|
+
@executables ||= []
|
1093
|
+
end
|
1017
1094
|
|
1018
1095
|
##
|
1019
|
-
#
|
1020
|
-
#
|
1021
|
-
# Do not set this, it is set automatically when the gem is packaged.
|
1096
|
+
# Sets executables to +value+, ensuring it is an array. Don't
|
1097
|
+
# use this, push onto the array instead.
|
1022
1098
|
|
1023
|
-
|
1099
|
+
def executables= value
|
1100
|
+
# TODO: warn about setting instead of pushing
|
1101
|
+
@executables = Array(value)
|
1102
|
+
end
|
1024
1103
|
|
1025
1104
|
##
|
1026
|
-
#
|
1027
|
-
#
|
1028
|
-
# Do not set this, it is set automatically when the gem is packaged.
|
1105
|
+
# Extensions to build when installing the gem. See
|
1106
|
+
# Gem::Installer#build_extensions for valid values.
|
1029
1107
|
|
1030
|
-
|
1108
|
+
def extensions
|
1109
|
+
@extensions ||= []
|
1110
|
+
end
|
1031
1111
|
|
1032
1112
|
##
|
1033
|
-
#
|
1113
|
+
# Sets extensions to +extensions+, ensuring it is an array. Don't
|
1114
|
+
# use this, push onto the array instead.
|
1034
1115
|
|
1035
|
-
|
1116
|
+
def extensions= extensions
|
1117
|
+
# TODO: warn about setting instead of pushing
|
1118
|
+
@extensions = Array extensions
|
1119
|
+
end
|
1036
1120
|
|
1037
1121
|
##
|
1038
|
-
#
|
1122
|
+
# Extra files to add to RDoc such as README or doc/examples.txt
|
1039
1123
|
|
1040
|
-
|
1124
|
+
def extra_rdoc_files
|
1125
|
+
@extra_rdoc_files ||= []
|
1126
|
+
end
|
1041
1127
|
|
1042
1128
|
##
|
1043
|
-
#
|
1044
|
-
#
|
1045
|
-
# The description should be more detailed than the summary. For example,
|
1046
|
-
# you might wish to copy the entire README into the description.
|
1047
|
-
#
|
1048
|
-
# As of RubyGems 1.3.2 newlines are no longer stripped.
|
1129
|
+
# Sets extra_rdoc_files to +files+, ensuring it is an array. Don't
|
1130
|
+
# use this, push onto the array instead.
|
1049
1131
|
|
1050
|
-
|
1132
|
+
def extra_rdoc_files= files
|
1133
|
+
# TODO: warn about setting instead of pushing
|
1134
|
+
@extra_rdoc_files = Array files
|
1135
|
+
end
|
1051
1136
|
|
1052
1137
|
##
|
1053
|
-
#
|
1138
|
+
# The default (generated) file name of the gem. See also #spec_name.
|
1054
1139
|
#
|
1055
|
-
#
|
1140
|
+
# spec.file_name # => "example-1.0.gem"
|
1056
1141
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1142
|
+
def file_name
|
1143
|
+
"#{full_name}.gem"
|
1144
|
+
end
|
1060
1145
|
|
1061
1146
|
##
|
1062
|
-
#
|
1063
|
-
#
|
1064
|
-
# If you are providing multiple authors and multiple emails they should be
|
1065
|
-
# in the same order such that:
|
1147
|
+
# Files included in this gem. You cannot append to this accessor, you must
|
1148
|
+
# assign to it.
|
1066
1149
|
#
|
1067
|
-
#
|
1150
|
+
# Only add files you can require to this list, not directories, etc.
|
1068
1151
|
#
|
1069
|
-
#
|
1070
|
-
|
1071
|
-
attr_accessor :email
|
1072
|
-
|
1073
|
-
##
|
1074
|
-
# The URL of this gem's home page
|
1075
|
-
|
1076
|
-
attr_accessor :homepage
|
1077
|
-
|
1078
|
-
##
|
1079
|
-
# The rubyforge project this gem lives under. i.e. RubyGems'
|
1080
|
-
# rubyforge_project is "rubygems".
|
1152
|
+
# Directories are automatically stripped from this list when building a gem,
|
1153
|
+
# other non-files cause an error.
|
1081
1154
|
|
1082
|
-
|
1155
|
+
def files
|
1156
|
+
# DO NOT CHANGE TO ||= ! This is not a normal accessor. (yes, it sucks)
|
1157
|
+
@files = [@files,
|
1158
|
+
@test_files,
|
1159
|
+
add_bindir(@executables),
|
1160
|
+
@extra_rdoc_files,
|
1161
|
+
@extensions,
|
1162
|
+
].flatten.uniq.compact
|
1163
|
+
end
|
1083
1164
|
|
1084
1165
|
##
|
1085
|
-
#
|
1166
|
+
# Sets files to +files+, ensuring it is an array.
|
1086
1167
|
|
1087
|
-
|
1168
|
+
def files= files
|
1169
|
+
@files = Array files
|
1170
|
+
end
|
1088
1171
|
|
1089
1172
|
##
|
1090
|
-
#
|
1091
|
-
# It no longer is supported.
|
1092
|
-
|
1093
|
-
attr_accessor :autorequire
|
1173
|
+
# Finds all gems that satisfy +dep+
|
1094
1174
|
|
1095
|
-
|
1096
|
-
|
1175
|
+
def find_all_satisfiers dep
|
1176
|
+
Gem::Specification.each do |spec|
|
1177
|
+
yield spec if spec.satisfies_requirement? dep
|
1178
|
+
end
|
1179
|
+
end
|
1097
1180
|
|
1098
|
-
|
1181
|
+
private :find_all_satisfiers
|
1099
1182
|
|
1100
1183
|
##
|
1101
|
-
#
|
1184
|
+
# Creates a duplicate spec without large blobs that aren't used at runtime.
|
1102
1185
|
|
1103
|
-
|
1186
|
+
def for_cache
|
1187
|
+
spec = dup
|
1104
1188
|
|
1105
|
-
|
1106
|
-
|
1189
|
+
spec.files = nil
|
1190
|
+
spec.test_files = nil
|
1107
1191
|
|
1108
|
-
|
1192
|
+
spec
|
1193
|
+
end
|
1109
1194
|
|
1110
1195
|
##
|
1111
|
-
# The
|
1112
|
-
|
1113
|
-
attr_reader :required_rubygems_version
|
1196
|
+
# The full path to the gem (install path + full name).
|
1114
1197
|
|
1115
|
-
|
1116
|
-
|
1198
|
+
def full_gem_path
|
1199
|
+
# TODO: try to get rid of this... or the awkward
|
1200
|
+
# TODO: also, shouldn't it default to full_name if it hasn't been written?
|
1201
|
+
return @full_gem_path if defined?(@full_gem_path) && @full_gem_path
|
1117
1202
|
|
1118
|
-
|
1203
|
+
@full_gem_path = File.expand_path File.join(gems_dir, full_name)
|
1119
1204
|
|
1120
|
-
|
1121
|
-
# The certificate chain used to sign this gem. See Gem::Security for
|
1122
|
-
# details.
|
1205
|
+
return @full_gem_path if File.directory? @full_gem_path
|
1123
1206
|
|
1124
|
-
|
1207
|
+
@full_gem_path = File.expand_path File.join(gems_dir, original_name)
|
1208
|
+
end
|
1125
1209
|
|
1126
1210
|
##
|
1127
|
-
#
|
1211
|
+
# Returns the full name (name-version) of this Gem. Platform information
|
1212
|
+
# is included (name-version-platform) if it is specified and not the
|
1213
|
+
# default Ruby platform.
|
1128
1214
|
|
1129
|
-
|
1215
|
+
def full_name
|
1216
|
+
if platform == Gem::Platform::RUBY or platform.nil? then
|
1217
|
+
"#{@name}-#{@version}"
|
1218
|
+
else
|
1219
|
+
"#{@name}-#{@version}-#{platform}"
|
1220
|
+
end
|
1221
|
+
end
|
1130
1222
|
|
1131
1223
|
##
|
1132
|
-
#
|
1133
|
-
#
|
1134
|
-
# If you are providing multiple authors and multiple emails they should be
|
1135
|
-
# in the same order such that:
|
1136
|
-
#
|
1137
|
-
# Hash[*spec.authors.zip(spec.emails).flatten]
|
1138
|
-
#
|
1139
|
-
# Gives a hash of author name to email address.
|
1140
|
-
|
1141
|
-
def authors
|
1142
|
-
@authors ||= []
|
1143
|
-
end
|
1224
|
+
# Returns the full path to this spec's gem directory.
|
1225
|
+
# eg: /usr/local/lib/ruby/1.8/gems/mygem-1.0
|
1144
1226
|
|
1145
|
-
def
|
1146
|
-
@
|
1227
|
+
def gem_dir
|
1228
|
+
@gem_dir ||= File.expand_path File.join(gems_dir, full_name)
|
1147
1229
|
end
|
1148
1230
|
|
1149
1231
|
##
|
1150
|
-
#
|
1151
|
-
#
|
1232
|
+
# Returns the full path to the gems directory containing this spec's
|
1233
|
+
# gem directory. eg: /usr/local/lib/ruby/1.8/gems
|
1152
1234
|
|
1153
|
-
def
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
def licenses=(value)
|
1158
|
-
@licenses = Array(value)
|
1235
|
+
def gems_dir
|
1236
|
+
# TODO: this logic seems terribly broken, but tests fail if just base_dir
|
1237
|
+
@gems_dir ||= File.join(loaded_from && base_dir || Gem.dir, "gems")
|
1159
1238
|
end
|
1160
1239
|
|
1161
1240
|
##
|
1162
|
-
#
|
1163
|
-
# assign to it.
|
1164
|
-
#
|
1165
|
-
# Only add files you can require to this list, not directories, etc.
|
1241
|
+
# Deprecated and ignored, defaults to true.
|
1166
1242
|
#
|
1167
|
-
#
|
1168
|
-
# other non-files cause an error.
|
1169
|
-
|
1170
|
-
def files
|
1171
|
-
@files ||= []
|
1172
|
-
end
|
1243
|
+
# Formerly used to indicate this gem was RDoc-capable.
|
1173
1244
|
|
1174
|
-
def
|
1175
|
-
|
1245
|
+
def has_rdoc
|
1246
|
+
true
|
1176
1247
|
end
|
1177
1248
|
|
1178
1249
|
##
|
1179
|
-
#
|
1180
|
-
#
|
1250
|
+
# Deprecated and ignored.
|
1251
|
+
#
|
1252
|
+
# Formerly used to indicate this gem was RDoc-capable.
|
1181
1253
|
|
1182
|
-
def
|
1183
|
-
@
|
1254
|
+
def has_rdoc= ignored
|
1255
|
+
@has_rdoc = true
|
1184
1256
|
end
|
1185
1257
|
|
1186
|
-
|
1187
|
-
@test_files = Array(value)
|
1188
|
-
end
|
1258
|
+
alias :has_rdoc? :has_rdoc
|
1189
1259
|
|
1190
1260
|
##
|
1191
|
-
#
|
1192
|
-
|
1193
|
-
def rdoc_options
|
1194
|
-
@rdoc_options ||= []
|
1195
|
-
end
|
1261
|
+
# True if this gem has files in test_files
|
1196
1262
|
|
1197
|
-
def
|
1198
|
-
|
1199
|
-
@rdoc_options = Array(value)
|
1263
|
+
def has_unit_tests?
|
1264
|
+
not test_files.empty?
|
1200
1265
|
end
|
1201
1266
|
|
1202
|
-
|
1203
|
-
|
1267
|
+
# :stopdoc:
|
1268
|
+
alias has_test_suite? has_unit_tests?
|
1269
|
+
# :startdoc:
|
1204
1270
|
|
1205
|
-
def
|
1206
|
-
|
1271
|
+
def hash # :nodoc:
|
1272
|
+
@@attributes.inject(0) { |hash_code, (name, _)|
|
1273
|
+
hash_code ^ self.send(name).hash
|
1274
|
+
}
|
1207
1275
|
end
|
1208
1276
|
|
1209
|
-
def
|
1210
|
-
|
1211
|
-
@extra_rdoc_files = Array(value)
|
1277
|
+
def init_with coder # :nodoc:
|
1278
|
+
yaml_initialize coder.tag, coder.map
|
1212
1279
|
end
|
1213
1280
|
|
1214
1281
|
##
|
1215
|
-
#
|
1216
|
-
|
1217
|
-
|
1218
|
-
@executables ||= []
|
1219
|
-
end
|
1282
|
+
# Specification constructor. Assigns the default values to the attributes
|
1283
|
+
# and yields itself for further initialization. Optionally takes +name+ and
|
1284
|
+
# +version+.
|
1220
1285
|
|
1221
|
-
def
|
1222
|
-
|
1223
|
-
@
|
1224
|
-
|
1286
|
+
def initialize name = nil, version = nil
|
1287
|
+
@loaded = false
|
1288
|
+
@loaded_from = nil
|
1289
|
+
@original_platform = nil
|
1225
1290
|
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1291
|
+
@@nil_attributes.each do |key|
|
1292
|
+
instance_variable_set "@#{key}", nil
|
1293
|
+
end
|
1229
1294
|
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1295
|
+
@@non_nil_attributes.each do |key|
|
1296
|
+
default = default_value(key)
|
1297
|
+
value = case default
|
1298
|
+
when Time, Numeric, Symbol, true, false, nil then default
|
1299
|
+
else default.dup
|
1300
|
+
end
|
1233
1301
|
|
1234
|
-
|
1235
|
-
|
1236
|
-
@extensions = Array(value)
|
1237
|
-
end
|
1302
|
+
instance_variable_set "@#{key}", value
|
1303
|
+
end
|
1238
1304
|
|
1239
|
-
|
1240
|
-
# An array or things required by this gem. Not used by anything
|
1241
|
-
# presently.
|
1305
|
+
@new_platform = Gem::Platform::RUBY
|
1242
1306
|
|
1243
|
-
|
1244
|
-
|
1245
|
-
end
|
1307
|
+
self.name = name if name
|
1308
|
+
self.version = version if version
|
1246
1309
|
|
1247
|
-
|
1248
|
-
# TODO: warn about setting instead of pushing
|
1249
|
-
@requirements = Array(value)
|
1310
|
+
yield self if block_given?
|
1250
1311
|
end
|
1251
1312
|
|
1252
1313
|
##
|
1253
|
-
#
|
1254
|
-
#
|
1255
|
-
# Use #add_dependency or #add_development_dependency to add dependencies to
|
1256
|
-
# a gem.
|
1314
|
+
# Duplicates array_attributes from +other_spec+ so state isn't shared.
|
1257
1315
|
|
1258
|
-
def
|
1259
|
-
|
1260
|
-
|
1316
|
+
def initialize_copy other_spec
|
1317
|
+
other_ivars = other_spec.instance_variables
|
1318
|
+
other_ivars = other_ivars.map { |ivar| ivar.intern } if # for 1.9
|
1319
|
+
String === other_ivars.first
|
1261
1320
|
|
1262
|
-
|
1321
|
+
self.class.array_attributes.each do |name|
|
1322
|
+
name = :"@#{name}"
|
1323
|
+
next unless other_ivars.include? name
|
1263
1324
|
|
1264
|
-
|
1265
|
-
|
1325
|
+
begin
|
1326
|
+
val = other_spec.instance_variable_get(name)
|
1327
|
+
if val then
|
1328
|
+
instance_variable_set name, val.dup
|
1329
|
+
else
|
1330
|
+
warn "WARNING: #{full_name} has an invalid nil value for #{name}"
|
1331
|
+
end
|
1332
|
+
rescue TypeError
|
1333
|
+
e = Gem::FormatException.new \
|
1334
|
+
"#{full_name} has an invalid value for #{name}"
|
1266
1335
|
|
1267
|
-
|
1268
|
-
|
1336
|
+
e.file_path = loaded_from
|
1337
|
+
raise e
|
1338
|
+
end
|
1339
|
+
end
|
1269
1340
|
end
|
1270
1341
|
|
1271
1342
|
##
|
1272
|
-
#
|
1343
|
+
# The directory that this gem was installed into.
|
1344
|
+
# TODO: rename - horrible. this is the base_dir for a gem path
|
1273
1345
|
|
1274
|
-
def
|
1275
|
-
|
1346
|
+
def installation_path
|
1347
|
+
loaded_from && base_dir
|
1276
1348
|
end
|
1277
1349
|
|
1278
1350
|
##
|
1279
|
-
#
|
1351
|
+
# Returns a string usable in Dir.glob to match all requirable paths
|
1352
|
+
# for this spec.
|
1280
1353
|
|
1281
|
-
def
|
1282
|
-
|
1354
|
+
def lib_dirs_glob
|
1355
|
+
dirs = if self.require_paths.size > 1 then
|
1356
|
+
"{#{self.require_paths.join(',')}}"
|
1357
|
+
else
|
1358
|
+
self.require_paths.first
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
"#{self.full_gem_path}/#{dirs}"
|
1283
1362
|
end
|
1284
1363
|
|
1285
1364
|
##
|
1286
|
-
#
|
1365
|
+
# Files in the Gem under one of the require_paths
|
1287
1366
|
|
1288
|
-
def
|
1289
|
-
|
1367
|
+
def lib_files
|
1368
|
+
@files.select do |file|
|
1369
|
+
require_paths.any? do |path|
|
1370
|
+
file.index(path) == 0
|
1371
|
+
end
|
1372
|
+
end
|
1290
1373
|
end
|
1291
1374
|
|
1292
1375
|
##
|
@@ -1304,64 +1387,101 @@ class Gem::Specification
|
|
1304
1387
|
end
|
1305
1388
|
|
1306
1389
|
##
|
1307
|
-
#
|
1390
|
+
# The license(s) for the library. Each license must be a short name, no
|
1391
|
+
# more than 64 characters.
|
1308
1392
|
|
1309
|
-
def
|
1310
|
-
|
1393
|
+
def licenses
|
1394
|
+
@licenses ||= []
|
1311
1395
|
end
|
1312
1396
|
|
1313
1397
|
##
|
1314
|
-
#
|
1398
|
+
# Set licenses to +licenses+, ensuring it is an array.
|
1315
1399
|
|
1316
|
-
def
|
1317
|
-
|
1400
|
+
def licenses= licenses
|
1401
|
+
@licenses = Array licenses
|
1318
1402
|
end
|
1319
1403
|
|
1320
1404
|
##
|
1321
|
-
#
|
1405
|
+
# Set the location a Specification was loaded from. +obj+ is converted
|
1406
|
+
# to a String.
|
1322
1407
|
|
1323
|
-
def
|
1324
|
-
|
1408
|
+
def loaded_from= path
|
1409
|
+
@loaded_from = path.to_s
|
1325
1410
|
end
|
1326
1411
|
|
1327
1412
|
##
|
1328
|
-
#
|
1413
|
+
# Sets the rubygems_version to the current RubyGems version.
|
1329
1414
|
|
1330
|
-
def
|
1331
|
-
|
1415
|
+
def mark_version
|
1416
|
+
@rubygems_version = Gem::VERSION
|
1332
1417
|
end
|
1333
1418
|
|
1334
1419
|
##
|
1335
|
-
#
|
1336
|
-
#
|
1337
|
-
# Formerly used to indicate this gem was RDoc-capable.
|
1420
|
+
# Return all files in this gem that match for +glob+.
|
1338
1421
|
|
1339
|
-
def
|
1340
|
-
|
1422
|
+
def matches_for_glob glob # TODO: rename?
|
1423
|
+
# TODO: do we need these?? Kill it
|
1424
|
+
glob = File.join(self.lib_dirs_glob, glob)
|
1425
|
+
|
1426
|
+
Dir[glob].map { |f| f.untaint } # FIX our tests are brokey, run w/ SAFE=1
|
1341
1427
|
end
|
1342
1428
|
|
1343
1429
|
##
|
1344
|
-
#
|
1345
|
-
#
|
1346
|
-
# Formerly used to indicate this gem was RDoc-capable.
|
1430
|
+
# Warn about unknown attributes while loading a spec.
|
1347
1431
|
|
1348
|
-
def
|
1349
|
-
@
|
1432
|
+
def method_missing(sym, *a, &b) # :nodoc:
|
1433
|
+
if @specification_version > CURRENT_SPECIFICATION_VERSION and
|
1434
|
+
sym.to_s =~ /=$/ then
|
1435
|
+
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
|
1436
|
+
else
|
1437
|
+
super
|
1438
|
+
end
|
1350
1439
|
end
|
1351
1440
|
|
1352
|
-
|
1441
|
+
##
|
1442
|
+
# Normalize the list of files so that:
|
1443
|
+
# * All file lists have redundancies removed.
|
1444
|
+
# * Files referenced in the extra_rdoc_files are included in the package
|
1445
|
+
# file list.
|
1353
1446
|
|
1354
|
-
def
|
1355
|
-
@
|
1356
|
-
|
1357
|
-
|
1447
|
+
def normalize
|
1448
|
+
if defined?(@extra_rdoc_files) and @extra_rdoc_files then
|
1449
|
+
@extra_rdoc_files.uniq!
|
1450
|
+
@files ||= []
|
1451
|
+
@files.concat(@extra_rdoc_files)
|
1452
|
+
end
|
1453
|
+
|
1454
|
+
@files = @files.uniq if @files
|
1455
|
+
@extensions = @extensions.uniq if @extensions
|
1456
|
+
@test_files = @test_files.uniq if @test_files
|
1457
|
+
@executables = @executables.uniq if @executables
|
1458
|
+
@extra_rdoc_files = @extra_rdoc_files.uniq if @extra_rdoc_files
|
1459
|
+
end
|
1460
|
+
|
1461
|
+
##
|
1462
|
+
# Returns the full name (name-version) of this gemspec using the original
|
1463
|
+
# platform. For use with legacy gems.
|
1464
|
+
|
1465
|
+
def original_name # :nodoc:
|
1466
|
+
if platform == Gem::Platform::RUBY or platform.nil? then
|
1467
|
+
"#{@name}-#{@version}"
|
1468
|
+
else
|
1469
|
+
"#{@name}-#{@version}-#{@original_platform}"
|
1470
|
+
end
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
##
|
1474
|
+
# Cruft. Use +platform+.
|
1475
|
+
|
1476
|
+
def original_platform # :nodoc:
|
1477
|
+
@original_platform ||= platform
|
1358
1478
|
end
|
1359
1479
|
|
1360
1480
|
##
|
1361
1481
|
# The platform this gem runs on. See Gem::Platform for details.
|
1362
1482
|
|
1363
1483
|
def platform
|
1364
|
-
@new_platform
|
1484
|
+
@new_platform ||= Gem::Platform::RUBY
|
1365
1485
|
end
|
1366
1486
|
|
1367
1487
|
##
|
@@ -1402,49 +1522,208 @@ class Gem::Specification
|
|
1402
1522
|
@new_platform
|
1403
1523
|
end
|
1404
1524
|
|
1525
|
+
def pretty_print(q) # :nodoc:
|
1526
|
+
q.group 2, 'Gem::Specification.new do |s|', 'end' do
|
1527
|
+
q.breakable
|
1528
|
+
|
1529
|
+
# REFACTOR: each_attr - use in to_yaml as well
|
1530
|
+
@@attributes.each do |attr_name|
|
1531
|
+
current_value = self.send attr_name
|
1532
|
+
if current_value != default_value(attr_name) or
|
1533
|
+
self.class.required_attribute? attr_name then
|
1534
|
+
|
1535
|
+
q.text "s.#{attr_name} = "
|
1536
|
+
|
1537
|
+
if attr_name == :date then
|
1538
|
+
current_value = current_value.utc
|
1539
|
+
|
1540
|
+
q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
|
1541
|
+
else
|
1542
|
+
q.pp current_value
|
1543
|
+
end
|
1544
|
+
|
1545
|
+
q.breakable
|
1546
|
+
end
|
1547
|
+
end
|
1548
|
+
end
|
1549
|
+
end
|
1550
|
+
|
1551
|
+
##
|
1552
|
+
# Check the spec for possible conflicts and freak out if there are any.
|
1553
|
+
|
1554
|
+
def raise_if_conflicts
|
1555
|
+
other = Gem.loaded_specs[self.name]
|
1556
|
+
|
1557
|
+
if other and self.version != other.version then
|
1558
|
+
# This gem is already loaded. If the currently loaded gem is not in the
|
1559
|
+
# list of candidate gems, then we have a version conflict.
|
1560
|
+
|
1561
|
+
msg = "can't activate #{full_name}, already activated #{other.full_name}"
|
1562
|
+
|
1563
|
+
e = Gem::LoadError.new msg
|
1564
|
+
e.name = self.name
|
1565
|
+
# TODO: e.requirement = dep.requirement
|
1566
|
+
|
1567
|
+
raise e
|
1568
|
+
end
|
1569
|
+
|
1570
|
+
conf = self.conflicts
|
1571
|
+
|
1572
|
+
unless conf.empty? then
|
1573
|
+
y = conf.map { |act,con|
|
1574
|
+
"#{act.full_name} conflicts with #{con.join(", ")}"
|
1575
|
+
}.join ", "
|
1576
|
+
|
1577
|
+
# TODO: improve message by saying who activated `con`
|
1578
|
+
|
1579
|
+
raise Gem::LoadError, "Unable to activate #{self.full_name}, because #{y}"
|
1580
|
+
end
|
1581
|
+
end
|
1582
|
+
|
1583
|
+
##
|
1584
|
+
# An ARGV style array of options to RDoc
|
1585
|
+
|
1586
|
+
def rdoc_options
|
1587
|
+
@rdoc_options ||= []
|
1588
|
+
end
|
1589
|
+
|
1590
|
+
##
|
1591
|
+
# Sets rdoc_options to +value+, ensuring it is an array. Don't
|
1592
|
+
# use this, push onto the array instead.
|
1593
|
+
|
1594
|
+
def rdoc_options= options
|
1595
|
+
# TODO: warn about setting instead of pushing
|
1596
|
+
@rdoc_options = Array options
|
1597
|
+
end
|
1598
|
+
|
1599
|
+
##
|
1600
|
+
# Singular accessor for #require_paths
|
1601
|
+
|
1602
|
+
def require_path
|
1603
|
+
val = require_paths and val.first
|
1604
|
+
end
|
1605
|
+
|
1606
|
+
##
|
1607
|
+
# Singular accessor for #require_paths
|
1608
|
+
|
1609
|
+
def require_path= path
|
1610
|
+
self.require_paths = [path]
|
1611
|
+
end
|
1612
|
+
|
1405
1613
|
##
|
1406
1614
|
# The version of ruby required by this gem
|
1407
1615
|
|
1408
|
-
def required_ruby_version=
|
1409
|
-
@required_ruby_version = Gem::Requirement.create
|
1616
|
+
def required_ruby_version= req
|
1617
|
+
@required_ruby_version = Gem::Requirement.create req
|
1410
1618
|
end
|
1411
1619
|
|
1412
1620
|
##
|
1413
1621
|
# The RubyGems version required by this gem
|
1414
1622
|
|
1415
|
-
def required_rubygems_version=
|
1416
|
-
@required_rubygems_version = Gem::Requirement.create
|
1623
|
+
def required_rubygems_version= req
|
1624
|
+
@required_rubygems_version = Gem::Requirement.create req
|
1417
1625
|
end
|
1418
1626
|
|
1419
1627
|
##
|
1420
|
-
#
|
1421
|
-
#
|
1422
|
-
# Do not set this, it is set automatically when the gem is packaged.
|
1628
|
+
# An array or things required by this gem. Not used by anything
|
1629
|
+
# presently.
|
1423
1630
|
|
1424
|
-
def
|
1425
|
-
|
1426
|
-
# This is the cleanest, most-readable, faster-than-using-Date
|
1427
|
-
# way to do it.
|
1428
|
-
@date = case date
|
1429
|
-
when String then
|
1430
|
-
if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
|
1431
|
-
Time.utc($1.to_i, $2.to_i, $3.to_i)
|
1432
|
-
else
|
1433
|
-
raise(Gem::InvalidSpecificationException,
|
1434
|
-
"invalid date format in specification: #{date.inspect}")
|
1435
|
-
end
|
1436
|
-
when Time, Date then
|
1437
|
-
Time.utc(date.year, date.month, date.day)
|
1438
|
-
else
|
1439
|
-
TODAY
|
1440
|
-
end
|
1631
|
+
def requirements
|
1632
|
+
@requirements ||= []
|
1441
1633
|
end
|
1442
1634
|
|
1443
1635
|
##
|
1444
|
-
#
|
1636
|
+
# Set requirements to +req+, ensuring it is an array. Don't
|
1637
|
+
# use this, push onto the array instead.
|
1445
1638
|
|
1446
|
-
def
|
1447
|
-
|
1639
|
+
def requirements= req
|
1640
|
+
# TODO: warn about setting instead of pushing
|
1641
|
+
@requirements = Array req
|
1642
|
+
end
|
1643
|
+
|
1644
|
+
##
|
1645
|
+
# Returns the full path to this spec's ri directory.
|
1646
|
+
|
1647
|
+
def ri_dir
|
1648
|
+
@ri_dir ||= File.join base_dir, 'ri', full_name
|
1649
|
+
end
|
1650
|
+
|
1651
|
+
##
|
1652
|
+
# Return a string containing a Ruby code representation of the given
|
1653
|
+
# object.
|
1654
|
+
|
1655
|
+
def ruby_code(obj)
|
1656
|
+
case obj
|
1657
|
+
when String then '%q{' + obj + '}'
|
1658
|
+
when Array then '[' + obj.map { |x| ruby_code x }.join(", ") + ']'
|
1659
|
+
when Gem::Version then obj.to_s.inspect
|
1660
|
+
when Date then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
1661
|
+
when Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
1662
|
+
when Numeric then obj.inspect
|
1663
|
+
when true, false, nil then obj.inspect
|
1664
|
+
when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
|
1665
|
+
when Gem::Requirement then "Gem::Requirement.new(#{obj.to_s.inspect})"
|
1666
|
+
else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
|
1667
|
+
end
|
1668
|
+
end
|
1669
|
+
|
1670
|
+
private :ruby_code
|
1671
|
+
|
1672
|
+
##
|
1673
|
+
# List of dependencies that will automatically be activated at runtime.
|
1674
|
+
|
1675
|
+
def runtime_dependencies
|
1676
|
+
dependencies.select { |d| d.type == :runtime }
|
1677
|
+
end
|
1678
|
+
|
1679
|
+
##
|
1680
|
+
# True if this gem has the same attributes as +other+.
|
1681
|
+
|
1682
|
+
def same_attributes? spec
|
1683
|
+
@@attributes.all? { |name, default| self.send(name) == spec.send(name) }
|
1684
|
+
end
|
1685
|
+
|
1686
|
+
private :same_attributes?
|
1687
|
+
|
1688
|
+
##
|
1689
|
+
# Checks if this specification meets the requirement of +dependency+.
|
1690
|
+
|
1691
|
+
def satisfies_requirement? dependency
|
1692
|
+
return @name == dependency.name &&
|
1693
|
+
dependency.requirement.satisfied_by?(@version)
|
1694
|
+
end
|
1695
|
+
|
1696
|
+
##
|
1697
|
+
# Returns an object you can use to sort specifications in #sort_by.
|
1698
|
+
|
1699
|
+
def sort_obj
|
1700
|
+
# TODO: this is horrible. Deprecate it.
|
1701
|
+
[@name, @version, @new_platform == Gem::Platform::RUBY ? -1 : 1]
|
1702
|
+
end
|
1703
|
+
|
1704
|
+
##
|
1705
|
+
# Returns the full path to the directory containing this spec's
|
1706
|
+
# gemspec file. eg: /usr/local/lib/ruby/gems/1.8/specifications
|
1707
|
+
|
1708
|
+
def spec_dir
|
1709
|
+
@spec_dir ||= File.join base_dir, "specifications"
|
1710
|
+
end
|
1711
|
+
|
1712
|
+
##
|
1713
|
+
# Returns the full path to this spec's gemspec file.
|
1714
|
+
# eg: /usr/local/lib/ruby/gems/1.8/specifications/mygem-1.0.gemspec
|
1715
|
+
|
1716
|
+
def spec_file
|
1717
|
+
@spec_file ||= File.join spec_dir, "#{full_name}.gemspec"
|
1718
|
+
end
|
1719
|
+
|
1720
|
+
##
|
1721
|
+
# The default name of the gemspec. See also #file_name
|
1722
|
+
#
|
1723
|
+
# spec.spec_name # => "example-1.0.gemspec"
|
1724
|
+
|
1725
|
+
def spec_name
|
1726
|
+
"#{full_name}.gemspec"
|
1448
1727
|
end
|
1449
1728
|
|
1450
1729
|
##
|
@@ -1456,27 +1735,23 @@ class Gem::Specification
|
|
1456
1735
|
end
|
1457
1736
|
|
1458
1737
|
##
|
1459
|
-
#
|
1738
|
+
# Singular accessor for #test_files
|
1460
1739
|
|
1461
|
-
def
|
1462
|
-
|
1740
|
+
def test_file
|
1741
|
+
val = test_files and val.first
|
1463
1742
|
end
|
1464
1743
|
|
1465
1744
|
##
|
1466
|
-
#
|
1745
|
+
# Singular accessor for #test_files
|
1467
1746
|
|
1468
|
-
def
|
1469
|
-
|
1470
|
-
result = @default_executable
|
1471
|
-
elsif @executables and @executables.size == 1
|
1472
|
-
result = Array(@executables).first
|
1473
|
-
else
|
1474
|
-
result = nil
|
1475
|
-
end
|
1476
|
-
result
|
1747
|
+
def test_file= file
|
1748
|
+
self.test_files = [file]
|
1477
1749
|
end
|
1478
1750
|
|
1479
|
-
|
1751
|
+
##
|
1752
|
+
# Test files included in this gem. You cannot append to this accessor, you
|
1753
|
+
# must assign to it.
|
1754
|
+
|
1480
1755
|
def test_files
|
1481
1756
|
# Handle the possibility that we have @test_suite_file but not
|
1482
1757
|
# @test_files. This will happen when an old gem is loaded via
|
@@ -1492,43 +1767,305 @@ class Gem::Specification
|
|
1492
1767
|
end
|
1493
1768
|
end
|
1494
1769
|
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
add_bindir(@executables),
|
1501
|
-
@extra_rdoc_files,
|
1502
|
-
@extensions,
|
1503
|
-
].flatten.uniq.compact
|
1770
|
+
##
|
1771
|
+
# Set test_files to +files+, ensuring it is an array.
|
1772
|
+
|
1773
|
+
def test_files= files
|
1774
|
+
@test_files = Array files
|
1504
1775
|
end
|
1505
1776
|
|
1506
|
-
def
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
spec.name == dep.name and not spec.satisfies_requirement? dep
|
1511
|
-
}
|
1777
|
+
def test_suite_file # :nodoc:
|
1778
|
+
# TODO: deprecate
|
1779
|
+
test_files.first
|
1780
|
+
end
|
1512
1781
|
|
1513
|
-
|
1782
|
+
def test_suite_file= file # :nodoc:
|
1783
|
+
# TODO: deprecate
|
1784
|
+
@test_files = [] unless defined? @test_files
|
1785
|
+
@test_files << file
|
1786
|
+
end
|
1787
|
+
|
1788
|
+
##
|
1789
|
+
# Returns a Ruby code representation of this specification, such that it can
|
1790
|
+
# be eval'ed and reconstruct the same specification later. Attributes that
|
1791
|
+
# still have their default values are omitted.
|
1792
|
+
|
1793
|
+
def to_ruby
|
1794
|
+
mark_version
|
1795
|
+
result = []
|
1796
|
+
result << "# -*- encoding: utf-8 -*-"
|
1797
|
+
result << nil
|
1798
|
+
result << "Gem::Specification.new do |s|"
|
1799
|
+
|
1800
|
+
result << " s.name = #{ruby_code name}"
|
1801
|
+
result << " s.version = #{ruby_code version}"
|
1802
|
+
unless platform.nil? or platform == Gem::Platform::RUBY then
|
1803
|
+
result << " s.platform = #{ruby_code original_platform}"
|
1514
1804
|
end
|
1515
|
-
|
1805
|
+
result << ""
|
1806
|
+
result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version="
|
1807
|
+
|
1808
|
+
handled = [
|
1809
|
+
:dependencies,
|
1810
|
+
:name,
|
1811
|
+
:platform,
|
1812
|
+
:required_rubygems_version,
|
1813
|
+
:specification_version,
|
1814
|
+
:version,
|
1815
|
+
:has_rdoc,
|
1816
|
+
:default_executable,
|
1817
|
+
]
|
1818
|
+
|
1819
|
+
@@attributes.each do |attr_name|
|
1820
|
+
next if handled.include? attr_name
|
1821
|
+
current_value = self.send(attr_name)
|
1822
|
+
if current_value != default_value(attr_name) or
|
1823
|
+
self.class.required_attribute? attr_name then
|
1824
|
+
result << " s.#{attr_name} = #{ruby_code current_value}"
|
1825
|
+
end
|
1826
|
+
end
|
1827
|
+
|
1828
|
+
result << nil
|
1829
|
+
result << " if s.respond_to? :specification_version then"
|
1830
|
+
result << " s.specification_version = #{specification_version}"
|
1831
|
+
result << nil
|
1832
|
+
|
1833
|
+
result << " if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then"
|
1834
|
+
|
1835
|
+
dependencies.each do |dep|
|
1836
|
+
req = dep.requirements_list.inspect
|
1837
|
+
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
|
1838
|
+
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{req})"
|
1839
|
+
end
|
1840
|
+
|
1841
|
+
result << " else"
|
1842
|
+
|
1843
|
+
dependencies.each do |dep|
|
1844
|
+
version_reqs_param = dep.requirements_list.inspect
|
1845
|
+
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
1846
|
+
end
|
1847
|
+
|
1848
|
+
result << ' end'
|
1849
|
+
|
1850
|
+
result << " else"
|
1851
|
+
dependencies.each do |dep|
|
1852
|
+
version_reqs_param = dep.requirements_list.inspect
|
1853
|
+
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
1854
|
+
end
|
1855
|
+
result << " end"
|
1856
|
+
|
1857
|
+
result << "end"
|
1858
|
+
result << nil
|
1859
|
+
|
1860
|
+
result.join "\n"
|
1516
1861
|
end
|
1517
1862
|
|
1518
|
-
|
1863
|
+
##
|
1864
|
+
# Returns a Ruby lighter-weight code representation of this specification,
|
1865
|
+
# used for indexing only.
|
1866
|
+
#
|
1867
|
+
# See #to_ruby.
|
1868
|
+
|
1869
|
+
def to_ruby_for_cache
|
1870
|
+
for_cache.to_ruby
|
1871
|
+
end
|
1872
|
+
|
1873
|
+
def to_s # :nodoc:
|
1874
|
+
"#<Gem::Specification name=#{@name} version=#{@version}>"
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
def to_yaml(opts = {}) # :nodoc:
|
1878
|
+
if YAML.const_defined?(:ENGINE) && !YAML::ENGINE.syck? then
|
1879
|
+
super.gsub(/ !!null \n/, " \n")
|
1880
|
+
else
|
1881
|
+
YAML.quick_emit object_id, opts do |out|
|
1882
|
+
out.map taguri, to_yaml_style do |map|
|
1883
|
+
encode_with map
|
1884
|
+
end
|
1885
|
+
end
|
1886
|
+
end
|
1887
|
+
end
|
1888
|
+
|
1889
|
+
##
|
1890
|
+
# Recursively walk dependencies of this spec, executing the +block+ for each
|
1891
|
+
# hop.
|
1892
|
+
|
1893
|
+
def traverse trail = [], &block
|
1519
1894
|
trail = trail + [self]
|
1520
1895
|
runtime_dependencies.each do |dep|
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
dep_spec.traverse(trail, &b) unless
|
1896
|
+
dep.to_specs.each do |dep_spec|
|
1897
|
+
block[self, dep, dep_spec, trail + [dep_spec]]
|
1898
|
+
dep_spec.traverse(trail, &block) unless
|
1525
1899
|
trail.map(&:name).include? dep_spec.name
|
1526
1900
|
end
|
1527
1901
|
end
|
1528
1902
|
end
|
1529
1903
|
|
1530
|
-
|
1531
|
-
|
1904
|
+
##
|
1905
|
+
# Checks that the specification contains all required fields, and does a
|
1906
|
+
# very basic sanity check.
|
1907
|
+
#
|
1908
|
+
# Raises InvalidSpecificationException if the spec does not pass the
|
1909
|
+
# checks..
|
1910
|
+
|
1911
|
+
def validate packaging = true
|
1912
|
+
require 'rubygems/user_interaction'
|
1913
|
+
extend Gem::UserInteraction
|
1914
|
+
normalize
|
1915
|
+
|
1916
|
+
nil_attributes = self.class.non_nil_attributes.find_all do |name|
|
1917
|
+
instance_variable_get("@#{name}").nil?
|
1918
|
+
end
|
1919
|
+
|
1920
|
+
unless nil_attributes.empty? then
|
1921
|
+
raise Gem::InvalidSpecificationException,
|
1922
|
+
"#{nil_attributes.join ', '} must not be nil"
|
1923
|
+
end
|
1924
|
+
|
1925
|
+
if packaging and rubygems_version != Gem::VERSION then
|
1926
|
+
raise Gem::InvalidSpecificationException,
|
1927
|
+
"expected RubyGems version #{Gem::VERSION}, was #{rubygems_version}"
|
1928
|
+
end
|
1929
|
+
|
1930
|
+
@@required_attributes.each do |symbol|
|
1931
|
+
unless self.send symbol then
|
1932
|
+
raise Gem::InvalidSpecificationException,
|
1933
|
+
"missing value for attribute #{symbol}"
|
1934
|
+
end
|
1935
|
+
end
|
1936
|
+
|
1937
|
+
unless String === name then
|
1938
|
+
raise Gem::InvalidSpecificationException,
|
1939
|
+
"invalid value for attribute name: \"#{name.inspect}\""
|
1940
|
+
end
|
1941
|
+
|
1942
|
+
if require_paths.empty? then
|
1943
|
+
raise Gem::InvalidSpecificationException,
|
1944
|
+
'specification must have at least one require_path'
|
1945
|
+
end
|
1946
|
+
|
1947
|
+
@files.delete_if { |x| File.directory?(x) }
|
1948
|
+
@test_files.delete_if { |x| File.directory?(x) }
|
1949
|
+
@executables.delete_if { |x| File.directory?(File.join(@bindir, x)) }
|
1950
|
+
@extra_rdoc_files.delete_if { |x| File.directory?(x) }
|
1951
|
+
@extensions.delete_if { |x| File.directory?(x) }
|
1952
|
+
|
1953
|
+
non_files = files.reject { |x| File.file?(x) }
|
1954
|
+
|
1955
|
+
unless not packaging or non_files.empty? then
|
1956
|
+
raise Gem::InvalidSpecificationException,
|
1957
|
+
"[\"#{non_files.join "\", \""}\"] are not files"
|
1958
|
+
end
|
1959
|
+
|
1960
|
+
unless specification_version.is_a?(Fixnum)
|
1961
|
+
raise Gem::InvalidSpecificationException,
|
1962
|
+
'specification_version must be a Fixnum (did you mean version?)'
|
1963
|
+
end
|
1964
|
+
|
1965
|
+
case platform
|
1966
|
+
when Gem::Platform, Gem::Platform::RUBY then # ok
|
1967
|
+
else
|
1968
|
+
raise Gem::InvalidSpecificationException,
|
1969
|
+
"invalid platform #{platform.inspect}, see Gem::Platform"
|
1970
|
+
end
|
1971
|
+
|
1972
|
+
self.class.array_attributes.each do |field|
|
1973
|
+
val = self.send field
|
1974
|
+
klass = case field
|
1975
|
+
when :dependencies
|
1976
|
+
Gem::Dependency
|
1977
|
+
else
|
1978
|
+
String
|
1979
|
+
end
|
1980
|
+
|
1981
|
+
unless Array === val and val.all? { |x| x.kind_of?(klass) } then
|
1982
|
+
raise(Gem::InvalidSpecificationException,
|
1983
|
+
"#{field} must be an Array of #{klass}")
|
1984
|
+
end
|
1985
|
+
end
|
1986
|
+
|
1987
|
+
[:authors].each do |field|
|
1988
|
+
val = self.send field
|
1989
|
+
raise Gem::InvalidSpecificationException, "#{field} may not be empty" if
|
1990
|
+
val.empty?
|
1991
|
+
end
|
1992
|
+
|
1993
|
+
licenses.each { |license|
|
1994
|
+
if license.length > 64
|
1995
|
+
raise Gem::InvalidSpecificationException,
|
1996
|
+
"each license must be 64 characters or less"
|
1997
|
+
end
|
1998
|
+
}
|
1999
|
+
|
2000
|
+
# reject lazy developers:
|
2001
|
+
|
2002
|
+
lazy = '"FIxxxXME" or "TOxxxDO"'.gsub(/xxx/, '')
|
2003
|
+
|
2004
|
+
unless authors.grep(/FI XME|TO DO/x).empty? then
|
2005
|
+
raise Gem::InvalidSpecificationException, "#{lazy} is not an author"
|
2006
|
+
end
|
2007
|
+
|
2008
|
+
unless Array(email).grep(/FI XME|TO DO/x).empty? then
|
2009
|
+
raise Gem::InvalidSpecificationException, "#{lazy} is not an email"
|
2010
|
+
end
|
2011
|
+
|
2012
|
+
if description =~ /FI XME|TO DO/x then
|
2013
|
+
raise Gem::InvalidSpecificationException, "#{lazy} is not a description"
|
2014
|
+
end
|
2015
|
+
|
2016
|
+
if summary =~ /FI XME|TO DO/x then
|
2017
|
+
raise Gem::InvalidSpecificationException, "#{lazy} is not a summary"
|
2018
|
+
end
|
2019
|
+
|
2020
|
+
if homepage and not homepage.empty? and
|
2021
|
+
homepage !~ /\A[a-z][a-z\d+.-]*:/i then
|
2022
|
+
raise Gem::InvalidSpecificationException,
|
2023
|
+
"\"#{homepage}\" is not a URI"
|
2024
|
+
end
|
2025
|
+
|
2026
|
+
# Warnings
|
2027
|
+
|
2028
|
+
%w[author description email homepage summary].each do |attribute|
|
2029
|
+
value = self.send attribute
|
2030
|
+
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
|
2031
|
+
end
|
2032
|
+
|
2033
|
+
if description == summary then
|
2034
|
+
alert_warning 'description and summary are identical'
|
2035
|
+
end
|
2036
|
+
|
2037
|
+
# TODO: raise at some given date
|
2038
|
+
alert_warning "deprecated autorequire specified" if autorequire
|
2039
|
+
|
2040
|
+
executables.each do |executable|
|
2041
|
+
executable_path = File.join(bindir, executable)
|
2042
|
+
shebang = File.read(executable_path, 2) == '#!'
|
2043
|
+
|
2044
|
+
alert_warning "#{executable_path} is missing #! line" unless shebang
|
2045
|
+
end
|
2046
|
+
|
2047
|
+
true
|
2048
|
+
end
|
2049
|
+
|
2050
|
+
##
|
2051
|
+
# Set the version to +version+, potentially also setting
|
2052
|
+
# required_rubygems_version if +version+ indicates it is a
|
2053
|
+
# prerelease.
|
2054
|
+
|
2055
|
+
def version= version
|
2056
|
+
@version = Gem::Version.create(version)
|
2057
|
+
self.required_rubygems_version = '> 1.3.1' if @version.prerelease?
|
2058
|
+
return @version
|
2059
|
+
end
|
2060
|
+
|
2061
|
+
# FIX: have this handle the platform/new_platform/original_platform bullshit
|
2062
|
+
def yaml_initialize(tag, vals) # :nodoc:
|
2063
|
+
vals.each do |ivar, val|
|
2064
|
+
instance_variable_set "@#{ivar}", val
|
2065
|
+
end
|
2066
|
+
|
2067
|
+
@original_platform = @platform # for backwards compatibility
|
2068
|
+
self.platform = Gem::Platform.new @platform
|
1532
2069
|
end
|
1533
2070
|
|
1534
2071
|
extend Deprecate
|
@@ -1540,4 +2077,12 @@ class Gem::Specification
|
|
1540
2077
|
deprecate :has_rdoc=, :none, 2011, 10
|
1541
2078
|
deprecate :default_executable, :none, 2011, 10
|
1542
2079
|
deprecate :default_executable=, :none, 2011, 10
|
2080
|
+
deprecate :loaded, :activated, 2011, 10
|
2081
|
+
deprecate :loaded?, :activated?, 2011, 10
|
2082
|
+
deprecate :loaded=, :activated=, 2011, 10
|
2083
|
+
deprecate :installation_path, :base_dir, 2011, 10
|
2084
|
+
deprecate :cache_gem, :cache_file, 2011, 10
|
2085
|
+
# deprecate :spec_name, :spec_file, 2011, 10
|
2086
|
+
# deprecate :file_name, :cache_file, 2011, 10
|
2087
|
+
# deprecate :full_gem_path, :cache_file, 2011, 10
|
1543
2088
|
end
|