Class: SdocAll::Rails
Constant Summary
Constants inherited from Base
Base::BASE_PATH, Base::DOCS_PATH, Base::PUBLIC_PATH
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #add_tasks(options = {}) ⇒ Object
- #get_paths(app_dir) ⇒ Object
-
#initialize(raw_config) ⇒ Rails
constructor
A new instance of Rails.
Methods inherited from Base
add_merge_task, add_task, base_path, chdir, clear, dirs, docs_path, dry_run!, dry_run?, entries, inherited, output_for_verbose_level, public_path, remove_if_present, short_name, sources_path, subclasses, system, tasks, to_document, used_sources, verbose_level, verbose_level=, with_env
Constructor Details
#initialize(raw_config) ⇒ Rails
Returns a new instance of Rails.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sdoc_all/parts/rails.rb', line 3 def initialize(raw_config) raw_config ||= {} raw_config = {:version => raw_config} unless raw_config.is_a?(Hash) if raw_config[:version] if self.class.versions(raw_config[:version]).empty? raise ConfigError.new("you don't have rails #{raw_config[:version]} installed") end else if self.class.versions.empty? raise ConfigError.new("you don't have any rails versions installed") end end @config = { :version => self.class.versions(raw_config.delete(:version)).last, } (raw_config) end |
Class Method Details
.versions(version_string = nil) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/sdoc_all/parts/rails.rb', line 71 def versions(version_string = nil) [].tap do |versions| Gem.source_index.search(Gem::Dependency.new('rails', version_string)).each do |spec| versions << spec.version end end.sort end |
Instance Method Details
#add_tasks(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sdoc_all/parts/rails.rb', line 24 def add_tasks( = {}) version = config[:version] path = sources_path + "r#{version}" unless path.directory? Base.remove_if_present(path) sources_path Base.with_env 'VERSION', version.to_s do if version.to_s[/\d+/].to_i < 3 Base.system('rails', "_#{version}_", path) Base.chdir(path) do Base.system('rake', 'rails:freeze:gems') end else Base.system('rails', "_#{version}_", 'new', path) end end end self.class.used_sources << path Base.add_task( :src_path => path, :doc_path => "rails-#{version}", :paths => get_paths(path), :title => "rails-#{version}" ) end |
#get_paths(app_dir) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sdoc_all/parts/rails.rb', line 52 def get_paths(app_dir) code = %{ require 'rubygems' require 'rake' require 'rake/rdoctask' Rake::RDocTask.class_eval{ def define; puts rdoc_files if name == 'rails'; end } class RDocTaskWithoutDescriptions < Rake::RDocTask def initialize(name = :rdoc); super; puts rdoc_files if name == 'rails'; end end Dir.chdir(ARGV.first){ load('Rakefile') } }.strip.gsub(/\s*\n\s*/m, '; ') args = 'ruby', '-e', code, app_dir.to_s IO.popen(args.shelljoin, &:readlines).map(&:strip) end |