Class: SdocAll::Ruby
- Extended by:
- ClassMethods
- Defined in:
- lib/sdoc_all/parts/ruby.rb
Defined Under Namespace
Modules: ClassMethods Classes: ArchiveInfo
Constant Summary
Constants included from Base::ClassMethods
Base::ClassMethods::BASE_PATH, Base::ClassMethods::DOCS_PATH, Base::ClassMethods::PUBLIC_PATH
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add_tasks(options = {}) ⇒ Object
-
#initialize(raw_config) ⇒ Ruby
constructor
A new instance of Ruby.
Methods included from ClassMethods
download_matching_archive, find_matching_archive, find_or_download_matching_archive, last_matching_ruby_archive, match_ruby_archive
Methods included from Base::ClassMethods
#add_merge_task, #add_task, #base_path, #clear, #docs_path, #entries, #inherited, #public_path, #remove_if_present, #short_name, #sources_path, #subclasses, #system, #tasks, #to_document, #used_sources, #with_env
Constructor Details
#initialize(raw_config) ⇒ Ruby
Returns a new instance of Ruby.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sdoc_all/parts/ruby.rb', line 6 def initialize(raw_config) raw_config ||= {} raw_config = {:version => raw_config} unless raw_config.is_a?(Hash) @config = { :update => raw_config.delete(:update) != false, :version => raw_config.delete(:version), :index => raw_config.delete(:index), :stdlib => raw_config.delete(:stdlib), } version = config[:version] unless version.present? raise ConfigError.new("specify version of ruby (place archive to 'sources' directory or it will be download from ftp://ftp.ruby-lang.org/)") end self.class.find_or_download_matching_archive(version) if config[:index] index = Pathname(config[:index]) unless index.directory? && (index + 'index.html').file? raise ConfigError.new("index should be a directory with index.html inside and all related files should be with relative links") end end if config[:stdlib] download_and_get_stdlib_config end (raw_config) end |
Instance Method Details
#add_tasks(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/sdoc_all/parts/ruby.rb', line 37 def add_tasks( = {}) archive = self.class.find_or_download_matching_archive(config[:version], :update => config[:update] && [:update]) version = archive.full_version src_path = sources_path + version unless src_path.directory? Base.remove_if_present(src_path) case archive.extension when 'tar.bz2' Base.system('tar', '-xjf', archive.path, '-C', sources_path) when 'tar.gz' Base.system('tar', '-xzf', archive.path, '-C', sources_path) when 'zip' Base.system('unzip', '-q', archive.path, '-d', sources_path) end File.rename(sources_path + "ruby-#{version}", src_path) end self.class.used_sources << src_path = { :src_path => src_path, :doc_path => "ruby-#{version}", :title => "ruby-#{version}" } [:index] = config[:index] if config[:index] Base.add_task() if config[:stdlib] stdlib_config = download_and_get_stdlib_config(:update => config[:update] && [:update]) stdlib_tasks = [] Dir.chdir(src_path) do main_files_to_document = get_files_to_document stdlib_config['targets'].each do |target| name = target['target'] paths = FileList.new paths.include("{lib,ext}/#{name}/**/README*") paths.include("{lib,ext}/#{name}.{c,rb}") paths.include("{lib,ext}/#{name}/**/*.{c,rb}") paths.resolve paths.reject! do |path| [%r{/extconf.rb\Z}, %r{/test/(?!unit)}, %r{/tests/}, %r{/sample}, %r{/demo/}].any?{ |pat| pat.match path } end if paths.present? && (paths - main_files_to_document).present? stdlib_tasks << { :src_path => src_path, :doc_path => name.gsub(/[^a-z0-9\-_]/i, '-'), :paths => paths.to_a, :main => target['mainpage'], :title => name } end end end Base.add_merge_task( :doc_path => "ruby-stdlib-#{version}", :title => "ruby-stdlib-#{version}", :tasks_options => stdlib_tasks.sort_by{ |task| task[:title].downcase } ) end end |