diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 03:22:49 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-12-20 03:22:49 +0000 |
commit | 2ef9c50c6e405717d06362787c4549ca4f1c6485 (patch) | |
tree | ee99486567461dd5796f3d6edcc9e204187f2666 /lib/rdoc/ri/store.rb | |
parent | d7effd506f5b91a636f2e6452ef1946b923007c7 (diff) | |
download | ruby-2ef9c50c6e405717d06362787c4549ca4f1c6485.tar.gz |
Import RDoc 3
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30249 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri/store.rb')
-rw-r--r-- | lib/rdoc/ri/store.rb | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/rdoc/ri/store.rb b/lib/rdoc/ri/store.rb index db02202f81..1fcd313d0f 100644 --- a/lib/rdoc/ri/store.rb +++ b/lib/rdoc/ri/store.rb @@ -11,6 +11,11 @@ require 'fileutils' class RDoc::RI::Store ## + # If true this Store will not write any files + + attr_accessor :dry_run + + ## # Path this store reads or writes attr_accessor :path @@ -21,14 +26,18 @@ class RDoc::RI::Store attr_accessor :type + ## + # The contents of the Store + attr_reader :cache ## # Creates a new Store of +type+ that will load or save to +path+ def initialize path, type = nil - @type = type - @path = path + @dry_run = false + @type = type + @path = path @cache = { :class_methods => {}, @@ -178,6 +187,8 @@ class RDoc::RI::Store @cache[:instance_methods].each do |_, m| m.uniq!; m.sort! end @cache[:modules].uniq!; @cache[:modules].sort! + return if @dry_run + open cache_path, 'wb' do |io| Marshal.dump @cache, io end @@ -187,7 +198,7 @@ class RDoc::RI::Store # Writes the ri data for +klass+ def save_class klass - FileUtils.mkdir_p class_path(klass.full_name) + FileUtils.mkdir_p class_path(klass.full_name) unless @dry_run @cache[:modules] << klass.full_name @@ -214,7 +225,7 @@ class RDoc::RI::Store @cache[:ancestors][klass.full_name].push(*ancestors) attributes = klass.attributes.map do |attribute| - "#{attribute.type} #{attribute.name}" + "#{attribute.definition} #{attribute.name}" end unless attributes.empty? then @@ -222,6 +233,8 @@ class RDoc::RI::Store @cache[:attributes][klass.full_name].push(*attributes) end + return if @dry_run + open path, 'wb' do |io| Marshal.dump klass, io end @@ -231,7 +244,7 @@ class RDoc::RI::Store # Writes the ri data for +method+ on +klass+ def save_method klass, method - FileUtils.mkdir_p class_path(klass.full_name) + FileUtils.mkdir_p class_path(klass.full_name) unless @dry_run cache = if method.singleton then @cache[:class_methods] @@ -241,6 +254,8 @@ class RDoc::RI::Store cache[klass.full_name] ||= [] cache[klass.full_name] << method.name + return if @dry_run + open method_file(klass.full_name, method.full_name), 'wb' do |io| Marshal.dump method, io end |