Permalink
Browse files

Add support for RubyGems 1.7.x

Closes #272
  • Loading branch information...
1 parent 72ccf6c commit f4075ea5ddb3bb85bb79408e4128c877c166a69e @lsegal committed Apr 4, 2011
Showing with 24 additions and 6 deletions.
  1. +1 −1 Rakefile
  2. +23 −5 lib/yard/rubygems/specification.rb
View
2 Rakefile
@@ -1,4 +1,5 @@
require File.dirname(__FILE__) + '/lib/yard'
+require File.dirname(__FILE__) + '/lib/yard/rubygems/specification'
require 'rbconfig'
YARD::VERSION.replace(ENV['YARD_VERSION']) if ENV['YARD_VERSION']
@@ -9,7 +10,6 @@ task :default => :specs
desc "Builds the gem"
task :gem do
- Gem.load_plugins # load plugins because they are not autoloaded anymore
load 'yard.gemspec'
Gem::Builder.new(SPEC).build
end
View
28 lib/yard/rubygems/specification.rb
@@ -1,13 +1,9 @@
require 'rubygems/specification'
class Gem::Specification
- # has_rdoc should not be ignored!
- overwrite_accessor(:has_rdoc) { @has_rdoc }
- overwrite_accessor(:has_rdoc=) {|v| @has_rdoc = v }
-
# @since 0.5.3
def has_yardoc=(value)
- @has_rdoc = 'yard'
+ @has_rdoc = value ? 'yard' : false
end
def has_yardoc
@@ -20,4 +16,26 @@ def has_rdoc?
end
alias has_yardoc? has_yardoc
+
+ # has_rdoc should not be ignored!
+ if respond_to?(:overwrite_accessor)
+ overwrite_accessor(:has_rdoc) { @has_rdoc }
+ overwrite_accessor(:has_rdoc=) {|v| @has_rdoc = v }
+ else
+ attr_accessor :has_rdoc
+ end
+
+ if defined?(Gem::VERSION) && Gem::VERSION =~ /^1\.7\./
+ def _dump_with_rdoc(limit)
+ dmp = _dump_without_rdoc(limit)
+ dmp[15] = @has_rdoc
+ dmp
+ end
+ alias _dump_without_rdoc _dump
+ alias _dump _dump_with_rdoc
+
+ @@default_value[:has_rdoc] = true if defined?(@@default_value)
+ @@attributes << 'has_rdoc' if defined?(@@attributes)
+ @@non_nil_attributes << 'has_rdoc' if defined?(@@non_nil_attributes)
+ end
end

0 comments on commit f4075ea

Please sign in to comment.