rubygems-update 1.3.1 → 1.3.2
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 +24 -0
- data/.document +4 -3
- data/ChangeLog +382 -1
- data/Manifest.txt +214 -0
- data/README +1 -49
- data/Rakefile +124 -191
- data/bin/gem +1 -4
- data/cruise_config.rb +22 -0
- data/doc/release_notes/rel_1_3_1.rdoc +3 -3
- data/doc/release_notes/rel_1_3_2.rdoc +119 -0
- data/lib/gauntlet_rubygems.rb +50 -0
- data/lib/rubygems.rb +250 -25
- data/lib/rubygems/builder.rb +62 -60
- data/lib/rubygems/command.rb +421 -319
- data/lib/rubygems/command_manager.rb +153 -125
- data/lib/rubygems/commands/check_command.rb +12 -7
- data/lib/rubygems/commands/cleanup_command.rb +11 -2
- data/lib/rubygems/commands/contents_command.rb +42 -18
- data/lib/rubygems/commands/generate_index_command.rb +91 -15
- data/lib/rubygems/commands/install_command.rb +33 -47
- data/lib/rubygems/commands/query_command.rb +36 -20
- data/lib/rubygems/commands/rdoc_command.rb +62 -68
- data/lib/rubygems/commands/search_command.rb +26 -32
- data/lib/rubygems/commands/setup_command.rb +353 -0
- data/lib/rubygems/commands/sources_command.rb +5 -0
- data/lib/rubygems/commands/specification_command.rb +23 -3
- data/lib/rubygems/commands/uninstall_command.rb +71 -61
- data/lib/rubygems/commands/unpack_command.rb +14 -12
- data/lib/rubygems/commands/update_command.rb +26 -5
- data/lib/rubygems/defaults.rb +16 -3
- data/lib/rubygems/dependency.rb +38 -7
- data/lib/rubygems/dependency_installer.rb +7 -4
- data/lib/rubygems/digest/digest_adapter.rb +42 -33
- data/lib/rubygems/digest/sha1.rb +6 -1
- data/lib/rubygems/digest/sha2.rb +5 -0
- data/lib/rubygems/doc_manager.rb +31 -11
- data/lib/rubygems/ext/ext_conf_builder.rb +2 -1
- data/lib/rubygems/ext/rake_builder.rb +6 -2
- data/lib/rubygems/format.rb +63 -63
- data/lib/rubygems/gem_openssl.rb +14 -2
- data/lib/rubygems/gem_path_searcher.rb +7 -3
- data/lib/rubygems/gem_runner.rb +59 -39
- data/lib/rubygems/indexer.rb +450 -109
- data/lib/rubygems/install_update_options.rb +13 -1
- data/lib/rubygems/installer.rb +25 -22
- data/lib/rubygems/local_remote_options.rb +5 -3
- data/lib/rubygems/old_format.rb +124 -120
- data/lib/rubygems/package/tar_header.rb +25 -3
- data/lib/rubygems/package/tar_input.rb +5 -5
- data/lib/rubygems/package/tar_output.rb +2 -0
- data/lib/rubygems/package/tar_reader.rb +19 -0
- data/lib/rubygems/package/tar_reader/entry.rb +43 -0
- data/lib/rubygems/package/tar_writer.rb +65 -3
- data/lib/rubygems/package_task.rb +117 -0
- data/lib/rubygems/platform.rb +12 -8
- data/lib/rubygems/remote_fetcher.rb +43 -24
- data/lib/rubygems/require_paths_builder.rb +14 -12
- data/lib/rubygems/requirement.rb +15 -6
- data/lib/rubygems/rubygems_version.rb +14 -1
- data/lib/rubygems/source_index.rb +38 -16
- data/lib/rubygems/source_info_cache_entry.rb +2 -2
- data/lib/rubygems/spec_fetcher.rb +43 -20
- data/lib/rubygems/specification.rb +1122 -947
- data/lib/rubygems/text.rb +30 -0
- data/lib/rubygems/timer.rb +14 -11
- data/lib/rubygems/uninstaller.rb +25 -5
- data/lib/rubygems/user_interaction.rb +294 -264
- data/lib/rubygems/validator.rb +70 -36
- data/lib/rubygems/version.rb +97 -33
- data/lib/rubygems/version_option.rb +1 -0
- data/setup.rb +11 -306
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +22 -11
- data/test/gem_package_tar_test_case.rb +0 -14
- data/test/gemutilities.rb +89 -8
- data/test/mockgemui.rb +2 -1
- data/test/rubygems_plugin.rb +16 -0
- data/test/test_gem.rb +107 -36
- data/test/test_gem_command.rb +3 -13
- data/test/test_gem_command_manager.rb +1 -14
- data/test/test_gem_commands_cert_command.rb +1 -1
- data/test/test_gem_commands_contents_command.rb +63 -0
- data/test/test_gem_commands_environment_command.rb +1 -1
- data/test/test_gem_commands_generate_index_command.rb +104 -1
- data/test/test_gem_commands_install_command.rb +95 -0
- data/test/test_gem_commands_pristine_command.rb +3 -3
- data/test/test_gem_commands_query_command.rb +46 -0
- data/test/test_gem_commands_sources_command.rb +9 -5
- data/test/test_gem_commands_specification_command.rb +31 -0
- data/test/test_gem_commands_uninstall_command.rb +3 -2
- data/test/test_gem_commands_unpack_command.rb +3 -2
- data/test/test_gem_commands_update_command.rb +12 -7
- data/test/test_gem_dependency.rb +62 -11
- data/test/test_gem_dependency_installer.rb +18 -5
- data/test/test_gem_dependency_list.rb +6 -6
- data/test/test_gem_doc_manager.rb +7 -1
- data/test/test_gem_ext_configure_builder.rb +8 -10
- data/test/test_gem_ext_ext_conf_builder.rb +14 -8
- data/test/test_gem_gem_path_searcher.rb +1 -1
- data/test/test_gem_gem_runner.rb +11 -0
- data/test/test_gem_indexer.rb +398 -21
- data/test/test_gem_install_update_options.rb +20 -6
- data/test/test_gem_installer.rb +22 -14
- data/test/test_gem_local_remote_options.rb +2 -1
- data/test/test_gem_package_tar_header.rb +3 -3
- data/test/test_gem_package_tar_input.rb +3 -3
- data/test/test_gem_package_tar_output.rb +2 -2
- data/test/test_gem_package_task.rb +70 -0
- data/test/test_gem_platform.rb +12 -6
- data/test/test_gem_remote_fetcher.rb +23 -1
- data/test/test_gem_source_index.rb +32 -21
- data/test/test_gem_spec_fetcher.rb +77 -5
- data/test/test_gem_specification.rb +274 -1
- data/test/test_gem_uninstaller.rb +34 -4
- data/test/test_gem_version.rb +94 -4
- data/test/test_gem_version_option.rb +13 -0
- data/test/test_kernel.rb +4 -4
- data/util/CL2notes +56 -0
- data/util/gem_prelude.rb.template +251 -0
- metadata +30 -20
- metadata.gz.sig +3 -4
- data/TODO +0 -1
- data/scripts/buildtests.rb +0 -31
- data/scripts/gemdoc.rb +0 -67
- data/scripts/runtest.rb +0 -40
- data/scripts/specdoc.rb +0 -171
- data/scripts/upload_gemdoc.rb +0 -140
@@ -13,6 +13,9 @@ require 'rubygems/platform'
|
|
13
13
|
# Time::today has been deprecated in 0.9.5 and will be removed.
|
14
14
|
if RUBY_VERSION < '1.9' then
|
15
15
|
def Time.today
|
16
|
+
file, lineno = location_of_caller
|
17
|
+
warn "#{file}:#{lineno}:Warning: Time::today is deprecated and will be removed in RubyGems 1.4."
|
18
|
+
|
16
19
|
t = Time.now
|
17
20
|
t - ((t.to_f + t.gmt_offset) % 86400)
|
18
21
|
end unless defined? Time.today
|
@@ -22,1240 +25,1412 @@ class Date; end # for ruby_code if date.rb wasn't required
|
|
22
25
|
|
23
26
|
# :startdoc:
|
24
27
|
|
25
|
-
|
28
|
+
##
|
29
|
+
# The Specification class contains the metadata for a Gem. Typically
|
30
|
+
# defined in a .gemspec file or a Rakefile, and looks like this:
|
31
|
+
#
|
32
|
+
# spec = Gem::Specification.new do |s|
|
33
|
+
# s.name = 'rfoo'
|
34
|
+
# s.version = '1.0'
|
35
|
+
# s.summary = 'Example gem specification'
|
36
|
+
# ...
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# For a great way to package gems, use Hoe.
|
40
|
+
|
41
|
+
class Gem::Specification
|
26
42
|
|
27
43
|
##
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
44
|
+
# Allows deinstallation of gems with legacy platforms.
|
45
|
+
|
46
|
+
attr_accessor :original_platform # :nodoc:
|
47
|
+
|
48
|
+
##
|
49
|
+
# The the version number of a specification that does not specify one
|
50
|
+
# (i.e. RubyGems 0.7 or earlier).
|
51
|
+
|
52
|
+
NONEXISTENT_SPECIFICATION_VERSION = -1
|
53
|
+
|
54
|
+
##
|
55
|
+
# The specification version applied to any new Specification instances
|
56
|
+
# created. This should be bumped whenever something in the spec format
|
57
|
+
# changes.
|
58
|
+
#--
|
59
|
+
# When updating this number, be sure to also update #to_ruby.
|
32
60
|
#
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
#
|
61
|
+
# NOTE RubyGems < 1.2 cannot load specification versions > 2.
|
62
|
+
|
63
|
+
CURRENT_SPECIFICATION_VERSION = 3
|
64
|
+
|
65
|
+
##
|
66
|
+
# An informal list of changes to the specification. The highest-valued
|
67
|
+
# key should be equal to the CURRENT_SPECIFICATION_VERSION.
|
68
|
+
|
69
|
+
SPECIFICATION_VERSION_HISTORY = {
|
70
|
+
-1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'],
|
71
|
+
1 => [
|
72
|
+
'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"',
|
73
|
+
'"test_file=x" is a shortcut for "test_files=[x]"'
|
74
|
+
],
|
75
|
+
2 => [
|
76
|
+
'Added "required_rubygems_version"',
|
77
|
+
'Now forward-compatible with future versions',
|
78
|
+
],
|
79
|
+
3 => [
|
80
|
+
'Added Fixnum validation to the specification_version'
|
81
|
+
]
|
82
|
+
}
|
83
|
+
|
84
|
+
# :stopdoc:
|
85
|
+
MARSHAL_FIELDS = { -1 => 16, 1 => 16, 2 => 16, 3 => 17 }
|
86
|
+
|
87
|
+
now = Time.at(Time.now.to_i)
|
88
|
+
TODAY = now - ((now.to_i + now.gmt_offset) % 86400)
|
89
|
+
# :startdoc:
|
90
|
+
|
91
|
+
##
|
92
|
+
# Optional block used to gather newly defined instances.
|
93
|
+
|
94
|
+
@@gather = nil
|
95
|
+
|
96
|
+
##
|
97
|
+
# List of attribute names: [:name, :version, ...]
|
98
|
+
|
99
|
+
@@required_attributes = []
|
100
|
+
|
101
|
+
##
|
102
|
+
# List of _all_ attributes and default values:
|
39
103
|
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
|
43
|
-
class Specification
|
44
|
-
|
45
|
-
##
|
46
|
-
# Allows deinstallation of gems with legacy platforms.
|
47
|
-
|
48
|
-
attr_accessor :original_platform # :nodoc:
|
49
|
-
|
50
|
-
##
|
51
|
-
# The the version number of a specification that does not specify one
|
52
|
-
# (i.e. RubyGems 0.7 or earlier).
|
53
|
-
|
54
|
-
NONEXISTENT_SPECIFICATION_VERSION = -1
|
55
|
-
|
56
|
-
##
|
57
|
-
# The specification version applied to any new Specification instances
|
58
|
-
# created. This should be bumped whenever something in the spec format
|
59
|
-
# changes.
|
60
|
-
#--
|
61
|
-
# When updating this number, be sure to also update #to_ruby.
|
62
|
-
#
|
63
|
-
# NOTE RubyGems < 1.2 cannot load specification versions > 2.
|
64
|
-
|
65
|
-
CURRENT_SPECIFICATION_VERSION = 2
|
66
|
-
|
67
|
-
##
|
68
|
-
# An informal list of changes to the specification. The highest-valued
|
69
|
-
# key should be equal to the CURRENT_SPECIFICATION_VERSION.
|
70
|
-
|
71
|
-
SPECIFICATION_VERSION_HISTORY = {
|
72
|
-
-1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'],
|
73
|
-
1 => [
|
74
|
-
'Deprecated "test_suite_file" in favor of the new, but equivalent, "test_files"',
|
75
|
-
'"test_file=x" is a shortcut for "test_files=[x]"'
|
76
|
-
],
|
77
|
-
2 => [
|
78
|
-
'Added "required_rubygems_version"',
|
79
|
-
'Now forward-compatible with future versions',
|
80
|
-
],
|
81
|
-
}
|
104
|
+
# [[:name, nil],
|
105
|
+
# [:bindir, 'bin'],
|
106
|
+
# ...]
|
82
107
|
|
83
|
-
|
84
|
-
MARSHAL_FIELDS = { -1 => 16, 1 => 16, 2 => 16 }
|
108
|
+
@@attributes = []
|
85
109
|
|
86
|
-
|
87
|
-
|
88
|
-
# :startdoc:
|
110
|
+
@@nil_attributes = []
|
111
|
+
@@non_nil_attributes = [:@original_platform]
|
89
112
|
|
90
|
-
|
91
|
-
|
113
|
+
##
|
114
|
+
# List of array attributes
|
92
115
|
|
93
|
-
|
116
|
+
@@array_attributes = []
|
94
117
|
|
95
|
-
|
96
|
-
|
118
|
+
##
|
119
|
+
# Map of attribute names to default values.
|
97
120
|
|
98
|
-
|
121
|
+
@@default_value = {}
|
99
122
|
|
100
|
-
|
101
|
-
|
102
|
-
@@required_attributes = []
|
123
|
+
##
|
124
|
+
# Names of all specification attributes
|
103
125
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
# [[:name, nil],
|
108
|
-
# [:bindir, 'bin'],
|
109
|
-
# ...]
|
126
|
+
def self.attribute_names
|
127
|
+
@@attributes.map { |name, default| name }
|
128
|
+
end
|
110
129
|
|
111
|
-
|
130
|
+
##
|
131
|
+
# Default values for specification attributes
|
112
132
|
|
113
|
-
|
114
|
-
@@
|
133
|
+
def self.attribute_defaults
|
134
|
+
@@attributes.dup
|
135
|
+
end
|
115
136
|
|
116
|
-
|
117
|
-
|
137
|
+
##
|
138
|
+
# The default value for specification attribute +name+
|
118
139
|
|
119
|
-
|
140
|
+
def self.default_value(name)
|
141
|
+
@@default_value[name]
|
142
|
+
end
|
120
143
|
|
121
|
-
|
122
|
-
|
144
|
+
##
|
145
|
+
# Required specification attributes
|
123
146
|
|
124
|
-
|
147
|
+
def self.required_attributes
|
148
|
+
@@required_attributes.dup
|
149
|
+
end
|
125
150
|
|
126
|
-
|
127
|
-
|
151
|
+
##
|
152
|
+
# Is +name+ a required attribute?
|
128
153
|
|
129
|
-
|
130
|
-
|
131
|
-
|
154
|
+
def self.required_attribute?(name)
|
155
|
+
@@required_attributes.include? name.to_sym
|
156
|
+
end
|
132
157
|
|
133
|
-
|
134
|
-
|
158
|
+
##
|
159
|
+
# Specification attributes that are arrays (appendable and so-forth)
|
135
160
|
|
136
|
-
|
137
|
-
|
138
|
-
|
161
|
+
def self.array_attributes
|
162
|
+
@@array_attributes.dup
|
163
|
+
end
|
139
164
|
|
140
|
-
|
141
|
-
|
165
|
+
##
|
166
|
+
# Specifies the +name+ and +default+ for a specification attribute, and
|
167
|
+
# creates a reader and writer method like Module#attr_accessor.
|
168
|
+
#
|
169
|
+
# The reader method returns the default if the value hasn't been set.
|
142
170
|
|
143
|
-
|
144
|
-
|
171
|
+
def self.attribute(name, default=nil)
|
172
|
+
ivar_name = "@#{name}".intern
|
173
|
+
if default.nil? then
|
174
|
+
@@nil_attributes << ivar_name
|
175
|
+
else
|
176
|
+
@@non_nil_attributes << [ivar_name, default]
|
145
177
|
end
|
146
178
|
|
147
|
-
|
148
|
-
|
179
|
+
@@attributes << [name, default]
|
180
|
+
@@default_value[name] = default
|
181
|
+
attr_accessor(name)
|
182
|
+
end
|
149
183
|
|
150
|
-
|
151
|
-
|
152
|
-
|
184
|
+
##
|
185
|
+
# Same as :attribute, but ensures that values assigned to the attribute
|
186
|
+
# are array values by applying :to_a to the value.
|
187
|
+
|
188
|
+
def self.array_attribute(name)
|
189
|
+
@@non_nil_attributes << ["@#{name}".intern, []]
|
190
|
+
|
191
|
+
@@array_attributes << name
|
192
|
+
@@attributes << [name, []]
|
193
|
+
@@default_value[name] = []
|
194
|
+
code = %{
|
195
|
+
def #{name}
|
196
|
+
@#{name} ||= []
|
197
|
+
end
|
198
|
+
def #{name}=(value)
|
199
|
+
@#{name} = Array(value)
|
200
|
+
end
|
201
|
+
}
|
153
202
|
|
154
|
-
|
155
|
-
|
203
|
+
module_eval code, __FILE__, __LINE__ - 9
|
204
|
+
end
|
156
205
|
|
157
|
-
|
158
|
-
|
159
|
-
end
|
206
|
+
##
|
207
|
+
# Same as attribute above, but also records this attribute as mandatory.
|
160
208
|
|
161
|
-
|
162
|
-
|
209
|
+
def self.required_attribute(*args)
|
210
|
+
@@required_attributes << args.first
|
211
|
+
attribute(*args)
|
212
|
+
end
|
213
|
+
|
214
|
+
##
|
215
|
+
# Sometimes we don't want the world to use a setter method for a
|
216
|
+
# particular attribute.
|
217
|
+
#
|
218
|
+
# +read_only+ makes it private so we can still use it internally.
|
163
219
|
|
164
|
-
|
165
|
-
|
220
|
+
def self.read_only(*names)
|
221
|
+
names.each do |name|
|
222
|
+
private "#{name}="
|
166
223
|
end
|
224
|
+
end
|
167
225
|
|
168
|
-
|
169
|
-
|
170
|
-
# instance.
|
226
|
+
# Shortcut for creating several attributes at once (each with a default
|
227
|
+
# value of +nil+).
|
171
228
|
|
172
|
-
|
173
|
-
|
229
|
+
def self.attributes(*args)
|
230
|
+
args.each do |arg|
|
231
|
+
attribute(arg, nil)
|
174
232
|
end
|
233
|
+
end
|
175
234
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
#
|
180
|
-
# The reader method returns the default if the value hasn't been set.
|
235
|
+
##
|
236
|
+
# Some attributes require special behaviour when they are accessed. This
|
237
|
+
# allows for that.
|
181
238
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
else
|
187
|
-
@@non_nil_attributes << [ivar_name, default]
|
188
|
-
end
|
239
|
+
def self.overwrite_accessor(name, &block)
|
240
|
+
remove_method name
|
241
|
+
define_method(name, &block)
|
242
|
+
end
|
189
243
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
244
|
+
##
|
245
|
+
# Defines a _singular_ version of an existing _plural_ attribute (i.e. one
|
246
|
+
# whose value is expected to be an array). This means just creating a
|
247
|
+
# helper method that takes a single value and appends it to the array.
|
248
|
+
# These are created for convenience, so that in a spec, one can write
|
249
|
+
#
|
250
|
+
# s.require_path = 'mylib'
|
251
|
+
#
|
252
|
+
# instead of:
|
253
|
+
#
|
254
|
+
# s.require_paths = ['mylib']
|
255
|
+
#
|
256
|
+
# That above convenience is available courtesy of:
|
257
|
+
#
|
258
|
+
# attribute_alias_singular :require_path, :require_paths
|
194
259
|
|
195
|
-
|
196
|
-
#
|
197
|
-
|
260
|
+
def self.attribute_alias_singular(singular, plural)
|
261
|
+
define_method("#{singular}=") { |val|
|
262
|
+
send("#{plural}=", [val])
|
263
|
+
}
|
264
|
+
define_method("#{singular}") {
|
265
|
+
val = send("#{plural}")
|
266
|
+
val.nil? ? nil : val.first
|
267
|
+
}
|
268
|
+
end
|
198
269
|
|
199
|
-
|
200
|
-
|
270
|
+
##
|
271
|
+
# Dump only crucial instance variables.
|
272
|
+
#--
|
273
|
+
# MAINTAIN ORDER!
|
274
|
+
|
275
|
+
def _dump(limit)
|
276
|
+
Marshal.dump [
|
277
|
+
@rubygems_version,
|
278
|
+
@specification_version,
|
279
|
+
@name,
|
280
|
+
@version,
|
281
|
+
(Time === @date ? @date : (require 'time'; Time.parse(@date.to_s))),
|
282
|
+
@summary,
|
283
|
+
@required_ruby_version,
|
284
|
+
@required_rubygems_version,
|
285
|
+
@original_platform,
|
286
|
+
@dependencies,
|
287
|
+
@rubyforge_project,
|
288
|
+
@email,
|
289
|
+
@authors,
|
290
|
+
@description,
|
291
|
+
@homepage,
|
292
|
+
@has_rdoc,
|
293
|
+
@new_platform,
|
294
|
+
@licenses
|
295
|
+
]
|
296
|
+
end
|
201
297
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
298
|
+
##
|
299
|
+
# Load custom marshal format, re-initializing defaults as needed
|
300
|
+
|
301
|
+
def self._load(str)
|
302
|
+
array = Marshal.load str
|
303
|
+
|
304
|
+
spec = Gem::Specification.new
|
305
|
+
spec.instance_variable_set :@specification_version, array[1]
|
306
|
+
|
307
|
+
current_version = CURRENT_SPECIFICATION_VERSION
|
308
|
+
|
309
|
+
field_count = if spec.specification_version > current_version then
|
310
|
+
spec.instance_variable_set :@specification_version,
|
311
|
+
current_version
|
312
|
+
MARSHAL_FIELDS[current_version]
|
313
|
+
else
|
314
|
+
MARSHAL_FIELDS[spec.specification_version]
|
315
|
+
end
|
316
|
+
|
317
|
+
if array.size < field_count then
|
318
|
+
raise TypeError, "invalid Gem::Specification format #{array.inspect}"
|
319
|
+
end
|
320
|
+
|
321
|
+
spec.instance_variable_set :@rubygems_version, array[0]
|
322
|
+
# spec version
|
323
|
+
spec.instance_variable_set :@name, array[2]
|
324
|
+
spec.instance_variable_set :@version, array[3]
|
325
|
+
spec.instance_variable_set :@date, array[4]
|
326
|
+
spec.instance_variable_set :@summary, array[5]
|
327
|
+
spec.instance_variable_set :@required_ruby_version, array[6]
|
328
|
+
spec.instance_variable_set :@required_rubygems_version, array[7]
|
329
|
+
spec.instance_variable_set :@original_platform, array[8]
|
330
|
+
spec.instance_variable_set :@dependencies, array[9]
|
331
|
+
spec.instance_variable_set :@rubyforge_project, array[10]
|
332
|
+
spec.instance_variable_set :@email, array[11]
|
333
|
+
spec.instance_variable_set :@authors, array[12]
|
334
|
+
spec.instance_variable_set :@description, array[13]
|
335
|
+
spec.instance_variable_set :@homepage, array[14]
|
336
|
+
spec.instance_variable_set :@has_rdoc, array[15]
|
337
|
+
spec.instance_variable_set :@new_platform, array[16]
|
338
|
+
spec.instance_variable_set :@platform, array[16].to_s
|
339
|
+
spec.instance_variable_set :@license, array[17]
|
340
|
+
spec.instance_variable_set :@loaded, false
|
341
|
+
|
342
|
+
spec
|
343
|
+
end
|
213
344
|
|
214
|
-
|
215
|
-
|
345
|
+
##
|
346
|
+
# List of depedencies that will automatically be activated at runtime.
|
216
347
|
|
217
|
-
|
218
|
-
|
348
|
+
def runtime_dependencies
|
349
|
+
dependencies.select { |d| d.type == :runtime || d.type == nil }
|
350
|
+
end
|
219
351
|
|
220
|
-
|
221
|
-
|
222
|
-
attribute(*args)
|
223
|
-
end
|
352
|
+
##
|
353
|
+
# List of dependencies that are used for development
|
224
354
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
#
|
229
|
-
# +read_only+ makes it private so we can still use it internally.
|
355
|
+
def development_dependencies
|
356
|
+
dependencies.select { |d| d.type == :development }
|
357
|
+
end
|
230
358
|
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
359
|
+
def test_suite_file # :nodoc:
|
360
|
+
warn 'test_suite_file deprecated, use test_files'
|
361
|
+
test_files.first
|
362
|
+
end
|
363
|
+
|
364
|
+
def test_suite_file=(val) # :nodoc:
|
365
|
+
warn 'test_suite_file= deprecated, use test_files='
|
366
|
+
@test_files = [] unless defined? @test_files
|
367
|
+
@test_files << val
|
368
|
+
end
|
369
|
+
|
370
|
+
##
|
371
|
+
# true when this gemspec has been loaded from a specifications directory.
|
372
|
+
# This attribute is not persisted.
|
373
|
+
|
374
|
+
attr_accessor :loaded
|
375
|
+
|
376
|
+
##
|
377
|
+
# Path this gemspec was loaded from. This attribute is not persisted.
|
378
|
+
|
379
|
+
attr_accessor :loaded_from
|
380
|
+
|
381
|
+
##
|
382
|
+
# Returns an array with bindir attached to each executable in the
|
383
|
+
# executables list
|
384
|
+
|
385
|
+
def add_bindir(executables)
|
386
|
+
return nil if executables.nil?
|
387
|
+
|
388
|
+
if @bindir then
|
389
|
+
Array(executables).map { |e| File.join(@bindir, e) }
|
390
|
+
else
|
391
|
+
executables
|
235
392
|
end
|
393
|
+
rescue
|
394
|
+
return nil
|
395
|
+
end
|
236
396
|
|
237
|
-
|
238
|
-
|
397
|
+
##
|
398
|
+
# Files in the Gem under one of the require_paths
|
239
399
|
|
240
|
-
|
241
|
-
|
242
|
-
|
400
|
+
def lib_files
|
401
|
+
@files.select do |file|
|
402
|
+
require_paths.any? do |path|
|
403
|
+
file.index(path) == 0
|
243
404
|
end
|
244
405
|
end
|
406
|
+
end
|
245
407
|
|
246
|
-
|
247
|
-
|
248
|
-
# allows for that.
|
408
|
+
##
|
409
|
+
# True if this gem was loaded from disk
|
249
410
|
|
250
|
-
|
251
|
-
remove_method name
|
252
|
-
define_method(name, &block)
|
253
|
-
end
|
411
|
+
alias :loaded? :loaded
|
254
412
|
|
255
|
-
|
256
|
-
|
257
|
-
# whose value is expected to be an array). This means just creating a
|
258
|
-
# helper method that takes a single value and appends it to the array.
|
259
|
-
# These are created for convenience, so that in a spec, one can write
|
260
|
-
#
|
261
|
-
# s.require_path = 'mylib'
|
262
|
-
#
|
263
|
-
# instead of:
|
264
|
-
#
|
265
|
-
# s.require_paths = ['mylib']
|
266
|
-
#
|
267
|
-
# That above convenience is available courtesy of:
|
268
|
-
#
|
269
|
-
# attribute_alias_singular :require_path, :require_paths
|
270
|
-
|
271
|
-
def self.attribute_alias_singular(singular, plural)
|
272
|
-
define_method("#{singular}=") { |val|
|
273
|
-
send("#{plural}=", [val])
|
274
|
-
}
|
275
|
-
define_method("#{singular}") {
|
276
|
-
val = send("#{plural}")
|
277
|
-
val.nil? ? nil : val.first
|
278
|
-
}
|
279
|
-
end
|
413
|
+
##
|
414
|
+
# True if this gem has files in test_files
|
280
415
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
# MAINTAIN ORDER!
|
285
|
-
|
286
|
-
def _dump(limit)
|
287
|
-
Marshal.dump [
|
288
|
-
@rubygems_version,
|
289
|
-
@specification_version,
|
290
|
-
@name,
|
291
|
-
@version,
|
292
|
-
(Time === @date ? @date : (require 'time'; Time.parse(@date.to_s))),
|
293
|
-
@summary,
|
294
|
-
@required_ruby_version,
|
295
|
-
@required_rubygems_version,
|
296
|
-
@original_platform,
|
297
|
-
@dependencies,
|
298
|
-
@rubyforge_project,
|
299
|
-
@email,
|
300
|
-
@authors,
|
301
|
-
@description,
|
302
|
-
@homepage,
|
303
|
-
@has_rdoc,
|
304
|
-
@new_platform,
|
305
|
-
]
|
306
|
-
end
|
416
|
+
def has_unit_tests?
|
417
|
+
not test_files.empty?
|
418
|
+
end
|
307
419
|
|
308
|
-
|
309
|
-
|
420
|
+
# :stopdoc:
|
421
|
+
alias has_test_suite? has_unit_tests?
|
422
|
+
# :startdoc:
|
310
423
|
|
311
|
-
|
312
|
-
|
424
|
+
##
|
425
|
+
# Specification constructor. Assigns the default values to the attributes
|
426
|
+
# and yields itself for further initialization.
|
313
427
|
|
314
|
-
|
315
|
-
|
428
|
+
def initialize
|
429
|
+
@new_platform = nil
|
430
|
+
assign_defaults
|
431
|
+
@loaded = false
|
432
|
+
@loaded_from = nil
|
316
433
|
|
317
|
-
|
434
|
+
yield self if block_given?
|
318
435
|
|
319
|
-
|
320
|
-
|
321
|
-
current_version
|
322
|
-
MARSHAL_FIELDS[current_version]
|
323
|
-
else
|
324
|
-
MARSHAL_FIELDS[spec.specification_version]
|
325
|
-
end
|
436
|
+
@@gather.call(self) if @@gather
|
437
|
+
end
|
326
438
|
|
327
|
-
|
328
|
-
|
329
|
-
end
|
439
|
+
##
|
440
|
+
# Duplicates array_attributes from +other_spec+ so state isn't shared.
|
330
441
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
spec.instance_variable_set :@dependencies, array[9]
|
341
|
-
spec.instance_variable_set :@rubyforge_project, array[10]
|
342
|
-
spec.instance_variable_set :@email, array[11]
|
343
|
-
spec.instance_variable_set :@authors, array[12]
|
344
|
-
spec.instance_variable_set :@description, array[13]
|
345
|
-
spec.instance_variable_set :@homepage, array[14]
|
346
|
-
spec.instance_variable_set :@has_rdoc, array[15]
|
347
|
-
spec.instance_variable_set :@new_platform, array[16]
|
348
|
-
spec.instance_variable_set :@platform, array[16].to_s
|
349
|
-
spec.instance_variable_set :@loaded, false
|
350
|
-
|
351
|
-
spec
|
442
|
+
def initialize_copy(other_spec)
|
443
|
+
other_ivars = other_spec.instance_variables
|
444
|
+
other_ivars = other_ivars.map { |ivar| ivar.intern } if # for 1.9
|
445
|
+
other_ivars.any? { |ivar| String === ivar }
|
446
|
+
|
447
|
+
self.class.array_attributes.each do |name|
|
448
|
+
name = :"@#{name}"
|
449
|
+
next unless other_ivars.include? name
|
450
|
+
instance_variable_set name, other_spec.instance_variable_get(name).dup
|
352
451
|
end
|
452
|
+
end
|
353
453
|
|
354
|
-
|
355
|
-
|
454
|
+
##
|
455
|
+
# Each attribute has a default value (possibly nil). Here, we initialize
|
456
|
+
# all attributes to their default value. This is done through the
|
457
|
+
# accessor methods, so special behaviours will be honored. Furthermore,
|
458
|
+
# we take a _copy_ of the default so each specification instance has its
|
459
|
+
# own empty arrays, etc.
|
356
460
|
|
357
|
-
|
358
|
-
|
461
|
+
def assign_defaults
|
462
|
+
@@nil_attributes.each do |name|
|
463
|
+
instance_variable_set name, nil
|
359
464
|
end
|
360
465
|
|
361
|
-
|
362
|
-
|
466
|
+
@@non_nil_attributes.each do |name, default|
|
467
|
+
value = case default
|
468
|
+
when Time, Numeric, Symbol, true, false, nil then default
|
469
|
+
else default.dup
|
470
|
+
end
|
363
471
|
|
364
|
-
|
365
|
-
dependencies.select { |d| d.type == :development }
|
472
|
+
instance_variable_set name, value
|
366
473
|
end
|
367
474
|
|
368
|
-
|
369
|
-
|
370
|
-
|
475
|
+
# HACK
|
476
|
+
instance_variable_set :@new_platform, Gem::Platform::RUBY
|
477
|
+
end
|
478
|
+
|
479
|
+
##
|
480
|
+
# Special loader for YAML files. When a Specification object is loaded
|
481
|
+
# from a YAML file, it bypasses the normal Ruby object initialization
|
482
|
+
# routine (#initialize). This method makes up for that and deals with
|
483
|
+
# gems of different ages.
|
484
|
+
#
|
485
|
+
# 'input' can be anything that YAML.load() accepts: String or IO.
|
486
|
+
|
487
|
+
def self.from_yaml(input)
|
488
|
+
input = normalize_yaml_input input
|
489
|
+
spec = YAML.load input
|
490
|
+
|
491
|
+
if spec && spec.class == FalseClass then
|
492
|
+
raise Gem::EndOfYAMLException
|
371
493
|
end
|
372
494
|
|
373
|
-
|
374
|
-
|
375
|
-
@test_files = [] unless defined? @test_files
|
376
|
-
@test_files << val
|
495
|
+
unless Gem::Specification === spec then
|
496
|
+
raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
|
377
497
|
end
|
378
498
|
|
379
|
-
|
380
|
-
|
381
|
-
|
499
|
+
unless (spec.instance_variables.include? '@specification_version' or
|
500
|
+
spec.instance_variables.include? :@specification_version) and
|
501
|
+
spec.instance_variable_get :@specification_version
|
502
|
+
spec.instance_variable_set :@specification_version,
|
503
|
+
NONEXISTENT_SPECIFICATION_VERSION
|
504
|
+
end
|
382
505
|
|
383
|
-
|
506
|
+
spec
|
507
|
+
end
|
384
508
|
|
385
|
-
|
386
|
-
|
509
|
+
##
|
510
|
+
# Loads ruby format gemspec from +filename+
|
511
|
+
|
512
|
+
def self.load(filename)
|
513
|
+
gemspec = nil
|
514
|
+
fail "NESTED Specification.load calls not allowed!" if @@gather
|
515
|
+
@@gather = proc { |gs| gemspec = gs }
|
516
|
+
data = File.read(filename)
|
517
|
+
eval(data)
|
518
|
+
gemspec
|
519
|
+
ensure
|
520
|
+
@@gather = nil
|
521
|
+
end
|
387
522
|
|
388
|
-
|
523
|
+
##
|
524
|
+
# Make sure the YAML specification is properly formatted with dashes
|
389
525
|
|
390
|
-
|
391
|
-
|
392
|
-
|
526
|
+
def self.normalize_yaml_input(input)
|
527
|
+
result = input.respond_to?(:read) ? input.read : input
|
528
|
+
result = "--- " + result unless result =~ /^--- /
|
529
|
+
result
|
530
|
+
end
|
393
531
|
|
394
|
-
|
395
|
-
|
532
|
+
##
|
533
|
+
# Sets the rubygems_version to the current RubyGems version
|
396
534
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
executables
|
401
|
-
end
|
402
|
-
rescue
|
403
|
-
return nil
|
404
|
-
end
|
535
|
+
def mark_version
|
536
|
+
@rubygems_version = Gem::RubyGemsVersion
|
537
|
+
end
|
405
538
|
|
406
|
-
|
407
|
-
|
539
|
+
##
|
540
|
+
# Ignore unknown attributes while loading
|
408
541
|
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
542
|
+
def method_missing(sym, *a, &b) # :nodoc:
|
543
|
+
if @specification_version > CURRENT_SPECIFICATION_VERSION and
|
544
|
+
sym.to_s =~ /=$/ then
|
545
|
+
warn "ignoring #{sym} loading #{full_name}" if $DEBUG
|
546
|
+
else
|
547
|
+
super
|
415
548
|
end
|
549
|
+
end
|
416
550
|
|
417
|
-
|
418
|
-
|
551
|
+
##
|
552
|
+
# Adds a development dependency named +gem+ with +requirements+ to this
|
553
|
+
# Gem. For example:
|
554
|
+
#
|
555
|
+
# spec.add_development_dependency 'jabber4r', '> 0.1', '<= 0.5'
|
556
|
+
#
|
557
|
+
# Development dependencies aren't installed by default and aren't
|
558
|
+
# activated when a gem is required.
|
419
559
|
|
420
|
-
|
560
|
+
def add_development_dependency(gem, *requirements)
|
561
|
+
add_dependency_with_type(gem, :development, *requirements)
|
562
|
+
end
|
421
563
|
|
422
|
-
|
423
|
-
|
564
|
+
##
|
565
|
+
# Adds a runtime dependency named +gem+ with +requirements+ to this Gem.
|
566
|
+
# For example:
|
567
|
+
#
|
568
|
+
# spec.add_runtime_dependency 'jabber4r', '> 0.1', '<= 0.5'
|
424
569
|
|
425
|
-
|
426
|
-
|
427
|
-
|
570
|
+
def add_runtime_dependency(gem, *requirements)
|
571
|
+
add_dependency_with_type(gem, :runtime, *requirements)
|
572
|
+
end
|
573
|
+
|
574
|
+
##
|
575
|
+
# Adds a runtime dependency
|
576
|
+
|
577
|
+
alias add_dependency add_runtime_dependency
|
428
578
|
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
# attributes, adds this spec to the list of loaded specs (see
|
434
|
-
# Specification.list), and yields itself for further initialization.
|
579
|
+
##
|
580
|
+
# Returns the full name (name-version) of this Gem. Platform information
|
581
|
+
# is included (name-version-platform) if it is specified and not the
|
582
|
+
# default Ruby platform.
|
435
583
|
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
@
|
441
|
-
|
584
|
+
def full_name
|
585
|
+
if platform == Gem::Platform::RUBY or platform.nil? then
|
586
|
+
"#{@name}-#{@version}"
|
587
|
+
else
|
588
|
+
"#{@name}-#{@version}-#{platform}"
|
589
|
+
end
|
590
|
+
end
|
442
591
|
|
443
|
-
|
592
|
+
##
|
593
|
+
# Returns the full name (name-version) of this gemspec using the original
|
594
|
+
# platform. For use with legacy gems.
|
444
595
|
|
445
|
-
|
596
|
+
def original_name # :nodoc:
|
597
|
+
if platform == Gem::Platform::RUBY or platform.nil? then
|
598
|
+
"#{@name}-#{@version}"
|
599
|
+
else
|
600
|
+
"#{@name}-#{@version}-#{@original_platform}"
|
446
601
|
end
|
602
|
+
end
|
447
603
|
|
448
|
-
|
449
|
-
|
450
|
-
# all attributes to their default value. This is done through the
|
451
|
-
# accessor methods, so special behaviours will be honored. Furthermore,
|
452
|
-
# we take a _copy_ of the default so each specification instance has its
|
453
|
-
# own empty arrays, etc.
|
604
|
+
##
|
605
|
+
# The full path to the gem (install path + full name).
|
454
606
|
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
607
|
+
def full_gem_path
|
608
|
+
path = File.join installation_path, 'gems', full_name
|
609
|
+
return path if File.directory? path
|
610
|
+
File.join installation_path, 'gems', original_name
|
611
|
+
end
|
459
612
|
|
460
|
-
|
461
|
-
|
462
|
-
when Time, Numeric, Symbol, true, false, nil then default
|
463
|
-
else default.dup
|
464
|
-
end
|
613
|
+
##
|
614
|
+
# The default (generated) file name of the gem.
|
465
615
|
|
466
|
-
|
467
|
-
|
616
|
+
def file_name
|
617
|
+
full_name + ".gem"
|
618
|
+
end
|
468
619
|
|
469
|
-
|
470
|
-
|
471
|
-
end
|
620
|
+
##
|
621
|
+
# The directory that this gem was installed into.
|
472
622
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
# routine (#initialize). This method makes up for that and deals with
|
477
|
-
# gems of different ages.
|
478
|
-
#
|
479
|
-
# 'input' can be anything that YAML.load() accepts: String or IO.
|
623
|
+
def installation_path
|
624
|
+
File.expand_path(File.dirname(File.dirname(@loaded_from)))
|
625
|
+
end
|
480
626
|
|
481
|
-
|
482
|
-
|
483
|
-
spec = YAML.load input
|
627
|
+
##
|
628
|
+
# Checks if this specification meets the requirement of +dependency+.
|
484
629
|
|
485
|
-
|
486
|
-
|
487
|
-
|
630
|
+
def satisfies_requirement?(dependency)
|
631
|
+
return @name == dependency.name &&
|
632
|
+
dependency.version_requirements.satisfied_by?(@version)
|
633
|
+
end
|
488
634
|
|
489
|
-
|
490
|
-
|
491
|
-
end
|
635
|
+
##
|
636
|
+
# Returns an object you can use to sort specifications in #sort_by.
|
492
637
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
spec.instance_variable_set :@specification_version,
|
497
|
-
NONEXISTENT_SPECIFICATION_VERSION
|
498
|
-
end
|
638
|
+
def sort_obj
|
639
|
+
[@name, @version, @new_platform == Gem::Platform::RUBY ? -1 : 1]
|
640
|
+
end
|
499
641
|
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
##
|
504
|
-
# Loads ruby format gemspec from +filename+
|
505
|
-
|
506
|
-
def self.load(filename)
|
507
|
-
gemspec = nil
|
508
|
-
fail "NESTED Specification.load calls not allowed!" if @@gather
|
509
|
-
@@gather = proc { |gs| gemspec = gs }
|
510
|
-
data = File.read(filename)
|
511
|
-
eval(data)
|
512
|
-
gemspec
|
513
|
-
ensure
|
514
|
-
@@gather = nil
|
515
|
-
end
|
642
|
+
def <=>(other) # :nodoc:
|
643
|
+
sort_obj <=> other.sort_obj
|
644
|
+
end
|
516
645
|
|
517
|
-
|
518
|
-
|
646
|
+
##
|
647
|
+
# Tests specs for equality (across all attributes).
|
519
648
|
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
##
|
527
|
-
# Sets the rubygems_version to the current RubyGems version
|
649
|
+
def ==(other) # :nodoc:
|
650
|
+
self.class === other && same_attributes?(other)
|
651
|
+
end
|
652
|
+
|
653
|
+
alias eql? == # :nodoc:
|
528
654
|
|
529
|
-
|
530
|
-
|
655
|
+
##
|
656
|
+
# True if this gem has the same attributes as +other+.
|
657
|
+
|
658
|
+
def same_attributes?(other)
|
659
|
+
@@attributes.each do |name, default|
|
660
|
+
return false unless self.send(name) == other.send(name)
|
531
661
|
end
|
662
|
+
true
|
663
|
+
end
|
532
664
|
|
533
|
-
|
534
|
-
# Ignore unknown attributes while loading
|
665
|
+
private :same_attributes?
|
535
666
|
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
667
|
+
def hash # :nodoc:
|
668
|
+
@@attributes.inject(0) { |hash_code, (name, default_value)|
|
669
|
+
n = self.send(name).hash
|
670
|
+
hash_code + n
|
671
|
+
}
|
672
|
+
end
|
673
|
+
|
674
|
+
def to_yaml(opts = {}) # :nodoc:
|
675
|
+
mark_version
|
676
|
+
|
677
|
+
attributes = @@attributes.map { |name,| name.to_s }.sort
|
678
|
+
attributes = attributes - %w[name version platform]
|
679
|
+
|
680
|
+
yaml = YAML.quick_emit object_id, opts do |out|
|
681
|
+
out.map taguri, to_yaml_style do |map|
|
682
|
+
map.add 'name', @name
|
683
|
+
map.add 'version', @version
|
684
|
+
platform = case @original_platform
|
685
|
+
when nil, '' then
|
686
|
+
'ruby'
|
687
|
+
when String then
|
688
|
+
@original_platform
|
689
|
+
else
|
690
|
+
@original_platform.to_s
|
691
|
+
end
|
692
|
+
map.add 'platform', platform
|
693
|
+
|
694
|
+
attributes.each do |name|
|
695
|
+
map.add name, instance_variable_get("@#{name}")
|
696
|
+
end
|
542
697
|
end
|
543
698
|
end
|
699
|
+
end
|
544
700
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
#
|
549
|
-
# spec.add_development_dependency 'jabber4r', '> 0.1', '<= 0.5'
|
550
|
-
#
|
551
|
-
# Development dependencies aren't installed by default and aren't
|
552
|
-
# activated when a gem is required.
|
553
|
-
|
554
|
-
def add_development_dependency(gem, *requirements)
|
555
|
-
add_dependency_with_type(gem, :development, *requirements)
|
701
|
+
def yaml_initialize(tag, vals) # :nodoc:
|
702
|
+
vals.each do |ivar, val|
|
703
|
+
instance_variable_set "@#{ivar}", val
|
556
704
|
end
|
557
705
|
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
#
|
562
|
-
# spec.add_runtime_dependency 'jabber4r', '> 0.1', '<= 0.5'
|
706
|
+
@original_platform = @platform # for backwards compatibility
|
707
|
+
self.platform = Gem::Platform.new @platform
|
708
|
+
end
|
563
709
|
|
564
|
-
|
565
|
-
|
710
|
+
##
|
711
|
+
# Returns a Ruby code representation of this specification, such that it
|
712
|
+
# can be eval'ed and reconstruct the same specification later. Attributes
|
713
|
+
# that still have their default values are omitted.
|
714
|
+
|
715
|
+
def to_ruby
|
716
|
+
mark_version
|
717
|
+
result = []
|
718
|
+
result << "# -*- encoding: utf-8 -*-"
|
719
|
+
result << nil
|
720
|
+
result << "Gem::Specification.new do |s|"
|
721
|
+
|
722
|
+
result << " s.name = #{ruby_code name}"
|
723
|
+
result << " s.version = #{ruby_code version}"
|
724
|
+
unless platform.nil? or platform == Gem::Platform::RUBY then
|
725
|
+
result << " s.platform = #{ruby_code original_platform}"
|
726
|
+
end
|
727
|
+
result << ""
|
728
|
+
result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version="
|
729
|
+
|
730
|
+
handled = [
|
731
|
+
:dependencies,
|
732
|
+
:name,
|
733
|
+
:platform,
|
734
|
+
:required_rubygems_version,
|
735
|
+
:specification_version,
|
736
|
+
:version,
|
737
|
+
]
|
738
|
+
|
739
|
+
attributes = @@attributes.sort_by { |attr_name,| attr_name.to_s }
|
740
|
+
|
741
|
+
attributes.each do |attr_name, default|
|
742
|
+
next if handled.include? attr_name
|
743
|
+
current_value = self.send(attr_name)
|
744
|
+
if current_value != default or
|
745
|
+
self.class.required_attribute? attr_name then
|
746
|
+
result << " s.#{attr_name} = #{ruby_code current_value}"
|
747
|
+
end
|
566
748
|
end
|
567
749
|
|
568
|
-
|
569
|
-
|
750
|
+
result << nil
|
751
|
+
result << " if s.respond_to? :specification_version then"
|
752
|
+
result << " current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION"
|
753
|
+
result << " s.specification_version = #{specification_version}"
|
754
|
+
result << nil
|
570
755
|
|
571
|
-
|
756
|
+
result << " if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then"
|
572
757
|
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
def full_name
|
579
|
-
if platform == Gem::Platform::RUBY or platform.nil? then
|
580
|
-
"#{@name}-#{@version}"
|
581
|
-
else
|
582
|
-
"#{@name}-#{@version}-#{platform}"
|
758
|
+
unless dependencies.empty? then
|
759
|
+
dependencies.each do |dep|
|
760
|
+
version_reqs_param = dep.requirements_list.inspect
|
761
|
+
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
|
762
|
+
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
583
763
|
end
|
584
764
|
end
|
585
765
|
|
586
|
-
|
587
|
-
# Returns the full name (name-version) of this gemspec using the original
|
588
|
-
# platform. For use with legacy gems.
|
766
|
+
result << " else"
|
589
767
|
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
"#{@name}-#{@version}-#{@original_platform}"
|
768
|
+
unless dependencies.empty? then
|
769
|
+
dependencies.each do |dep|
|
770
|
+
version_reqs_param = dep.requirements_list.inspect
|
771
|
+
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
595
772
|
end
|
596
773
|
end
|
597
774
|
|
598
|
-
|
599
|
-
# The full path to the gem (install path + full name).
|
775
|
+
result << ' end'
|
600
776
|
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
777
|
+
result << " else"
|
778
|
+
dependencies.each do |dep|
|
779
|
+
version_reqs_param = dep.requirements_list.inspect
|
780
|
+
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
781
|
+
end
|
782
|
+
result << " end"
|
606
783
|
|
607
|
-
|
608
|
-
|
784
|
+
result << "end"
|
785
|
+
result << nil
|
609
786
|
|
610
|
-
|
611
|
-
|
612
|
-
|
787
|
+
result.join "\n"
|
788
|
+
end
|
789
|
+
|
790
|
+
##
|
791
|
+
# Checks that the specification contains all required fields, and does a
|
792
|
+
# very basic sanity check.
|
793
|
+
#
|
794
|
+
# Raises InvalidSpecificationException if the spec does not pass the
|
795
|
+
# checks..
|
613
796
|
|
614
|
-
|
615
|
-
|
797
|
+
def validate
|
798
|
+
extend Gem::UserInteraction
|
799
|
+
normalize
|
616
800
|
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
File.expand_path path
|
801
|
+
if rubygems_version != Gem::RubyGemsVersion then
|
802
|
+
raise Gem::InvalidSpecificationException,
|
803
|
+
"expected RubyGems version #{Gem::RubyGemsVersion}, was #{rubygems_version}"
|
621
804
|
end
|
622
805
|
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
dependency.version_requirements.satisfied_by?(@version)
|
806
|
+
@@required_attributes.each do |symbol|
|
807
|
+
unless self.send symbol then
|
808
|
+
raise Gem::InvalidSpecificationException,
|
809
|
+
"missing value for attribute #{symbol}"
|
810
|
+
end
|
629
811
|
end
|
630
812
|
|
631
|
-
|
632
|
-
|
813
|
+
unless String === name then
|
814
|
+
raise Gem::InvalidSpecificationException,
|
815
|
+
"invalid value for attribute name: \"#{name.inspect}\""
|
816
|
+
end
|
633
817
|
|
634
|
-
|
635
|
-
|
818
|
+
if require_paths.empty? then
|
819
|
+
raise Gem::InvalidSpecificationException,
|
820
|
+
'specification must have at least one require_path'
|
636
821
|
end
|
637
822
|
|
638
|
-
|
639
|
-
|
823
|
+
@files.delete_if do |file| File.directory? file end
|
824
|
+
@test_files.delete_if do |file| File.directory? file end
|
825
|
+
@executables.delete_if do |file| File.directory? file end
|
826
|
+
@extra_rdoc_files.delete_if do |file| File.directory? file end
|
827
|
+
@extensions.delete_if do |file| File.directory? file end
|
828
|
+
|
829
|
+
non_files = files.select do |file|
|
830
|
+
!File.file? file
|
640
831
|
end
|
641
832
|
|
642
|
-
|
643
|
-
|
833
|
+
unless non_files.empty? then
|
834
|
+
non_files = non_files.map { |file| file.inspect }
|
835
|
+
raise Gem::InvalidSpecificationException,
|
836
|
+
"[#{non_files.join ", "}] are not files"
|
837
|
+
end
|
644
838
|
|
645
|
-
|
646
|
-
|
839
|
+
unless specification_version.is_a?(Fixnum)
|
840
|
+
raise Gem::InvalidSpecificationException,
|
841
|
+
'specification_version must be a Fixnum (did you mean version?)'
|
647
842
|
end
|
648
843
|
|
649
|
-
|
844
|
+
case platform
|
845
|
+
when Gem::Platform, Gem::Platform::RUBY then # ok
|
846
|
+
else
|
847
|
+
raise Gem::InvalidSpecificationException,
|
848
|
+
"invalid platform #{platform.inspect}, see Gem::Platform"
|
849
|
+
end
|
650
850
|
|
651
|
-
|
652
|
-
|
851
|
+
unless Array === authors and
|
852
|
+
authors.all? { |author| String === author } then
|
853
|
+
raise Gem::InvalidSpecificationException,
|
854
|
+
'authors must be Array of Strings'
|
855
|
+
end
|
653
856
|
|
654
|
-
|
655
|
-
|
656
|
-
|
857
|
+
licenses.each{ |license|
|
858
|
+
if license.length > 64
|
859
|
+
raise Gem::InvalidSpecificationException,
|
860
|
+
"each license must be 64 characters or less"
|
657
861
|
end
|
658
|
-
|
862
|
+
}
|
863
|
+
|
864
|
+
# reject FIXME and TODO
|
865
|
+
|
866
|
+
unless authors.grep(/FIXME|TODO/).empty? then
|
867
|
+
raise Gem::InvalidSpecificationException,
|
868
|
+
'"FIXME" or "TODO" is not an author'
|
869
|
+
end
|
870
|
+
|
871
|
+
unless Array(email).grep(/FIXME|TODO/).empty? then
|
872
|
+
raise Gem::InvalidSpecificationException,
|
873
|
+
'"FIXME" or "TODO" is not an email address'
|
659
874
|
end
|
660
875
|
|
661
|
-
|
876
|
+
if description =~ /FIXME|TODO/ then
|
877
|
+
raise Gem::InvalidSpecificationException,
|
878
|
+
'"FIXME" or "TODO" is not a description'
|
879
|
+
end
|
662
880
|
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
hash_code + n
|
667
|
-
}
|
881
|
+
if summary =~ /FIXME|TODO/ then
|
882
|
+
raise Gem::InvalidSpecificationException,
|
883
|
+
'"FIXME" or "TODO" is not a summary'
|
668
884
|
end
|
669
885
|
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
attributes = @@attributes.map { |name,| name.to_s }.sort
|
674
|
-
attributes = attributes - %w[name version platform]
|
675
|
-
|
676
|
-
yaml = YAML.quick_emit object_id, opts do |out|
|
677
|
-
out.map taguri, to_yaml_style do |map|
|
678
|
-
map.add 'name', @name
|
679
|
-
map.add 'version', @version
|
680
|
-
platform = case @original_platform
|
681
|
-
when nil, '' then
|
682
|
-
'ruby'
|
683
|
-
when String then
|
684
|
-
@original_platform
|
685
|
-
else
|
686
|
-
@original_platform.to_s
|
687
|
-
end
|
688
|
-
map.add 'platform', platform
|
689
|
-
|
690
|
-
attributes.each do |name|
|
691
|
-
map.add name, instance_variable_get("@#{name}")
|
692
|
-
end
|
693
|
-
end
|
694
|
-
end
|
886
|
+
unless homepage.empty? or homepage =~ /\A[a-z][a-z\d+.-]*:/i then
|
887
|
+
raise Gem::InvalidSpecificationException,
|
888
|
+
"\"#{homepage}\" is not a URI"
|
695
889
|
end
|
696
890
|
|
697
|
-
|
698
|
-
vals.each do |ivar, val|
|
699
|
-
instance_variable_set "@#{ivar}", val
|
700
|
-
end
|
891
|
+
# Warnings
|
701
892
|
|
702
|
-
|
703
|
-
|
893
|
+
%w[author description email homepage rubyforge_project summary].each do |attribute|
|
894
|
+
value = self.send attribute
|
895
|
+
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
|
704
896
|
end
|
705
897
|
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
# that still have their default values are omitted.
|
710
|
-
|
711
|
-
def to_ruby
|
712
|
-
mark_version
|
713
|
-
result = []
|
714
|
-
result << "# -*- encoding: utf-8 -*-"
|
715
|
-
result << nil
|
716
|
-
result << "Gem::Specification.new do |s|"
|
717
|
-
|
718
|
-
result << " s.name = #{ruby_code name}"
|
719
|
-
result << " s.version = #{ruby_code version}"
|
720
|
-
unless platform.nil? or platform == Gem::Platform::RUBY then
|
721
|
-
result << " s.platform = #{ruby_code original_platform}"
|
722
|
-
end
|
723
|
-
result << ""
|
724
|
-
result << " s.required_rubygems_version = #{ruby_code required_rubygems_version} if s.respond_to? :required_rubygems_version="
|
725
|
-
|
726
|
-
handled = [
|
727
|
-
:dependencies,
|
728
|
-
:name,
|
729
|
-
:platform,
|
730
|
-
:required_rubygems_version,
|
731
|
-
:specification_version,
|
732
|
-
:version,
|
733
|
-
]
|
898
|
+
if summary and not summary.empty? and description == summary then
|
899
|
+
alert_warning 'description and summary are identical'
|
900
|
+
end
|
734
901
|
|
735
|
-
|
902
|
+
alert_warning "RDoc will not be generated (has_rdoc == false)" unless
|
903
|
+
has_rdoc
|
736
904
|
|
737
|
-
|
738
|
-
next if handled.include? attr_name
|
739
|
-
current_value = self.send(attr_name)
|
740
|
-
if current_value != default or
|
741
|
-
self.class.required_attribute? attr_name then
|
742
|
-
result << " s.#{attr_name} = #{ruby_code current_value}"
|
743
|
-
end
|
744
|
-
end
|
905
|
+
alert_warning "deprecated autorequire specified" if autorequire
|
745
906
|
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
result << " s.specification_version = #{specification_version}"
|
750
|
-
result << nil
|
907
|
+
executables.each do |executable|
|
908
|
+
executable_path = File.join bindir, executable
|
909
|
+
shebang = File.read(executable_path, 2) == '#!'
|
751
910
|
|
752
|
-
|
911
|
+
alert_warning "#{executable_path} is missing #! line" unless shebang
|
912
|
+
end
|
753
913
|
|
754
|
-
|
755
|
-
|
756
|
-
version_reqs_param = dep.requirements_list.inspect
|
757
|
-
dep.instance_variable_set :@type, :runtime if dep.type.nil? # HACK
|
758
|
-
result << " s.add_#{dep.type}_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
759
|
-
end
|
760
|
-
end
|
914
|
+
true
|
915
|
+
end
|
761
916
|
|
762
|
-
|
917
|
+
##
|
918
|
+
# Normalize the list of files so that:
|
919
|
+
# * All file lists have redundancies removed.
|
920
|
+
# * Files referenced in the extra_rdoc_files are included in the package
|
921
|
+
# file list.
|
922
|
+
|
923
|
+
def normalize
|
924
|
+
if defined?(@extra_rdoc_files) and @extra_rdoc_files then
|
925
|
+
@extra_rdoc_files.uniq!
|
926
|
+
@files ||= []
|
927
|
+
@files.concat(@extra_rdoc_files)
|
928
|
+
end
|
929
|
+
@files.uniq! if @files
|
930
|
+
end
|
763
931
|
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
932
|
+
##
|
933
|
+
# Return a list of all gems that have a dependency on this gemspec. The
|
934
|
+
# list is structured with entries that conform to:
|
935
|
+
#
|
936
|
+
# [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]
|
937
|
+
|
938
|
+
def dependent_gems
|
939
|
+
out = []
|
940
|
+
Gem.source_index.each do |name,gem|
|
941
|
+
gem.dependencies.each do |dep|
|
942
|
+
if self.satisfies_requirement?(dep) then
|
943
|
+
sats = []
|
944
|
+
find_all_satisfiers(dep) do |sat|
|
945
|
+
sats << sat
|
946
|
+
end
|
947
|
+
out << [gem, dep, sats]
|
768
948
|
end
|
769
949
|
end
|
950
|
+
end
|
951
|
+
out
|
952
|
+
end
|
770
953
|
|
771
|
-
|
954
|
+
def to_s # :nodoc:
|
955
|
+
"#<Gem::Specification name=#{@name} version=#{@version}>"
|
956
|
+
end
|
772
957
|
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})"
|
777
|
-
end
|
778
|
-
result << " end"
|
958
|
+
def pretty_print(q) # :nodoc:
|
959
|
+
q.group 2, 'Gem::Specification.new do |s|', 'end' do
|
960
|
+
q.breakable
|
779
961
|
|
780
|
-
|
781
|
-
result << nil
|
962
|
+
attributes = @@attributes.sort_by { |attr_name,| attr_name.to_s }
|
782
963
|
|
783
|
-
|
784
|
-
|
964
|
+
attributes.each do |attr_name, default|
|
965
|
+
current_value = self.send attr_name
|
966
|
+
if current_value != default or
|
967
|
+
self.class.required_attribute? attr_name then
|
785
968
|
|
786
|
-
|
787
|
-
# Checks that the specification contains all required fields, and does a
|
788
|
-
# very basic sanity check.
|
789
|
-
#
|
790
|
-
# Raises InvalidSpecificationException if the spec does not pass the
|
791
|
-
# checks..
|
969
|
+
q.text "s.#{attr_name} = "
|
792
970
|
|
793
|
-
|
794
|
-
|
795
|
-
normalize
|
971
|
+
if attr_name == :date then
|
972
|
+
current_value = current_value.utc
|
796
973
|
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
974
|
+
q.text "Time.utc(#{current_value.year}, #{current_value.month}, #{current_value.day})"
|
975
|
+
else
|
976
|
+
q.pp current_value
|
977
|
+
end
|
801
978
|
|
802
|
-
|
803
|
-
unless self.send symbol then
|
804
|
-
raise Gem::InvalidSpecificationException,
|
805
|
-
"missing value for attribute #{symbol}"
|
979
|
+
q.breakable
|
806
980
|
end
|
807
|
-
end
|
808
|
-
|
809
|
-
if require_paths.empty? then
|
810
|
-
raise Gem::InvalidSpecificationException,
|
811
|
-
"specification must have at least one require_path"
|
812
|
-
end
|
813
|
-
|
814
|
-
case platform
|
815
|
-
when Gem::Platform, Platform::RUBY then # ok
|
816
|
-
else
|
817
|
-
raise Gem::InvalidSpecificationException,
|
818
|
-
"invalid platform #{platform.inspect}, see Gem::Platform"
|
819
981
|
end
|
982
|
+
end
|
983
|
+
end
|
820
984
|
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
end
|
985
|
+
##
|
986
|
+
# Adds a dependency on gem +dependency+ with type +type+ that requires
|
987
|
+
# +requirements+. Valid types are currently <tt>:runtime</tt> and
|
988
|
+
# <tt>:development</tt>.
|
826
989
|
|
827
|
-
|
990
|
+
def add_dependency_with_type(dependency, type, *requirements)
|
991
|
+
requirements = if requirements.empty? then
|
992
|
+
Gem::Requirement.default
|
993
|
+
else
|
994
|
+
requirements.flatten
|
995
|
+
end
|
828
996
|
|
829
|
-
|
830
|
-
|
831
|
-
alert_warning "no #{attribute} specified" if value.nil? or value.empty?
|
832
|
-
end
|
997
|
+
unless dependency.respond_to?(:name) &&
|
998
|
+
dependency.respond_to?(:version_requirements)
|
833
999
|
|
834
|
-
|
835
|
-
|
1000
|
+
dependency = Gem::Dependency.new(dependency, requirements, type)
|
1001
|
+
end
|
836
1002
|
|
837
|
-
|
1003
|
+
dependencies << dependency
|
1004
|
+
end
|
838
1005
|
|
839
|
-
|
840
|
-
executable_path = File.join bindir, executable
|
841
|
-
shebang = File.read(executable_path, 2) == '#!'
|
1006
|
+
private :add_dependency_with_type
|
842
1007
|
|
843
|
-
|
844
|
-
|
1008
|
+
##
|
1009
|
+
# Finds all gems that satisfy +dep+
|
845
1010
|
|
846
|
-
|
1011
|
+
def find_all_satisfiers(dep)
|
1012
|
+
Gem.source_index.each do |_, gem|
|
1013
|
+
yield gem if gem.satisfies_requirement? dep
|
847
1014
|
end
|
1015
|
+
end
|
848
1016
|
|
849
|
-
|
850
|
-
# Normalize the list of files so that:
|
851
|
-
# * All file lists have redundancies removed.
|
852
|
-
# * Files referenced in the extra_rdoc_files are included in the package
|
853
|
-
# file list.
|
854
|
-
#
|
855
|
-
# Also, the summary and description are converted to a normal format.
|
856
|
-
|
857
|
-
def normalize
|
858
|
-
if defined?(@extra_rdoc_files) and @extra_rdoc_files then
|
859
|
-
@extra_rdoc_files.uniq!
|
860
|
-
@files ||= []
|
861
|
-
@files.concat(@extra_rdoc_files)
|
862
|
-
end
|
863
|
-
@files.uniq! if @files
|
864
|
-
end
|
1017
|
+
private :find_all_satisfiers
|
865
1018
|
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
end
|
883
|
-
end
|
884
|
-
end
|
885
|
-
out
|
1019
|
+
##
|
1020
|
+
# Return a string containing a Ruby code representation of the given
|
1021
|
+
# object.
|
1022
|
+
|
1023
|
+
def ruby_code(obj)
|
1024
|
+
case obj
|
1025
|
+
when String then '%q{' + obj + '}'
|
1026
|
+
when Array then obj.inspect
|
1027
|
+
when Gem::Version then obj.to_s.inspect
|
1028
|
+
when Date then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
1029
|
+
when Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
1030
|
+
when Numeric then obj.inspect
|
1031
|
+
when true, false, nil then obj.inspect
|
1032
|
+
when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
|
1033
|
+
when Gem::Requirement then "Gem::Requirement.new(#{obj.to_s.inspect})"
|
1034
|
+
else raise Gem::Exception, "ruby_code case not handled: #{obj.class}"
|
886
1035
|
end
|
1036
|
+
end
|
887
1037
|
|
888
|
-
|
889
|
-
"#<Gem::Specification name=#{@name} version=#{@version}>"
|
890
|
-
end
|
1038
|
+
private :ruby_code
|
891
1039
|
|
892
|
-
|
893
|
-
requirements = if requirements.empty? then
|
894
|
-
Gem::Requirement.default
|
895
|
-
else
|
896
|
-
requirements.flatten
|
897
|
-
end
|
1040
|
+
# :section: Required gemspec attributes
|
898
1041
|
|
899
|
-
|
900
|
-
|
1042
|
+
##
|
1043
|
+
# :attr_accessor: rubygems_version
|
1044
|
+
#
|
1045
|
+
# The version of RubyGems used to create this gem
|
901
1046
|
|
902
|
-
|
903
|
-
end
|
1047
|
+
required_attribute :rubygems_version, Gem::RubyGemsVersion
|
904
1048
|
|
905
|
-
|
906
|
-
|
1049
|
+
##
|
1050
|
+
# :attr_accessor: specification_version
|
1051
|
+
#
|
1052
|
+
# The Gem::Specification version of this gemspec
|
907
1053
|
|
908
|
-
|
1054
|
+
required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION
|
909
1055
|
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
end
|
915
|
-
end
|
916
|
-
end
|
1056
|
+
##
|
1057
|
+
# :attr_accessor: name
|
1058
|
+
#
|
1059
|
+
# This gem's name
|
917
1060
|
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
def ruby_code(obj)
|
925
|
-
case obj
|
926
|
-
when String then '%q{' + obj + '}'
|
927
|
-
when Array then obj.inspect
|
928
|
-
when Gem::Version then obj.to_s.inspect
|
929
|
-
when Date then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
930
|
-
when Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
931
|
-
when Numeric then obj.inspect
|
932
|
-
when true, false, nil then obj.inspect
|
933
|
-
when Gem::Platform then "Gem::Platform.new(#{obj.to_a.inspect})"
|
934
|
-
when Gem::Requirement then "Gem::Requirement.new(#{obj.to_s.inspect})"
|
935
|
-
else raise Exception, "ruby_code case not handled: #{obj.class}"
|
936
|
-
end
|
937
|
-
end
|
938
|
-
|
939
|
-
private :ruby_code
|
1061
|
+
required_attribute :name
|
1062
|
+
|
1063
|
+
##
|
1064
|
+
# :attr_accessor: version
|
1065
|
+
#
|
1066
|
+
# This gem's version
|
940
1067
|
|
941
|
-
|
942
|
-
|
943
|
-
##
|
944
|
-
# The version of RubyGems used to create this gem
|
1068
|
+
required_attribute :version
|
945
1069
|
|
946
|
-
|
1070
|
+
##
|
1071
|
+
# :attr_accessor: date
|
1072
|
+
#
|
1073
|
+
# The date this gem was created
|
947
1074
|
|
948
|
-
|
949
|
-
# The Gem::Specification version of this gemspec
|
1075
|
+
required_attribute :date, TODAY
|
950
1076
|
|
951
|
-
|
1077
|
+
##
|
1078
|
+
# :attr_accessor: summary
|
1079
|
+
#
|
1080
|
+
# A short summary of this gem's description. Displayed in `gem list -d`.
|
952
1081
|
|
953
|
-
|
954
|
-
# This gem's name
|
1082
|
+
required_attribute :summary
|
955
1083
|
|
956
|
-
|
1084
|
+
##
|
1085
|
+
# :attr_accessor: require_paths
|
1086
|
+
#
|
1087
|
+
# Paths in the gem to add to $LOAD_PATH when this gem is activated
|
957
1088
|
|
958
|
-
|
959
|
-
# This gem's version
|
1089
|
+
required_attribute :require_paths, ['lib']
|
960
1090
|
|
961
|
-
|
1091
|
+
# :section: Optional gemspec attributes
|
962
1092
|
|
963
|
-
|
964
|
-
|
1093
|
+
##
|
1094
|
+
# :attr_accessor: email
|
1095
|
+
#
|
1096
|
+
# A contact email for this gem
|
965
1097
|
|
966
|
-
|
1098
|
+
attribute :email
|
967
1099
|
|
968
|
-
|
969
|
-
|
1100
|
+
##
|
1101
|
+
# :attr_accessor: homepage
|
1102
|
+
#
|
1103
|
+
# The URL of this gem's home page
|
970
1104
|
|
971
|
-
|
1105
|
+
attribute :homepage
|
972
1106
|
|
973
|
-
|
974
|
-
|
1107
|
+
##
|
1108
|
+
# :attr_accessor: rubyforge_project
|
1109
|
+
#
|
1110
|
+
# The rubyforge project this gem lives under. i.e. RubyGems'
|
1111
|
+
# rubyforge_project is "rubygems".
|
975
1112
|
|
976
|
-
|
1113
|
+
attribute :rubyforge_project
|
977
1114
|
|
978
|
-
|
1115
|
+
##
|
1116
|
+
# :attr_accessor: description
|
1117
|
+
#
|
1118
|
+
# A long description of this gem
|
979
1119
|
|
980
|
-
|
981
|
-
# A contact email for this gem
|
982
|
-
|
983
|
-
attribute :email
|
1120
|
+
attribute :description
|
984
1121
|
|
985
|
-
|
986
|
-
|
1122
|
+
##
|
1123
|
+
# :attr_accessor: autorequire
|
1124
|
+
#
|
1125
|
+
# Autorequire was used by old RubyGems to automatically require a file.
|
1126
|
+
# It no longer is supported.
|
987
1127
|
|
988
|
-
|
1128
|
+
attribute :autorequire
|
989
1129
|
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
attribute :rubyforge_project
|
1130
|
+
##
|
1131
|
+
# :attr_accessor: default_executable
|
1132
|
+
#
|
1133
|
+
# The default executable for this gem.
|
995
1134
|
|
996
|
-
|
997
|
-
# A long description of this gem
|
1135
|
+
attribute :default_executable
|
998
1136
|
|
999
|
-
|
1137
|
+
##
|
1138
|
+
# :attr_accessor: bindir
|
1139
|
+
#
|
1140
|
+
# The path in the gem for executable scripts
|
1000
1141
|
|
1001
|
-
|
1002
|
-
# Autorequire was used by old RubyGems to automatically require a file.
|
1003
|
-
# It no longer is supported.
|
1142
|
+
attribute :bindir, 'bin'
|
1004
1143
|
|
1005
|
-
|
1144
|
+
##
|
1145
|
+
# :attr_accessor: has_rdoc
|
1146
|
+
#
|
1147
|
+
# True if this gem is RDoc-compliant
|
1006
1148
|
|
1007
|
-
|
1008
|
-
# The default executable for this gem.
|
1149
|
+
attribute :has_rdoc, false
|
1009
1150
|
|
1010
|
-
|
1151
|
+
##
|
1152
|
+
# True if this gem supports RDoc
|
1011
1153
|
|
1012
|
-
|
1013
|
-
# The path in the gem for executable scripts
|
1154
|
+
alias :has_rdoc? :has_rdoc
|
1014
1155
|
|
1015
|
-
|
1156
|
+
##
|
1157
|
+
# :attr_accessor: required_ruby_version
|
1158
|
+
#
|
1159
|
+
# The ruby of version required by this gem
|
1016
1160
|
|
1017
|
-
|
1018
|
-
# True if this gem is RDoc-compliant
|
1161
|
+
attribute :required_ruby_version, Gem::Requirement.default
|
1019
1162
|
|
1020
|
-
|
1163
|
+
##
|
1164
|
+
# :attr_accessor: required_rubygems_version
|
1165
|
+
#
|
1166
|
+
# The RubyGems version required by this gem
|
1021
1167
|
|
1022
|
-
|
1023
|
-
# True if this gem supports RDoc
|
1168
|
+
attribute :required_rubygems_version, Gem::Requirement.default
|
1024
1169
|
|
1025
|
-
|
1170
|
+
##
|
1171
|
+
# :attr_accessor: platform
|
1172
|
+
#
|
1173
|
+
# The platform this gem runs on. See Gem::Platform for details.
|
1026
1174
|
|
1027
|
-
|
1028
|
-
# The ruby of version required by this gem
|
1175
|
+
attribute :platform, Gem::Platform::RUBY
|
1029
1176
|
|
1030
|
-
|
1177
|
+
##
|
1178
|
+
# :attr_accessor: signing_key
|
1179
|
+
#
|
1180
|
+
# The key used to sign this gem. See Gem::Security for details.
|
1031
1181
|
|
1032
|
-
|
1033
|
-
# The RubyGems version required by this gem
|
1182
|
+
attribute :signing_key, nil
|
1034
1183
|
|
1035
|
-
|
1184
|
+
##
|
1185
|
+
# :attr_accessor: cert_chain
|
1186
|
+
#
|
1187
|
+
# The certificate chain used to sign this gem. See Gem::Security for
|
1188
|
+
# details.
|
1036
1189
|
|
1037
|
-
|
1038
|
-
# The platform this gem runs on. See Gem::Platform for details.
|
1190
|
+
attribute :cert_chain, []
|
1039
1191
|
|
1040
|
-
|
1192
|
+
##
|
1193
|
+
# :attr_accessor: post_install_message
|
1194
|
+
#
|
1195
|
+
# A message that gets displayed after the gem is installed
|
1041
1196
|
|
1042
|
-
|
1043
|
-
# The key used to sign this gem. See Gem::Security for details.
|
1197
|
+
attribute :post_install_message, nil
|
1044
1198
|
|
1045
|
-
|
1199
|
+
##
|
1200
|
+
# :attr_accessor: authors
|
1201
|
+
#
|
1202
|
+
# The list of authors who wrote this gem
|
1046
1203
|
|
1047
|
-
|
1048
|
-
# The certificate chain used to sign this gem. See Gem::Security for
|
1049
|
-
# details.
|
1204
|
+
array_attribute :authors
|
1050
1205
|
|
1051
|
-
|
1206
|
+
##
|
1207
|
+
# :attr_accessor: licenses
|
1208
|
+
#
|
1209
|
+
# The license(s) for the library. Each license must be a short name, no
|
1210
|
+
# more than 64 characters.
|
1052
1211
|
|
1053
|
-
|
1054
|
-
# A message that gets displayed after the gem is installed
|
1212
|
+
array_attribute :licenses
|
1055
1213
|
|
1056
|
-
|
1214
|
+
##
|
1215
|
+
# :attr_accessor: files
|
1216
|
+
#
|
1217
|
+
# Files included in this gem. You cannot append to this accessor, you must
|
1218
|
+
# assign to it.
|
1219
|
+
#
|
1220
|
+
# Only add files you can require to this list, not directories, etc.
|
1221
|
+
#
|
1222
|
+
# Directories are automatically stripped from this list when building a gem,
|
1223
|
+
# other non-files cause an error.
|
1057
1224
|
|
1058
|
-
|
1059
|
-
# The list of authors who wrote this gem
|
1225
|
+
array_attribute :files
|
1060
1226
|
|
1061
|
-
|
1227
|
+
##
|
1228
|
+
# :attr_accessor: test_files
|
1229
|
+
#
|
1230
|
+
# Test files included in this gem. You cannot append to this accessor, you
|
1231
|
+
# must assign to it.
|
1062
1232
|
|
1063
|
-
|
1064
|
-
|
1233
|
+
array_attribute :test_files
|
1234
|
+
|
1235
|
+
##
|
1236
|
+
# :attr_accessor: rdoc_options
|
1237
|
+
#
|
1238
|
+
# An ARGV-style array of options to RDoc
|
1065
1239
|
|
1066
|
-
|
1240
|
+
array_attribute :rdoc_options
|
1067
1241
|
|
1068
|
-
|
1069
|
-
|
1242
|
+
##
|
1243
|
+
# :attr_accessor: extra_rdoc_files
|
1244
|
+
#
|
1245
|
+
# Extra files to add to RDoc
|
1070
1246
|
|
1071
|
-
|
1247
|
+
array_attribute :extra_rdoc_files
|
1072
1248
|
|
1073
|
-
|
1074
|
-
|
1249
|
+
##
|
1250
|
+
# :attr_accessor: executables
|
1251
|
+
#
|
1252
|
+
# Executables included in the gem
|
1075
1253
|
|
1076
|
-
|
1254
|
+
array_attribute :executables
|
1077
1255
|
|
1078
|
-
|
1079
|
-
|
1256
|
+
##
|
1257
|
+
# :attr_accessor: extensions
|
1258
|
+
#
|
1259
|
+
# Extensions to build when installing the gem. See
|
1260
|
+
# Gem::Installer#build_extensions for valid values.
|
1080
1261
|
|
1081
|
-
|
1262
|
+
array_attribute :extensions
|
1082
1263
|
|
1083
|
-
|
1084
|
-
|
1264
|
+
##
|
1265
|
+
# :attr_accessor: requirements
|
1266
|
+
#
|
1267
|
+
# An array or things required by this gem. Not used by anything
|
1268
|
+
# presently.
|
1085
1269
|
|
1086
|
-
|
1270
|
+
array_attribute :requirements
|
1087
1271
|
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1272
|
+
##
|
1273
|
+
# :attr_reader: dependencies
|
1274
|
+
#
|
1275
|
+
# A list of Gem::Dependency objects this gem depends on.
|
1091
1276
|
|
1092
|
-
|
1277
|
+
array_attribute :dependencies
|
1093
1278
|
|
1094
|
-
|
1095
|
-
# An array or things required by this gem. Not used by anything
|
1096
|
-
# presently.
|
1279
|
+
read_only :dependencies
|
1097
1280
|
|
1098
|
-
|
1281
|
+
# :section: Aliased gemspec attributes
|
1099
1282
|
|
1100
|
-
|
1101
|
-
|
1283
|
+
##
|
1284
|
+
# Singular accessor for #executables
|
1102
1285
|
|
1103
|
-
|
1286
|
+
attribute_alias_singular :executable, :executables
|
1104
1287
|
|
1105
|
-
|
1288
|
+
##
|
1289
|
+
# Singular accessor for #authors
|
1106
1290
|
|
1107
|
-
|
1291
|
+
attribute_alias_singular :author, :authors
|
1108
1292
|
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
attribute_alias_singular :executable, :executables
|
1293
|
+
##
|
1294
|
+
# Singular accessor for #licenses
|
1113
1295
|
|
1114
|
-
|
1115
|
-
# Singular accessor for authors
|
1296
|
+
attribute_alias_singular :license, :licenses
|
1116
1297
|
|
1117
|
-
|
1298
|
+
##
|
1299
|
+
# Singular accessor for #require_paths
|
1118
1300
|
|
1119
|
-
|
1120
|
-
# Singular accessor for require_paths
|
1301
|
+
attribute_alias_singular :require_path, :require_paths
|
1121
1302
|
|
1122
|
-
|
1303
|
+
##
|
1304
|
+
# Singular accessor for #test_files
|
1123
1305
|
|
1124
|
-
|
1125
|
-
# Singular accessor for test_files
|
1306
|
+
attribute_alias_singular :test_file, :test_files
|
1126
1307
|
|
1127
|
-
|
1308
|
+
overwrite_accessor :version= do |version|
|
1309
|
+
@version = Gem::Version.create(version)
|
1310
|
+
self.required_rubygems_version = '> 1.3.1' if @version.prerelease?
|
1311
|
+
return @version
|
1312
|
+
end
|
1128
1313
|
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1314
|
+
overwrite_accessor :platform do
|
1315
|
+
@new_platform
|
1316
|
+
end
|
1132
1317
|
|
1133
|
-
|
1134
|
-
|
1318
|
+
overwrite_accessor :platform= do |platform|
|
1319
|
+
if @original_platform.nil? or
|
1320
|
+
@original_platform == Gem::Platform::RUBY then
|
1321
|
+
@original_platform = platform
|
1135
1322
|
end
|
1136
1323
|
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
end
|
1142
|
-
|
1143
|
-
case platform
|
1144
|
-
when Gem::Platform::CURRENT then
|
1145
|
-
@new_platform = Gem::Platform.local
|
1146
|
-
@original_platform = @new_platform.to_s
|
1147
|
-
|
1148
|
-
when Gem::Platform then
|
1149
|
-
@new_platform = platform
|
1150
|
-
|
1151
|
-
# legacy constants
|
1152
|
-
when nil, Gem::Platform::RUBY then
|
1153
|
-
@new_platform = Gem::Platform::RUBY
|
1154
|
-
when 'mswin32' then # was Gem::Platform::WIN32
|
1155
|
-
@new_platform = Gem::Platform.new 'x86-mswin32'
|
1156
|
-
when 'i586-linux' then # was Gem::Platform::LINUX_586
|
1157
|
-
@new_platform = Gem::Platform.new 'x86-linux'
|
1158
|
-
when 'powerpc-darwin' then # was Gem::Platform::DARWIN
|
1159
|
-
@new_platform = Gem::Platform.new 'ppc-darwin'
|
1160
|
-
else
|
1161
|
-
@new_platform = Gem::Platform.new platform
|
1162
|
-
end
|
1324
|
+
case platform
|
1325
|
+
when Gem::Platform::CURRENT then
|
1326
|
+
@new_platform = Gem::Platform.local
|
1327
|
+
@original_platform = @new_platform.to_s
|
1163
1328
|
|
1164
|
-
|
1329
|
+
when Gem::Platform then
|
1330
|
+
@new_platform = platform
|
1165
1331
|
|
1166
|
-
|
1332
|
+
# legacy constants
|
1333
|
+
when nil, Gem::Platform::RUBY then
|
1334
|
+
@new_platform = Gem::Platform::RUBY
|
1335
|
+
when 'mswin32' then # was Gem::Platform::WIN32
|
1336
|
+
@new_platform = Gem::Platform.new 'x86-mswin32'
|
1337
|
+
when 'i586-linux' then # was Gem::Platform::LINUX_586
|
1338
|
+
@new_platform = Gem::Platform.new 'x86-linux'
|
1339
|
+
when 'powerpc-darwin' then # was Gem::Platform::DARWIN
|
1340
|
+
@new_platform = Gem::Platform.new 'ppc-darwin'
|
1341
|
+
else
|
1342
|
+
@new_platform = Gem::Platform.new platform
|
1167
1343
|
end
|
1168
1344
|
|
1169
|
-
|
1170
|
-
@required_ruby_version = Gem::Requirement.create(value)
|
1171
|
-
end
|
1345
|
+
@platform = @new_platform.to_s
|
1172
1346
|
|
1173
|
-
|
1174
|
-
|
1175
|
-
end
|
1347
|
+
@new_platform
|
1348
|
+
end
|
1176
1349
|
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
# way to do it.
|
1181
|
-
case date
|
1182
|
-
when String then
|
1183
|
-
@date = if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
|
1184
|
-
Time.local($1.to_i, $2.to_i, $3.to_i)
|
1185
|
-
else
|
1186
|
-
require 'time'
|
1187
|
-
Time.parse date
|
1188
|
-
end
|
1189
|
-
when Time then
|
1190
|
-
@date = Time.local(date.year, date.month, date.day)
|
1191
|
-
when Date then
|
1192
|
-
@date = Time.local(date.year, date.month, date.day)
|
1193
|
-
else
|
1194
|
-
@date = TODAY
|
1195
|
-
end
|
1196
|
-
end
|
1350
|
+
overwrite_accessor :required_ruby_version= do |value|
|
1351
|
+
@required_ruby_version = Gem::Requirement.create(value)
|
1352
|
+
end
|
1197
1353
|
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
end
|
1354
|
+
overwrite_accessor :required_rubygems_version= do |value|
|
1355
|
+
@required_rubygems_version = Gem::Requirement.create(value)
|
1356
|
+
end
|
1202
1357
|
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1358
|
+
overwrite_accessor :date= do |date|
|
1359
|
+
# We want to end up with a Time object with one-day resolution.
|
1360
|
+
# This is the cleanest, most-readable, faster-than-using-Date
|
1361
|
+
# way to do it.
|
1362
|
+
case date
|
1363
|
+
when String then
|
1364
|
+
@date = if /\A(\d{4})-(\d{2})-(\d{2})\Z/ =~ date then
|
1365
|
+
Time.local($1.to_i, $2.to_i, $3.to_i)
|
1366
|
+
else
|
1367
|
+
require 'time'
|
1368
|
+
Time.parse date
|
1369
|
+
end
|
1370
|
+
when Time then
|
1371
|
+
@date = Time.local(date.year, date.month, date.day)
|
1372
|
+
when Date then
|
1373
|
+
@date = Time.local(date.year, date.month, date.day)
|
1374
|
+
else
|
1375
|
+
@date = TODAY
|
1209
1376
|
end
|
1377
|
+
end
|
1210
1378
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
gsub(/\n[ \t]*/, " ")
|
1216
|
-
end
|
1217
|
-
end
|
1379
|
+
overwrite_accessor :date do
|
1380
|
+
self.date = nil if @date.nil? # HACK Sets the default value for date
|
1381
|
+
@date
|
1382
|
+
end
|
1218
1383
|
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
result = nil
|
1227
|
-
end
|
1228
|
-
result
|
1229
|
-
rescue
|
1230
|
-
nil
|
1231
|
-
end
|
1232
|
-
end
|
1384
|
+
overwrite_accessor :summary= do |str|
|
1385
|
+
@summary = if str then
|
1386
|
+
str.strip.
|
1387
|
+
gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').
|
1388
|
+
gsub(/\n[ \t]*/, " ")
|
1389
|
+
end
|
1390
|
+
end
|
1233
1391
|
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
@
|
1392
|
+
overwrite_accessor :description= do |str|
|
1393
|
+
@description = str.to_s
|
1394
|
+
end
|
1395
|
+
|
1396
|
+
overwrite_accessor :default_executable do
|
1397
|
+
begin
|
1398
|
+
if defined?(@default_executable) and @default_executable
|
1399
|
+
result = @default_executable
|
1400
|
+
elsif @executables and @executables.size == 1
|
1401
|
+
result = Array(@executables).first
|
1244
1402
|
else
|
1245
|
-
|
1403
|
+
result = nil
|
1246
1404
|
end
|
1405
|
+
result
|
1406
|
+
rescue
|
1407
|
+
nil
|
1247
1408
|
end
|
1409
|
+
end
|
1248
1410
|
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
result.uniq.compact
|
1411
|
+
overwrite_accessor :test_files do
|
1412
|
+
# Handle the possibility that we have @test_suite_file but not
|
1413
|
+
# @test_files. This will happen when an old gem is loaded via
|
1414
|
+
# YAML.
|
1415
|
+
if defined? @test_suite_file then
|
1416
|
+
@test_files = [@test_suite_file].flatten
|
1417
|
+
@test_suite_file = nil
|
1257
1418
|
end
|
1419
|
+
if defined?(@test_files) and @test_files then
|
1420
|
+
@test_files
|
1421
|
+
else
|
1422
|
+
@test_files = []
|
1423
|
+
end
|
1424
|
+
end
|
1258
1425
|
|
1426
|
+
overwrite_accessor :files do
|
1427
|
+
result = []
|
1428
|
+
result.push(*@files) if defined?(@files)
|
1429
|
+
result.push(*@test_files) if defined?(@test_files)
|
1430
|
+
result.push(*(add_bindir(@executables)))
|
1431
|
+
result.push(*@extra_rdoc_files) if defined?(@extra_rdoc_files)
|
1432
|
+
result.push(*@extensions) if defined?(@extensions)
|
1433
|
+
result.uniq.compact
|
1259
1434
|
end
|
1260
1435
|
|
1261
1436
|
end
|