rubygems-update 2.1.0.rc.1 → 2.1.0.rc.2
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.txt +11 -3
- data/Manifest.txt +1 -0
- data/Rakefile +22 -18
- data/lib/rubygems.rb +8 -10
- data/lib/rubygems/basic_specification.rb +112 -108
- data/lib/rubygems/commands/build_command.rb +19 -0
- data/lib/rubygems/commands/check_command.rb +7 -0
- data/lib/rubygems/commands/cleanup_command.rb +5 -5
- data/lib/rubygems/commands/contents_command.rb +8 -0
- data/lib/rubygems/commands/dependency_command.rb +11 -0
- data/lib/rubygems/commands/environment_command.rb +3 -0
- data/lib/rubygems/commands/fetch_command.rb +10 -0
- data/lib/rubygems/commands/list_command.rb +12 -1
- data/lib/rubygems/commands/mirror_command.rb +6 -0
- data/lib/rubygems/commands/outdated_command.rb +9 -0
- data/lib/rubygems/commands/owner_command.rb +9 -2
- data/lib/rubygems/commands/pristine_command.rb +12 -11
- data/lib/rubygems/commands/push_command.rb +8 -2
- data/lib/rubygems/commands/query_command.rb +9 -0
- data/lib/rubygems/commands/rdoc_command.rb +6 -2
- data/lib/rubygems/commands/search_command.rb +14 -1
- data/lib/rubygems/commands/sources_command.rb +47 -0
- data/lib/rubygems/commands/specification_command.rb +16 -0
- data/lib/rubygems/commands/stale_command.rb +10 -0
- data/lib/rubygems/commands/uninstall_command.rb +19 -6
- data/lib/rubygems/commands/unpack_command.rb +18 -0
- data/lib/rubygems/commands/update_command.rb +9 -0
- data/lib/rubygems/commands/which_command.rb +11 -0
- data/lib/rubygems/commands/yank_command.rb +16 -2
- data/lib/rubygems/core_ext/kernel_require.rb +4 -4
- data/lib/rubygems/defaults.rb +7 -0
- data/lib/rubygems/dependency_installer.rb +1 -4
- data/lib/rubygems/ext/builder.rb +118 -0
- data/lib/rubygems/installer.rb +7 -60
- data/lib/rubygems/package_task.rb +5 -2
- data/lib/rubygems/remote_fetcher.rb +1 -1
- data/lib/rubygems/security/policy.rb +5 -0
- data/lib/rubygems/security/signer.rb +19 -1
- data/lib/rubygems/source.rb +7 -3
- data/lib/rubygems/source/local.rb +5 -4
- data/lib/rubygems/source/specific_file.rb +28 -0
- data/lib/rubygems/specification.rb +55 -44
- data/lib/rubygems/stub_specification.rb +93 -92
- data/lib/rubygems/test_case.rb +10 -9
- data/test/rubygems/test_gem.rb +27 -0
- data/test/rubygems/test_gem_commands_install_command.rb +1 -0
- data/test/rubygems/test_gem_commands_uninstall_command.rb +17 -8
- data/test/rubygems/test_gem_ext_builder.rb +97 -2
- data/test/rubygems/test_gem_installer.rb +0 -89
- data/test/rubygems/test_gem_package.rb +6 -8
- data/test/rubygems/test_gem_package_task.rb +23 -2
- data/test/rubygems/test_gem_security_policy.rb +11 -0
- data/test/rubygems/test_gem_security_signer.rb +6 -0
- data/test/rubygems/test_gem_source.rb +23 -0
- data/test/rubygems/test_gem_source_installed.rb +28 -0
- data/test/rubygems/test_gem_source_local.rb +29 -6
- data/test/rubygems/test_gem_source_specific_file.rb +38 -0
- data/test/rubygems/test_gem_specification.rb +10 -2
- metadata +7 -5
- metadata.gz.sig +0 -0
| @@ -1,8 +1,8 @@ | |
| 1 | 
            -
            require 'rubygems/source'
         | 
| 2 | 
            -
             | 
| 3 1 | 
             
            class Gem::Source::Local < Gem::Source
         | 
| 4 2 | 
             
              def initialize
         | 
| 5 | 
            -
                @ | 
| 3 | 
            +
                @specs   = nil
         | 
| 4 | 
            +
                @api_uri = nil
         | 
| 5 | 
            +
                @uri     = nil
         | 
| 6 6 | 
             
              end
         | 
| 7 7 |  | 
| 8 8 | 
             
              ##
         | 
| @@ -22,7 +22,8 @@ class Gem::Source::Local < Gem::Source | |
| 22 22 | 
             
              end
         | 
| 23 23 |  | 
| 24 24 | 
             
              def inspect # :nodoc:
         | 
| 25 | 
            -
                 | 
| 25 | 
            +
                keys = @specs ? @specs.keys.sort : 'NOT LOADED'
         | 
| 26 | 
            +
                "#<%s specs: %p>" % [self.class, keys]
         | 
| 26 27 | 
             
              end
         | 
| 27 28 |  | 
| 28 29 | 
             
              def load_specs(type)
         | 
| @@ -25,4 +25,32 @@ class Gem::Source::SpecificFile < Gem::Source | |
| 25 25 | 
             
                raise Gem::Exception, "Unable to download '#{spec.full_name}'"
         | 
| 26 26 | 
             
              end
         | 
| 27 27 |  | 
| 28 | 
            +
              def pretty_print q # :nodoc:
         | 
| 29 | 
            +
                q.group 2, '[Local:', ']' do
         | 
| 30 | 
            +
                  q.breakable
         | 
| 31 | 
            +
                  q.text @path
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              ##
         | 
| 36 | 
            +
              # Orders this source against +other+.
         | 
| 37 | 
            +
              #
         | 
| 38 | 
            +
              # If +other+ is a SpecificFile from a different gem name +nil+ is returned.
         | 
| 39 | 
            +
              #
         | 
| 40 | 
            +
              # If +other+ is a SpecificFile from the same gem name the versions are
         | 
| 41 | 
            +
              # compared using Gem::Version#<=>
         | 
| 42 | 
            +
              #
         | 
| 43 | 
            +
              # Otherwise Gem::Source#<=> is used.
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              def <=> other
         | 
| 46 | 
            +
                case other
         | 
| 47 | 
            +
                when Gem::Source::SpecificFile then
         | 
| 48 | 
            +
                  return nil if @spec.name != other.spec.name
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  @spec.version <=> other.spec.version
         | 
| 51 | 
            +
                else
         | 
| 52 | 
            +
                  super
         | 
| 53 | 
            +
                end
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 28 56 | 
             
            end
         | 
| @@ -206,15 +206,19 @@ class Gem::Specification < Gem::BasicSpecification | |
| 206 206 | 
             
              attr_reader :version
         | 
| 207 207 |  | 
| 208 208 | 
             
              ##
         | 
| 209 | 
            -
              # Paths in the gem to add to < | 
| 209 | 
            +
              # Paths in the gem to add to <code>$LOAD_PATH</code> when this gem is
         | 
| 210 | 
            +
              # activated.
         | 
| 211 | 
            +
              #
         | 
| 212 | 
            +
              # If you have an extension you do not need to add <code>"ext"</code> to the
         | 
| 213 | 
            +
              # require path, the extension build process will copy the extension files
         | 
| 214 | 
            +
              # into "lib" for you.
         | 
| 215 | 
            +
              #
         | 
| 216 | 
            +
              # The default value is <code>"lib"</code>
         | 
| 210 217 | 
             
              #
         | 
| 211 218 | 
             
              # Usage:
         | 
| 212 219 | 
             
              #
         | 
| 213 220 | 
             
              #   # If all library files are in the root directory...
         | 
| 214 221 | 
             
              #   spec.require_path = '.'
         | 
| 215 | 
            -
              #
         | 
| 216 | 
            -
              #   # If you have 'lib' and 'ext' directories...
         | 
| 217 | 
            -
              #   spec.require_paths << 'ext'
         | 
| 218 222 |  | 
| 219 223 | 
             
              attr_accessor :require_paths
         | 
| 220 224 |  | 
| @@ -228,7 +232,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 228 232 | 
             
              ##
         | 
| 229 233 | 
             
              # A short summary of this gem's description.  Displayed in `gem list -d`.
         | 
| 230 234 | 
             
              #
         | 
| 231 | 
            -
              # The description should be more detailed than the summary.
         | 
| 235 | 
            +
              # The #description should be more detailed than the summary.
         | 
| 232 236 | 
             
              #
         | 
| 233 237 | 
             
              # Usage:
         | 
| 234 238 | 
             
              #
         | 
| @@ -241,21 +245,23 @@ class Gem::Specification < Gem::BasicSpecification | |
| 241 245 | 
             
              #
         | 
| 242 246 | 
             
              # This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT.
         | 
| 243 247 | 
             
              #
         | 
| 244 | 
            -
              # Most gems contain pure Ruby code; they should simply leave the default | 
| 245 | 
            -
              # in place. | 
| 246 | 
            -
              #  | 
| 247 | 
            -
              # will only compile on a certain type of system. | 
| 248 | 
            -
              # pre-compiled code ( | 
| 249 | 
            -
              # the platform attribute appropriately. | 
| 250 | 
            -
              # Gem::Platform::CURRENT, which will cause the gem builder | 
| 251 | 
            -
              # to the appropriate value for the system on which the | 
| 248 | 
            +
              # Most gems contain pure Ruby code; they should simply leave the default
         | 
| 249 | 
            +
              # value in place.  Some gems contain C (or other) code to be compiled into a
         | 
| 250 | 
            +
              # Ruby "extension".  The should leave the default value in place unless
         | 
| 251 | 
            +
              # their code will only compile on a certain type of system.  Some gems
         | 
| 252 | 
            +
              # consist of pre-compiled code ("binary gems").  It's especially important
         | 
| 253 | 
            +
              # that they set the platform attribute appropriately.  A shortcut is to set
         | 
| 254 | 
            +
              # the platform to Gem::Platform::CURRENT, which will cause the gem builder
         | 
| 255 | 
            +
              # to set the platform to the appropriate value for the system on which the
         | 
| 256 | 
            +
              # build is being performed.
         | 
| 252 257 | 
             
              #
         | 
| 253 | 
            -
              # If this attribute is set to a non-default value, it will be included in | 
| 254 | 
            -
              # filename of the gem when it is built | 
| 258 | 
            +
              # If this attribute is set to a non-default value, it will be included in
         | 
| 259 | 
            +
              # the filename of the gem when it is built such as:
         | 
| 260 | 
            +
              # nokogiri-1.6.0-x86-mingw32.gem
         | 
| 255 261 | 
             
              #
         | 
| 256 262 | 
             
              # Usage:
         | 
| 257 263 | 
             
              #
         | 
| 258 | 
            -
              #   spec.platform = Gem::Platform | 
| 264 | 
            +
              #   spec.platform = Gem::Platform.local
         | 
| 259 265 |  | 
| 260 266 | 
             
              def platform= platform
         | 
| 261 267 | 
             
                if @original_platform.nil? or
         | 
| @@ -357,7 +363,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 357 363 | 
             
              attr_reader :description
         | 
| 358 364 |  | 
| 359 365 | 
             
              ##
         | 
| 360 | 
            -
              # A contact email for this gem
         | 
| 366 | 
            +
              # A contact email address (or addresses) for this gem
         | 
| 361 367 | 
             
              #
         | 
| 362 368 | 
             
              # Usage:
         | 
| 363 369 | 
             
              #
         | 
| @@ -473,6 +479,8 @@ class Gem::Specification < Gem::BasicSpecification | |
| 473 479 | 
             
              # Usage:
         | 
| 474 480 | 
             
              #
         | 
| 475 481 | 
             
              #  spec.extensions << 'ext/rmagic/extconf.rb'
         | 
| 482 | 
            +
              #
         | 
| 483 | 
            +
              # See Gem::Ext::Builder for information about writing extensions for gems.
         | 
| 476 484 |  | 
| 477 485 | 
             
              def extensions
         | 
| 478 486 | 
             
                @extensions ||= []
         | 
| @@ -502,6 +510,8 @@ class Gem::Specification < Gem::BasicSpecification | |
| 502 510 | 
             
              # This should just be the name of your license. The full
         | 
| 503 511 | 
             
              # text of the license should be inside of the gem when you build it.
         | 
| 504 512 | 
             
              #
         | 
| 513 | 
            +
              # You can set multiple licenses with #licenses=
         | 
| 514 | 
            +
              #
         | 
| 505 515 | 
             
              # Usage:
         | 
| 506 516 | 
             
              #   spec.license = 'MIT'
         | 
| 507 517 |  | 
| @@ -538,15 +548,20 @@ class Gem::Specification < Gem::BasicSpecification | |
| 538 548 | 
             
              end
         | 
| 539 549 |  | 
| 540 550 | 
             
              ##
         | 
| 541 | 
            -
              # The version of Ruby required by this gem
         | 
| 551 | 
            +
              # The version of Ruby required by this gem.  The ruby version can be
         | 
| 552 | 
            +
              # specified to the patch-level:
         | 
| 553 | 
            +
              #
         | 
| 554 | 
            +
              #   $ ruby -v -e 'p Gem.ruby_version'
         | 
| 555 | 
            +
              #   ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
         | 
| 556 | 
            +
              #   #<Gem::Version "2.0.0.247">
         | 
| 542 557 | 
             
              #
         | 
| 543 558 | 
             
              # Usage:
         | 
| 544 559 | 
             
              #
         | 
| 545 | 
            -
              #  #  | 
| 560 | 
            +
              #  # This gem will work with 1.8.6 or greater...
         | 
| 546 561 | 
             
              #  spec.required_ruby_version = '>= 1.8.6'
         | 
| 547 562 | 
             
              #
         | 
| 548 | 
            -
              #  #  | 
| 549 | 
            -
              #  spec.required_ruby_version = ' | 
| 563 | 
            +
              #  # Only with ruby 2.0.x
         | 
| 564 | 
            +
              #  spec.required_ruby_version = '~> 2.0'
         | 
| 550 565 |  | 
| 551 566 | 
             
              def required_ruby_version= req
         | 
| 552 567 | 
             
                @required_ruby_version = Gem::Requirement.create req
         | 
| @@ -554,7 +569,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 554 569 |  | 
| 555 570 | 
             
              ##
         | 
| 556 571 | 
             
              # Lists the external (to RubyGems) requirements that must be met for this gem
         | 
| 557 | 
            -
              # to work. | 
| 572 | 
            +
              # to work.  It's simply information for the user.
         | 
| 558 573 | 
             
              #
         | 
| 559 574 | 
             
              # Usage:
         | 
| 560 575 | 
             
              #
         | 
| @@ -566,7 +581,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 566 581 | 
             
              end
         | 
| 567 582 |  | 
| 568 583 | 
             
              ##
         | 
| 569 | 
            -
              # A collection of unit test files. | 
| 584 | 
            +
              # A collection of unit test files.  They will be loaded as unit tests when
         | 
| 570 585 | 
             
              # the user requests a gem to be unit tested.
         | 
| 571 586 | 
             
              #
         | 
| 572 587 | 
             
              # Usage:
         | 
| @@ -592,7 +607,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 592 607 | 
             
              #
         | 
| 593 608 | 
             
              # Deprecated: It is neither supported nor functional.
         | 
| 594 609 |  | 
| 595 | 
            -
              attr_accessor :autorequire
         | 
| 610 | 
            +
              attr_accessor :autorequire # :nodoc:
         | 
| 596 611 |  | 
| 597 612 | 
             
              ##
         | 
| 598 613 | 
             
              # Sets the default executable for this gem.
         | 
| @@ -615,9 +630,12 @@ class Gem::Specification < Gem::BasicSpecification | |
| 615 630 | 
             
              # The RubyGems version required by this gem
         | 
| 616 631 |  | 
| 617 632 | 
             
              attr_reader :required_rubygems_version
         | 
| 633 | 
            +
             | 
| 618 634 | 
             
              ##
         | 
| 619 635 | 
             
              # The rubyforge project this gem lives under.  i.e. RubyGems'
         | 
| 620 636 | 
             
              # rubyforge_project is "rubygems".
         | 
| 637 | 
            +
              #
         | 
| 638 | 
            +
              # This option is deprecated.
         | 
| 621 639 |  | 
| 622 640 | 
             
              attr_accessor :rubyforge_project
         | 
| 623 641 |  | 
| @@ -768,7 +786,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 768 786 | 
             
              # -- wilsonb
         | 
| 769 787 |  | 
| 770 788 | 
             
              def self.all= specs
         | 
| 771 | 
            -
                @@all = specs
         | 
| 789 | 
            +
                @@all = @@stubs = specs
         | 
| 772 790 | 
             
              end
         | 
| 773 791 |  | 
| 774 792 | 
             
              ##
         | 
| @@ -1320,7 +1338,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1320 1338 | 
             
              end
         | 
| 1321 1339 |  | 
| 1322 1340 | 
             
              ##
         | 
| 1323 | 
            -
              # Singular reader for #authors
         | 
| 1341 | 
            +
              # Singular reader for #authors.  Returns the first author in the list
         | 
| 1324 1342 |  | 
| 1325 1343 | 
             
              def author
         | 
| 1326 1344 | 
             
                val = authors and val.first
         | 
| @@ -1328,6 +1346,8 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1328 1346 |  | 
| 1329 1347 | 
             
              ##
         | 
| 1330 1348 | 
             
              # The list of author names who wrote this gem.
         | 
| 1349 | 
            +
              #
         | 
| 1350 | 
            +
              #   spec.authors = ['Chad Fowler', 'Jim Weirich', 'Rich Kilmer']
         | 
| 1331 1351 |  | 
| 1332 1352 | 
             
              def authors
         | 
| 1333 1353 | 
             
                @authors ||= []
         | 
| @@ -1407,7 +1427,9 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1407 1427 | 
             
              end
         | 
| 1408 1428 |  | 
| 1409 1429 | 
             
              ##
         | 
| 1410 | 
            -
              # The date this gem was created. | 
| 1430 | 
            +
              # The date this gem was created.  Lazily defaults to the current UTC date.
         | 
| 1431 | 
            +
              #
         | 
| 1432 | 
            +
              # There is no need to set this in your gem specification.
         | 
| 1411 1433 |  | 
| 1412 1434 | 
             
              def date
         | 
| 1413 1435 | 
             
                @date ||= TODAY
         | 
| @@ -1454,7 +1476,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1454 1476 | 
             
              # Deprecated: The name of the gem is assumed to be the name of the
         | 
| 1455 1477 | 
             
              # executable now.  See Gem.bin_path.
         | 
| 1456 1478 |  | 
| 1457 | 
            -
              def default_executable
         | 
| 1479 | 
            +
              def default_executable # :nodoc:
         | 
| 1458 1480 | 
             
                if defined?(@default_executable) and @default_executable
         | 
| 1459 1481 | 
             
                  result = @default_executable
         | 
| 1460 1482 | 
             
                elsif @executables and @executables.size == 1
         | 
| @@ -1513,7 +1535,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1513 1535 | 
             
              end
         | 
| 1514 1536 |  | 
| 1515 1537 | 
             
              ##
         | 
| 1516 | 
            -
              # A  | 
| 1538 | 
            +
              # A detailed description of this gem.  See also #summary
         | 
| 1517 1539 |  | 
| 1518 1540 | 
             
              def description= str
         | 
| 1519 1541 | 
             
                @description = str.to_s
         | 
| @@ -1672,7 +1694,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1672 1694 | 
             
              #
         | 
| 1673 1695 | 
             
              # Formerly used to indicate this gem was RDoc-capable.
         | 
| 1674 1696 |  | 
| 1675 | 
            -
              def has_rdoc
         | 
| 1697 | 
            +
              def has_rdoc # :nodoc:
         | 
| 1676 1698 | 
             
                true
         | 
| 1677 1699 | 
             
              end
         | 
| 1678 1700 |  | 
| @@ -1681,11 +1703,11 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1681 1703 | 
             
              #
         | 
| 1682 1704 | 
             
              # Formerly used to indicate this gem was RDoc-capable.
         | 
| 1683 1705 |  | 
| 1684 | 
            -
              def has_rdoc= ignored
         | 
| 1706 | 
            +
              def has_rdoc= ignored # :nodoc:
         | 
| 1685 1707 | 
             
                @has_rdoc = true
         | 
| 1686 1708 | 
             
              end
         | 
| 1687 1709 |  | 
| 1688 | 
            -
              alias :has_rdoc? :has_rdoc
         | 
| 1710 | 
            +
              alias :has_rdoc? :has_rdoc # :nodoc:
         | 
| 1689 1711 |  | 
| 1690 1712 | 
             
              ##
         | 
| 1691 1713 | 
             
              # True if this gem has files in test_files
         | 
| @@ -1818,7 +1840,7 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1818 1840 | 
             
                @licenses ||= []
         | 
| 1819 1841 | 
             
              end
         | 
| 1820 1842 |  | 
| 1821 | 
            -
              def  | 
| 1843 | 
            +
              def loaded_from= path # :nodoc:
         | 
| 1822 1844 | 
             
                super
         | 
| 1823 1845 |  | 
| 1824 1846 | 
             
                @bin_dir       = nil
         | 
| @@ -1831,17 +1853,6 @@ class Gem::Specification < Gem::BasicSpecification | |
| 1831 1853 | 
             
                @spec_file     = nil
         | 
| 1832 1854 | 
             
              end
         | 
| 1833 1855 |  | 
| 1834 | 
            -
              ##
         | 
| 1835 | 
            -
              # Path this gemspec was loaded from.  This attribute is not persisted.
         | 
| 1836 | 
            -
             | 
| 1837 | 
            -
              alias loaded_from filename
         | 
| 1838 | 
            -
             | 
| 1839 | 
            -
              ##
         | 
| 1840 | 
            -
              # Set the location a Specification was loaded from. +obj+ is converted
         | 
| 1841 | 
            -
              # to a String.
         | 
| 1842 | 
            -
             | 
| 1843 | 
            -
              alias loaded_from= filename=
         | 
| 1844 | 
            -
             | 
| 1845 1856 | 
             
              ##
         | 
| 1846 1857 | 
             
              # Sets the rubygems_version to the current RubyGems version.
         | 
| 1847 1858 |  | 
| @@ -1,119 +1,120 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                   | 
| 13 | 
            -
             | 
| 14 | 
            -
                   | 
| 15 | 
            -
             | 
| 16 | 
            -
                # :nodoc:
         | 
| 17 | 
            -
                class StubLine
         | 
| 18 | 
            -
                  attr_reader :parts
         | 
| 1 | 
            +
            ##
         | 
| 2 | 
            +
            # Gem::StubSpecification reads the stub: line from the gemspec.  This prevents
         | 
| 3 | 
            +
            # us having to eval the entire gemspec in order to find out certain
         | 
| 4 | 
            +
            # information.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            class Gem::StubSpecification < Gem::BasicSpecification
         | 
| 7 | 
            +
              # :nodoc:
         | 
| 8 | 
            +
              PREFIX = "# stub: "
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              OPEN_MODE = # :nodoc:
         | 
| 11 | 
            +
                if Object.const_defined? :Encoding then
         | 
| 12 | 
            +
                  'r:UTF-8:-'
         | 
| 13 | 
            +
                else
         | 
| 14 | 
            +
                  'r'
         | 
| 15 | 
            +
                end
         | 
| 19 16 |  | 
| 20 | 
            -
             | 
| 21 | 
            -
             | 
| 22 | 
            -
                  end
         | 
| 17 | 
            +
              class StubLine # :nodoc: all
         | 
| 18 | 
            +
                attr_reader :parts
         | 
| 23 19 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
             | 
| 26 | 
            -
             | 
| 20 | 
            +
                def initialize(data)
         | 
| 21 | 
            +
                  @parts = data[PREFIX.length..-1].split(" ")
         | 
| 22 | 
            +
                end
         | 
| 27 23 |  | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 24 | 
            +
                def name
         | 
| 25 | 
            +
                  @parts[0]
         | 
| 26 | 
            +
                end
         | 
| 31 27 |  | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 28 | 
            +
                def version
         | 
| 29 | 
            +
                  Gem::Version.new @parts[1]
         | 
| 30 | 
            +
                end
         | 
| 35 31 |  | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
                  end
         | 
| 32 | 
            +
                def platform
         | 
| 33 | 
            +
                  Gem::Platform.new @parts[2]
         | 
| 39 34 | 
             
                end
         | 
| 40 35 |  | 
| 41 | 
            -
                def  | 
| 42 | 
            -
                   | 
| 43 | 
            -
                  @data         = nil
         | 
| 44 | 
            -
                  @spec         = nil
         | 
| 36 | 
            +
                def require_paths
         | 
| 37 | 
            +
                  @parts[3..-1].join(" ").split("\0")
         | 
| 45 38 | 
             
                end
         | 
| 39 | 
            +
              end
         | 
| 46 40 |  | 
| 47 | 
            -
             | 
| 48 | 
            -
                 | 
| 41 | 
            +
              def initialize(filename)
         | 
| 42 | 
            +
                self.loaded_from = filename
         | 
| 43 | 
            +
                @data            = nil
         | 
| 44 | 
            +
                @spec            = nil
         | 
| 45 | 
            +
              end
         | 
| 49 46 |  | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
                end
         | 
| 47 | 
            +
              ##
         | 
| 48 | 
            +
              # True when this gem has been activated
         | 
| 53 49 |  | 
| 54 | 
            -
             | 
| 55 | 
            -
                 | 
| 50 | 
            +
              def activated?
         | 
| 51 | 
            +
                loaded = Gem.loaded_specs[name]
         | 
| 52 | 
            +
                loaded && loaded.version == version
         | 
| 53 | 
            +
              end
         | 
| 56 54 |  | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 55 | 
            +
              ##
         | 
| 56 | 
            +
              # If the gemspec contains a stubline, returns a StubLine instance. Otherwise
         | 
| 57 | 
            +
              # returns the full Gem::Specification.
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              def data
         | 
| 60 | 
            +
                unless @data
         | 
| 61 | 
            +
                  open loaded_from, OPEN_MODE do |file|
         | 
| 62 | 
            +
                    begin
         | 
| 63 | 
            +
                      file.readline # discard encoding line
         | 
| 64 | 
            +
                      stubline = file.readline.chomp
         | 
| 65 | 
            +
                      @data = StubLine.new(stubline) if stubline.start_with?(PREFIX)
         | 
| 66 | 
            +
                    rescue EOFError
         | 
| 67 | 
            +
                    end
         | 
| 68 | 
            +
                  end
         | 
| 59 69 | 
             
                end
         | 
| 60 70 |  | 
| 61 | 
            -
                 | 
| 62 | 
            -
             | 
| 71 | 
            +
                @data ||= to_spec
         | 
| 72 | 
            +
              end
         | 
| 63 73 |  | 
| 64 | 
            -
             | 
| 65 | 
            -
                  @platform ||= data.platform
         | 
| 66 | 
            -
                end
         | 
| 74 | 
            +
              private :data
         | 
| 67 75 |  | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 76 | 
            +
              ##
         | 
| 77 | 
            +
              # Name of the gem
         | 
| 70 78 |  | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 79 | 
            +
              def name
         | 
| 80 | 
            +
                @name ||= data.name
         | 
| 81 | 
            +
              end
         | 
| 74 82 |  | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 83 | 
            +
              ##
         | 
| 84 | 
            +
              # Platform of the gem
         | 
| 77 85 |  | 
| 78 | 
            -
             | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 86 | 
            +
              def platform
         | 
| 87 | 
            +
                @platform ||= data.platform
         | 
| 88 | 
            +
              end
         | 
| 81 89 |  | 
| 82 | 
            -
             | 
| 83 | 
            -
             | 
| 90 | 
            +
              ##
         | 
| 91 | 
            +
              # Require paths of the gem
         | 
| 84 92 |  | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
                end
         | 
| 93 | 
            +
              def require_paths
         | 
| 94 | 
            +
                @require_paths ||= data.require_paths
         | 
| 95 | 
            +
              end
         | 
| 89 96 |  | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 92 | 
            -
                # the filename contain a valid gemspec?
         | 
| 97 | 
            +
              ##
         | 
| 98 | 
            +
              # The full Gem::Specification for this gem, loaded from evalling its gemspec
         | 
| 93 99 |  | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 100 | 
            +
              def to_spec
         | 
| 101 | 
            +
                @spec ||= Gem::Specification.load(loaded_from)
         | 
| 102 | 
            +
              end
         | 
| 97 103 |  | 
| 98 | 
            -
             | 
| 99 | 
            -
             | 
| 100 | 
            -
             | 
| 101 | 
            -
                # If the gemspec contains a stubline, returns a StubLine instance. Otherwise
         | 
| 102 | 
            -
                # returns the full Gem::Specification.
         | 
| 103 | 
            -
             | 
| 104 | 
            -
                def data
         | 
| 105 | 
            -
                  unless @data
         | 
| 106 | 
            -
                    open filename, OPEN_MODE do |file|
         | 
| 107 | 
            -
                      begin
         | 
| 108 | 
            -
                        file.readline # discard encoding line
         | 
| 109 | 
            -
                        stubline = file.readline.chomp
         | 
| 110 | 
            -
                        @data = StubLine.new(stubline) if stubline.start_with?(PREFIX)
         | 
| 111 | 
            -
                      rescue EOFError
         | 
| 112 | 
            -
                      end
         | 
| 113 | 
            -
                    end
         | 
| 114 | 
            -
                  end
         | 
| 104 | 
            +
              ##
         | 
| 105 | 
            +
              # Is this StubSpecification valid? i.e. have we found a stub line, OR does
         | 
| 106 | 
            +
              # the filename contain a valid gemspec?
         | 
| 115 107 |  | 
| 116 | 
            -
             | 
| 117 | 
            -
                 | 
| 108 | 
            +
              def valid?
         | 
| 109 | 
            +
                data
         | 
| 118 110 | 
             
              end
         | 
| 111 | 
            +
             | 
| 112 | 
            +
              ##
         | 
| 113 | 
            +
              # Version of the gem
         | 
| 114 | 
            +
             | 
| 115 | 
            +
              def version
         | 
| 116 | 
            +
                @version ||= data.version
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
             | 
| 119 119 | 
             
            end
         | 
| 120 | 
            +
             |