rubygems-update 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rubygems-update might be problematic. Click here for more details.
- data/ChangeLog +2335 -0
- data/README +54 -0
- data/Rakefile +293 -0
- data/Releases +98 -0
- data/TODO +7 -0
- data/bin/gem +11 -0
- data/bin/gem_server +111 -0
- data/bin/generate_yaml_index.rb +58 -0
- data/bin/update_rubygems +18 -0
- data/doc/doc.css +73 -0
- data/doc/makedoc.rb +4 -0
- data/examples/application/an-app.gemspec +26 -0
- data/examples/application/bin/myapp +3 -0
- data/examples/application/lib/somefunctionality.rb +3 -0
- data/gemspecs/README +4 -0
- data/gemspecs/cgikit-1.1.0.gemspec +18 -0
- data/gemspecs/jabber4r.gemspec +26 -0
- data/gemspecs/linguistics.gemspec +22 -0
- data/gemspecs/ook.gemspec +21 -0
- data/gemspecs/progressbar.gemspec +22 -0
- data/gemspecs/redcloth.gemspec +22 -0
- data/gemspecs/rublog.gemspec +23 -0
- data/gemspecs/ruby-doom.gemspec +21 -0
- data/gemspecs/rubyjdwp.gemspec +21 -0
- data/gemspecs/statistics.gemspec +21 -0
- data/lib/rubygems.rb +353 -0
- data/lib/rubygems/builder.rb +54 -0
- data/lib/rubygems/cmd_manager.rb +127 -0
- data/lib/rubygems/command.rb +191 -0
- data/lib/rubygems/config_file.rb +57 -0
- data/lib/rubygems/doc_manager.rb +94 -0
- data/lib/rubygems/format.rb +65 -0
- data/lib/rubygems/gem_commands.rb +925 -0
- data/lib/rubygems/gem_runner.rb +23 -0
- data/lib/rubygems/installer.rb +621 -0
- data/lib/rubygems/loadpath_manager.rb +108 -0
- data/lib/rubygems/old_format.rb +150 -0
- data/lib/rubygems/open-uri.rb +604 -0
- data/lib/rubygems/package.rb +740 -0
- data/lib/rubygems/remote_installer.rb +499 -0
- data/lib/rubygems/rubygems_version.rb +6 -0
- data/lib/rubygems/source_index.rb +130 -0
- data/lib/rubygems/specification.rb +613 -0
- data/lib/rubygems/user_interaction.rb +176 -0
- data/lib/rubygems/validator.rb +148 -0
- data/lib/rubygems/version.rb +279 -0
- data/lib/ubygems.rb +4 -0
- data/pkgs/sources/lib/sources.rb +6 -0
- data/pkgs/sources/sources.gemspec +14 -0
- data/post-install.rb +75 -0
- data/redist/session.gem +433 -0
- data/scripts/buildtests.rb +25 -0
- data/scripts/gemdoc.rb +62 -0
- data/scripts/runtest.rb +17 -0
- data/scripts/specdoc.rb +164 -0
- data/setup.rb +1360 -0
- data/test/bogussources.rb +5 -0
- data/test/data/legacy/keyedlist-0.4.0.ruby +11 -0
- data/test/data/legacy/keyedlist-0.4.0.yaml +16 -0
- data/test/data/lib/code.rb +1 -0
- data/test/data/one/README.one +1 -0
- data/test/data/one/lib/one.rb +3 -0
- data/test/data/one/one.gemspec +17 -0
- data/test/data/one/one.yaml +40 -0
- data/test/functional.rb +145 -0
- data/test/gemenvironment.rb +45 -0
- data/test/gemutilities.rb +18 -0
- data/test/insure_session.rb +46 -0
- data/test/mock/gems/gems/sources-0.0.1/lib/sources.rb +5 -0
- data/test/mock/gems/specifications/sources-0.0.1.gemspec +8 -0
- data/test/mockgemui.rb +45 -0
- data/test/onegem.rb +23 -0
- data/test/simple_gem.rb +66 -0
- data/test/test_builder.rb +13 -0
- data/test/test_cached_fetcher.rb +60 -0
- data/test/test_check_command.rb +28 -0
- data/test/test_command.rb +130 -0
- data/test/test_configfile.rb +36 -0
- data/test/test_format.rb +70 -0
- data/test/test_gemloadpaths.rb +45 -0
- data/test/test_gempaths.rb +115 -0
- data/test/test_loadmanager.rb +40 -0
- data/test/test_local_cache.rb +157 -0
- data/test/test_package.rb +600 -0
- data/test/test_parse_commands.rb +179 -0
- data/test/test_process_commands.rb +21 -0
- data/test/test_remote_fetcher.rb +162 -0
- data/test/test_remote_installer.rb +154 -0
- data/test/test_source_index.rb +58 -0
- data/test/test_specification.rb +286 -0
- data/test/test_validator.rb +53 -0
- data/test/test_version_comparison.rb +204 -0
- data/test/testgem.rc +6 -0
- data/test/user_capture.rb +1 -0
- data/test/yaml_data.rb +59 -0
- metadata +151 -0
@@ -0,0 +1,23 @@
|
|
1
|
+
$:.unshift '../lib'
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = 'rublog'
|
6
|
+
s.version = "0.8.0"
|
7
|
+
s.author = "Dave Thomas"
|
8
|
+
s.email = "dave@pragprog.com"
|
9
|
+
s.homepage = "http://www.pragprog.com/pragdave/Tech/Blog"
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.summary = "RubLog is a simple web log, based around the idea of displaying a set of regular files in a log-format."
|
12
|
+
s.files = Dir.glob("{extras,styles,convertors,doc,data,search,sidebar}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc")}
|
13
|
+
s.files.concat Dir.glob("*rb")
|
14
|
+
s.files.concat Dir.glob("*cgi")
|
15
|
+
s.files << "README"
|
16
|
+
s.require_path = "."
|
17
|
+
end
|
18
|
+
|
19
|
+
if $0==__FILE__
|
20
|
+
Gem::manage_gems
|
21
|
+
Gem::Builder.new(spec).build
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift '../lib'
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = 'ruby-doom'
|
6
|
+
s.version = "0.0.7"
|
7
|
+
s.author = "Tom Copeland"
|
8
|
+
s.email = "tom@infoether.com"
|
9
|
+
s.homepage = "http://ruby-doom.rubyforge.org/"
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.summary = "Ruby-DOOM provides a scripting API for creating DOOM maps. It also provides higher-level APIs to make map creation easier."
|
12
|
+
s.files = Dir.glob("{samples,tests,lib,docs}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc")}
|
13
|
+
s.require_path = 'lib'
|
14
|
+
s.autorequire = 'doom'
|
15
|
+
end
|
16
|
+
|
17
|
+
if $0==__FILE__
|
18
|
+
Gem::manage_gems
|
19
|
+
Gem::Builder.new(spec).build
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift '../lib'
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = 'RubyJDWP'
|
6
|
+
s.version = "0.0.1"
|
7
|
+
s.author = "Rich Kilmer, Chad Fowler"
|
8
|
+
s.email = "rich@infoether.com, chad@chadfowler.com"
|
9
|
+
s.homepage = "http://rubyforge.org/projects/rubyjdwp"
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.summary = "Ruby implementation of the Java Debug Wire Protocol. This version is pre-alpha."
|
12
|
+
s.files = Dir.glob("{examples,lib,doc}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc")}
|
13
|
+
s.require_path = 'lib'
|
14
|
+
s.autorequire = 'jdi'
|
15
|
+
end
|
16
|
+
|
17
|
+
if $0==__FILE__
|
18
|
+
Gem::manage_gems
|
19
|
+
Gem::Builder.new(spec).build
|
20
|
+
end
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift '../lib'
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
spec = Gem::Specification.new do |s|
|
5
|
+
s.name = 'statistics'
|
6
|
+
s.version = "2001.2.28"
|
7
|
+
s.author = "Gotoken"
|
8
|
+
s.email = "gotoken@notwork.org"
|
9
|
+
s.homepage = "http://www.notwork.org/~gotoken/ruby/p/statistics/"
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.summary = "module Math::Statistics provides common statistical functions"
|
12
|
+
s.files = Dir.glob("{sample,lib,docs}/**/*").delete_if {|item| item.include?("CVS") || item.include?("rdoc")}
|
13
|
+
s.require_path = 'lib'
|
14
|
+
s.autorequire = 'math/statistics'
|
15
|
+
end
|
16
|
+
|
17
|
+
if $0==__FILE__
|
18
|
+
Gem::manage_gems
|
19
|
+
Gem::Builder.new(spec).build
|
20
|
+
end
|
21
|
+
|
data/lib/rubygems.rb
ADDED
@@ -0,0 +1,353 @@
|
|
1
|
+
module Gem
|
2
|
+
class LoadError < ::LoadError
|
3
|
+
attr_accessor :name, :version_requirement
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
module Kernel
|
8
|
+
|
9
|
+
##
|
10
|
+
# Adds a Ruby Gem to the $LOAD_PATH. Before a Gem is loaded, its required
|
11
|
+
# Gems are loaded (by specified version or highest version). If the version
|
12
|
+
# information is omitted, the highest version Gem of the supplied name is
|
13
|
+
# loaded. If a Gem is not found that meets the version requirement and/or
|
14
|
+
# a required Gem is not found, a Gem::LoadError is raised. More information on
|
15
|
+
# version requirements can be found in the Gem::Version documentation.
|
16
|
+
#
|
17
|
+
# As a shortcut, the +gem+ parameter can be a _path_, for example:
|
18
|
+
#
|
19
|
+
# require_gem 'rake/packagetask'
|
20
|
+
#
|
21
|
+
# This is strictly short for
|
22
|
+
#
|
23
|
+
# require_gem 'rake'
|
24
|
+
# require 'rake/packagetask'
|
25
|
+
#
|
26
|
+
# You can define the environment variable GEM_SKIP as a way to not
|
27
|
+
# load specified gems. you might do this to test out changes that haven't
|
28
|
+
# been intsalled yet. Example:
|
29
|
+
#
|
30
|
+
# GEM_SKIP=libA:libB ruby-I../libA -I../libB ./mycode.rb
|
31
|
+
#
|
32
|
+
# <i>This is an experimental feature added after versoin 0.7, on 2004-07-13. </i>
|
33
|
+
#
|
34
|
+
# gem:: [String or Gem::Dependency] The gem name or dependency instance.
|
35
|
+
# version_requirement:: [default="> 0.0.0"] The version requirement.
|
36
|
+
# return:: [Boolean] true if the Gem is loaded, otherwise false.
|
37
|
+
# raises:: [Gem::LoadError] if Gem cannot be found, is listed in GEM_SKIP, or version requirement not met.
|
38
|
+
#
|
39
|
+
def require_gem(gem, *version_requirements)
|
40
|
+
skip_list = (ENV['GEM_SKIP'] || "").split(/:/)
|
41
|
+
raise Gem::LoadError, "skipping #{gem}" if skip_list.include? gem
|
42
|
+
Gem.activate(gem, true, *version_requirements)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
##
|
48
|
+
# Main module to hold all RubyGem classes/modules.
|
49
|
+
#
|
50
|
+
module Gem
|
51
|
+
require 'rubygems/rubygems_version.rb'
|
52
|
+
|
53
|
+
class Exception < RuntimeError
|
54
|
+
end
|
55
|
+
|
56
|
+
RubyGemsPackageVersion = RubyGemsVersion
|
57
|
+
|
58
|
+
DIRECTORIES = ['cache', 'doc', 'gems', 'specifications']
|
59
|
+
|
60
|
+
@@source_index = nil
|
61
|
+
|
62
|
+
class << self
|
63
|
+
|
64
|
+
def manage_gems
|
65
|
+
require 'rubygems/user_interaction'
|
66
|
+
require 'rubygems/builder'
|
67
|
+
require 'rubygems/format'
|
68
|
+
require 'rubygems/remote_installer'
|
69
|
+
require 'rubygems/installer'
|
70
|
+
require 'rubygems/validator'
|
71
|
+
require 'rubygems/doc_manager'
|
72
|
+
require 'rubygems/cmd_manager'
|
73
|
+
require 'rubygems/gem_runner'
|
74
|
+
require 'rubygems/config_file'
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Returns an Cache of specifications that are in the Gem.path
|
79
|
+
#
|
80
|
+
# return:: [Gem::Cache] cache of Gem::Specifications
|
81
|
+
#
|
82
|
+
def source_index
|
83
|
+
@@source_index ||= SourceIndex.from_installed_gems
|
84
|
+
@@source_index.refresh!
|
85
|
+
end
|
86
|
+
|
87
|
+
# Provide an alias for the old name.
|
88
|
+
alias cache source_index
|
89
|
+
|
90
|
+
##
|
91
|
+
# The directory path where Gems are to be installed.
|
92
|
+
#
|
93
|
+
# return:: [String] The directory path
|
94
|
+
#
|
95
|
+
def dir
|
96
|
+
@gem_home ||= nil
|
97
|
+
set_home(ENV['GEM_HOME'] || default_dir) unless @gem_home
|
98
|
+
@gem_home
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# List of directory paths to search for Gems.
|
103
|
+
#
|
104
|
+
# return:: [List<String>] List of directory paths.
|
105
|
+
#
|
106
|
+
def path
|
107
|
+
@gem_path ||= nil
|
108
|
+
set_paths(ENV['GEM_PATH']) unless @gem_path
|
109
|
+
@gem_path
|
110
|
+
end
|
111
|
+
|
112
|
+
# The home directory for the user.
|
113
|
+
def user_home
|
114
|
+
@user_home ||= find_home
|
115
|
+
end
|
116
|
+
|
117
|
+
##
|
118
|
+
# Activate a gem (i.e. add it to the Ruby load path). The gem
|
119
|
+
# must satisfy all the specified version constraints. If
|
120
|
+
# +autorequire+ is true, then automatically require the specified
|
121
|
+
# autorequire file in the gem spec.
|
122
|
+
#
|
123
|
+
def activate(gem, autorequire, *version_requirements)
|
124
|
+
unless version_requirements.size > 0
|
125
|
+
version_requirements = ["> 0.0.0"]
|
126
|
+
end
|
127
|
+
unless gem.respond_to?(:name) && gem.respond_to?(:version_requirements)
|
128
|
+
gem = Gem::Dependency.new(gem, version_requirements)
|
129
|
+
end
|
130
|
+
|
131
|
+
gem_name_pattern = /^#{gem.name}$/
|
132
|
+
matches = Gem.source_index.search(gem_name_pattern, gem.version_requirements)
|
133
|
+
if matches.size==0
|
134
|
+
matches = Gem.source_index.search(gem_name_pattern)
|
135
|
+
if matches.size==0
|
136
|
+
error = Gem::LoadError.new("\nCould not find RubyGem #{gem.name} (#{gem.version_requirements})\n")
|
137
|
+
error.name = gem.name
|
138
|
+
error.version_requirement = gem.version_requirements
|
139
|
+
raise error
|
140
|
+
else
|
141
|
+
error = Gem::LoadError.new("\nRubyGem version error: #{gem.name}(#{matches.first.version} not #{gem.version_requirements})\n")
|
142
|
+
error.name = gem.name
|
143
|
+
error.version_requirement = gem.version_requirements
|
144
|
+
raise error
|
145
|
+
end
|
146
|
+
else
|
147
|
+
# Get highest matching version
|
148
|
+
spec = matches.last
|
149
|
+
if spec.loaded?
|
150
|
+
result = spec.autorequire ? require(spec.autorequire) : false
|
151
|
+
return result || false
|
152
|
+
end
|
153
|
+
|
154
|
+
spec.loaded = true
|
155
|
+
|
156
|
+
# Load dependent gems first
|
157
|
+
spec.dependencies.each do |dep_gem|
|
158
|
+
activate(dep_gem, autorequire)
|
159
|
+
end
|
160
|
+
|
161
|
+
# add bin dir to require_path
|
162
|
+
if(spec.bindir) then
|
163
|
+
spec.require_paths << spec.bindir
|
164
|
+
end
|
165
|
+
|
166
|
+
# Now add the require_paths to the LOAD_PATH
|
167
|
+
spec.require_paths.each do |path|
|
168
|
+
$:.unshift File.join(spec.full_gem_path, path)
|
169
|
+
end
|
170
|
+
|
171
|
+
require spec.autorequire if autorequire && spec.autorequire
|
172
|
+
return true
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
##
|
178
|
+
# Reset the +dir+ and +path+ values. The next time +dir+ or +path+
|
179
|
+
# is requested, the values will be calculated from scratch. This is
|
180
|
+
# mainly used by the unit tests to provide test isolation.
|
181
|
+
#
|
182
|
+
def clear_paths
|
183
|
+
@gem_home = nil
|
184
|
+
@gem_path = nil
|
185
|
+
@@source_index = nil
|
186
|
+
end
|
187
|
+
|
188
|
+
# Use the +home+ and (optional) +paths+ values for +dir+ and +path+.
|
189
|
+
# Used mainly by the unit tests to provide environment isolation.
|
190
|
+
#
|
191
|
+
def use_paths(home, paths=[])
|
192
|
+
clear_paths
|
193
|
+
set_home(home) if home
|
194
|
+
set_paths(paths.join(File::PATH_SEPARATOR)) if paths
|
195
|
+
end
|
196
|
+
|
197
|
+
# Return a list of all possible load paths for all versions for
|
198
|
+
# all gems in the Gem installation.
|
199
|
+
#
|
200
|
+
def all_load_paths
|
201
|
+
result = []
|
202
|
+
Gem.path.each do |gemdir|
|
203
|
+
each_load_path(all_partials(gemdir)) do |load_path|
|
204
|
+
result << load_path
|
205
|
+
end
|
206
|
+
end
|
207
|
+
result
|
208
|
+
end
|
209
|
+
|
210
|
+
# Return a list of all possible load paths for the latest version
|
211
|
+
# for all gems in the Gem installation.
|
212
|
+
def latest_load_paths
|
213
|
+
result = []
|
214
|
+
Gem.path.each do |gemdir|
|
215
|
+
each_load_path(latest_partials(gemdir)) do |load_path|
|
216
|
+
result << load_path
|
217
|
+
end
|
218
|
+
end
|
219
|
+
result
|
220
|
+
end
|
221
|
+
|
222
|
+
def required_location(gemname, libfile, *version_constraints)
|
223
|
+
version_constraints = [">0"] if version_constraints.empty?
|
224
|
+
matches = Gem.source_index.search(gemname, version_constraints)
|
225
|
+
return nil if matches.empty?
|
226
|
+
spec = matches.last
|
227
|
+
spec.require_paths.each do |path|
|
228
|
+
result = File.join(spec.full_gem_path, path, libfile)
|
229
|
+
return result if File.exists?(result)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
private
|
235
|
+
|
236
|
+
# Return all the partial paths in the given +gemdir+.
|
237
|
+
def all_partials(gemdir)
|
238
|
+
Dir[File.join(gemdir, 'gems/*')]
|
239
|
+
end
|
240
|
+
|
241
|
+
# Return only the latest partial paths in the given +gemdir+.
|
242
|
+
def latest_partials(gemdir)
|
243
|
+
latest = {}
|
244
|
+
all_partials(gemdir).each do |gp|
|
245
|
+
base = File.basename(gp)
|
246
|
+
matches = /(.*)-((\d+\.)*\d+)/.match(base)
|
247
|
+
name, version = [matches[1], matches[2]]
|
248
|
+
ver = Gem::Version.new(version)
|
249
|
+
if latest[name].nil? || ver > latest[name][0]
|
250
|
+
latest[name] = [ver, gp]
|
251
|
+
end
|
252
|
+
end
|
253
|
+
latest.collect { |k,v| v[1] }
|
254
|
+
end
|
255
|
+
|
256
|
+
# Expand each partial gem path with each of the required paths
|
257
|
+
# specified in the Gem spec. Each expanded path is yielded.
|
258
|
+
def each_load_path(partials)
|
259
|
+
partials.each do |gp|
|
260
|
+
base = File.basename(gp)
|
261
|
+
specfn = File.join(dir, "specifications", base + ".gemspec")
|
262
|
+
if File.exist?(specfn)
|
263
|
+
spec = eval(File.read(specfn))
|
264
|
+
spec.require_paths.each do |rp|
|
265
|
+
yield(File.join(gp, rp))
|
266
|
+
end
|
267
|
+
else
|
268
|
+
filename = File.join(gp, 'lib')
|
269
|
+
yield(filename) if File.exist?(filename)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
# Set the Gem home directory (as reported by +dir+).
|
275
|
+
def set_home(home)
|
276
|
+
@gem_home = home
|
277
|
+
ensure_gem_subdirectories(@gem_home)
|
278
|
+
end
|
279
|
+
|
280
|
+
# Set the Gem search path (as reported by +path+).
|
281
|
+
def set_paths(gpaths)
|
282
|
+
if gpaths
|
283
|
+
@gem_path = gpaths.split(File::PATH_SEPARATOR)
|
284
|
+
@gem_path << Gem.dir
|
285
|
+
else
|
286
|
+
@gem_path = [Gem.dir]
|
287
|
+
end
|
288
|
+
@gem_path.uniq!
|
289
|
+
@gem_path.each do |gp| ensure_gem_subdirectories(gp) end
|
290
|
+
end
|
291
|
+
|
292
|
+
# Some comments from the ruby-talk list regarding finding the home
|
293
|
+
# directory:
|
294
|
+
#
|
295
|
+
# I have HOME, USERPROFILE and HOMEDRIVE + HOMEPATH. Ruby seems
|
296
|
+
# to be depending on HOME in those code samples. I propose that
|
297
|
+
# it should fallback to USERPROFILE and HOMEDRIVE + HOMEPATH (at
|
298
|
+
# least on Win32).
|
299
|
+
#
|
300
|
+
def find_home
|
301
|
+
['HOME', 'USERPROFILE'].each do |homekey|
|
302
|
+
return ENV[homekey] if ENV[homekey]
|
303
|
+
end
|
304
|
+
if ENV['HOMEDRIVE'] && ENV['HOMEPATH']
|
305
|
+
return "#{ENV['HOMEDRIVE']}:#{ENV['HOMEPATH']}"
|
306
|
+
end
|
307
|
+
begin
|
308
|
+
File.expand_path("~")
|
309
|
+
rescue Exception => ex
|
310
|
+
if File::ALT_SEPARATOR
|
311
|
+
"C:/"
|
312
|
+
else
|
313
|
+
"/"
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
public
|
319
|
+
|
320
|
+
# Default home directory path to be used if an alternate value is
|
321
|
+
# not specified in the environment.
|
322
|
+
def default_dir
|
323
|
+
#rbconfig = Dir.glob("{#{($LOAD_PATH).join(',')}}/rbconfig.rb").first
|
324
|
+
#if rbconfig
|
325
|
+
# module_eval File.read(rbconfig) unless const_defined?("Config")
|
326
|
+
#else
|
327
|
+
require 'rbconfig'
|
328
|
+
#end
|
329
|
+
File.join(Config::CONFIG['libdir'], 'ruby', 'gems', Config::CONFIG['ruby_version'])
|
330
|
+
end
|
331
|
+
|
332
|
+
private
|
333
|
+
|
334
|
+
# Quietly ensure the named Gem directory contains all the proper
|
335
|
+
# subdirectories. If we can't create a directory due to a
|
336
|
+
# permission problem, then we will silently continue.
|
337
|
+
def ensure_gem_subdirectories(gemdir)
|
338
|
+
DIRECTORIES.each do |filename|
|
339
|
+
fn = File.join(gemdir, filename)
|
340
|
+
if ! File.exists?(fn) && File.writable?(fn)
|
341
|
+
require 'fileutils'
|
342
|
+
FileUtils.mkdir_p(fn)
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
require 'rubygems/source_index'
|
351
|
+
require 'rubygems/specification'
|
352
|
+
require 'rubygems/version'
|
353
|
+
require 'rubygems/loadpath_manager'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "rubygems/package"
|
2
|
+
require "yaml"
|
3
|
+
|
4
|
+
module Gem
|
5
|
+
|
6
|
+
##
|
7
|
+
# The Builder class processes RubyGem specification files
|
8
|
+
# to produce a .gem file.
|
9
|
+
#
|
10
|
+
class Builder
|
11
|
+
|
12
|
+
include UserInteraction
|
13
|
+
##
|
14
|
+
# Constructs a builder instance for the provided specification
|
15
|
+
#
|
16
|
+
# spec:: [Gem::Specification] The specification instance
|
17
|
+
#
|
18
|
+
def initialize(spec)
|
19
|
+
@spec = spec
|
20
|
+
end
|
21
|
+
|
22
|
+
##
|
23
|
+
# Builds the gem from the specification. Returns the name of the file written.
|
24
|
+
#
|
25
|
+
def build
|
26
|
+
@spec.mark_version
|
27
|
+
@spec.validate
|
28
|
+
|
29
|
+
file_name = @spec.full_name+".gem"
|
30
|
+
|
31
|
+
Package.open(file_name, "w") do |pkg|
|
32
|
+
pkg.metadata = @spec.to_yaml
|
33
|
+
@spec.files.each do |file|
|
34
|
+
next if File.directory? file
|
35
|
+
pkg.add_file_simple(file, File.stat(file_name).mode & 0777,
|
36
|
+
File.size(file)) do |os|
|
37
|
+
os.write File.open(file, "rb"){|f|f.read}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
say success
|
42
|
+
file_name
|
43
|
+
end
|
44
|
+
|
45
|
+
def success
|
46
|
+
<<-EOM
|
47
|
+
Successfully built RubyGem
|
48
|
+
Name: #{@spec.name}
|
49
|
+
Version: #{@spec.version}
|
50
|
+
File: #{@spec.full_name+'.gem'}
|
51
|
+
EOM
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|