Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Documenting Gem::Package class.

  • Loading branch information...
commit 38fe168e9382b04288d1cfaae7f97943baa078b2 1 parent c954bc5
@tute tute authored
View
38 lib/rubygems/package.rb
@@ -3,6 +3,42 @@
# Copyright (C) 2004 Mauricio Julio Fernández Pradier
# See LICENSE.txt for additional licensing information.
#++
+#
+# Example using a Gem::Package
+#
+# Builds a .gem file given a Gem::Specification. A .gem file is a tarball
+# which contains a data.tar.gz and metadata.gz, and possibly signatures.
+#
+# require 'rubygems'
+# require 'rubygems/package'
+#
+# spec = Gem::Specification.new do |s|
+# s.summary = "Ruby based make-like utility."
+# s.name = 'rake'
+# s.version = PKG_VERSION
+# s.requirements << 'none'
+# s.files = PKG_FILES
+# s.description = <<-EOF
+# Rake is a Make-like program implemented in Ruby. Tasks
+# and dependencies are specified in standard Ruby syntax.
+# EOF
+# end
+#
+# Gem::Package.build spec
+#
+# Reads a .gem file.
+#
+# require 'rubygems'
+# require 'rubygems/package'
+#
+# the_gem = Gem::Package.new(path_to_dot_gem)
+# the_gem.contents # get the files in the gem
+# the_gem.extract_files destination_directory # extract the gem into a directory
+# the_gem.spec # get the spec out of the gem
+# the_gem.verify # check the gem is OK (contains valid gem specification, contains a not corrupt contents archive)
+#
+# #files are the files in the .gem tar file, not the ruby files in the gem
+# #extract_files and #contents automatically call #verify
require 'rubygems/security'
require 'rubygems/specification'
@@ -92,7 +128,7 @@ def self.new gem
# Creates a new package that will read or write to the file +gem+.
def initialize gem # :notnew:
- @gem = gem
+ @gem = gem
@contents = nil
@digest = Gem::Security::DIGEST_ALGORITHM
View
3  lib/rubygems/package_task.rb
@@ -44,13 +44,10 @@
# require 'rubygems/package_task'
#
# spec = Gem::Specification.new do |s|
-# s.platform = Gem::Platform::RUBY
# s.summary = "Ruby based make-like utility."
# s.name = 'rake'
# s.version = PKG_VERSION
# s.requirements << 'none'
-# s.require_path = 'lib'
-# s.autorequire = 'rake'
# s.files = PKG_FILES
# s.description = <<-EOF
# Rake is a Make-like program implemented in Ruby. Tasks
View
4 lib/rubygems/requirement.rb
@@ -41,7 +41,7 @@ class BadRequirementError < ArgumentError; end
#
# If the input is "weird", the default version requirement is
# returned.
-
+
# REFACTOR: There's no reason that this can't be unified with .new.
# .new is the standard Ruby factory method.
@@ -124,7 +124,7 @@ def initialize *requirements
##
# true if this gem has no requirements.
-
+
# FIX: maybe this should be using #default ?
def none?
if @requirements.size == 1
Please sign in to comment.
Something went wrong with that request. Please try again.