Class: SdocAll::Plugins
Constant Summary
Constants inherited from Base
Base::BASE_PATH, Base::DOCS_PATH, Base::PUBLIC_PATH
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add_tasks(options = {}) ⇒ Object
-
#initialize(raw_config) ⇒ Plugins
constructor
A new instance of Plugins.
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) ⇒ Plugins
Returns a new instance of Plugins.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/sdoc_all/parts/plugins.rb', line 3 def initialize(raw_config) raw_config ||= {} raw_config = {:path => raw_config} unless raw_config.is_a?(Hash) raw_config[:path] ||= sources_path @config = { :update => raw_config.delete(:update) != false, :path => Pathname.new(raw_config.delete(:path))., :only => config_only_option(raw_config), :exclude => config_exclude_option(raw_config), } unless config[:path].directory? raise ConfigError.new("path #{config[:path]} is not a directory") end (raw_config) end |
Instance Method Details
#add_tasks(options = {}) ⇒ Object
23 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sdoc_all/parts/plugins.rb', line 23 def add_tasks( = {}) plugins = config[:path].children.select(&:directory?).select(&:visible?) plugins.delete_if{ |plugin| !config[:only].include?(plugin.basename.to_s.downcase) } if config[:only] plugins.delete_if{ |plugin| config[:exclude].include?(plugin.basename.to_s.downcase) } if config[:update] && [:update] plugins.each do |plugin| if (plugin + '.git').directory? Base.chdir(plugin) do Base.system('git fetch origin && git reset --hard origin') end end end end plugins.each do |plugin| paths = FileList.new Base.chdir(plugin) do paths.include('lib/**/*.rb') paths.include('README*') paths.include('CHANGELOG*') begin File.open('Rakefile') do |f| true until f.readline['Rake::RDocTask'] until ['end', '}'].include?(line = f.readline.strip) globs = line.scan(/'([^']*)'/).map{ |match| match[0] } if line['include('] paths.include(*globs) elsif line['exclude('] paths.exclude(*globs) end end end rescue end paths.resolve end Base.add_task( :src_path => plugin, :doc_path => "plugins.#{plugin.basename}", :paths => paths.to_a, :title => "plugins: #{plugin.basename}" ) end end |