Module: Bdoc
- Defined in:
- lib/bdoc.rb
Constant Summary collapse
- VERSION =
'0.2.2.4'
Class Attribute Summary collapse
-
.output_dir ⇒ Object
Returns the value of attribute output_dir.
-
.output_index ⇒ Object
Returns the value of attribute output_index.
Class Method Summary collapse
Class Attribute Details
.output_dir ⇒ Object
Returns the value of attribute output_dir.
14 15 16 |
# File 'lib/bdoc.rb', line 14 def output_dir @output_dir end |
.output_index ⇒ Object
Returns the value of attribute output_index.
15 16 17 |
# File 'lib/bdoc.rb', line 15 def output_index @output_index end |
Class Method Details
.gems_with_doc_index ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bdoc.rb', line 21 def gems_with_doc_index installed_gems = Gem::SourceIndex.from_installed_gems.gems.map{|k,v|v} gems = installed_gems.map { |g| g.name if g.has_rdoc? }.compact.uniq.sort{|x,y| x.downcase <=> y.downcase} gems = gems.map do |g| gem = installed_gems.find_all{|gem| gem.name == g}.last { :name => g, :description => gem.description, :homepage => gem.homepage, :versions => installed_gems.find_all{|gem| gem.name == g }.map{|gem| rdoc_index = File.(File.join(gem.full_gem_path,"..","..","doc",gem.full_name, "rdoc","index.html")) { :version => gem.version.version, :rdoc_index => (File.exist?(rdoc_index) ? rdoc_index : nil) } #removes dups since uniq doesn't work on array of hashes }.compact.sort_by{|g|g[:version]}.inject([]){|result,h| result << h unless result.include?(h) result } } end end |
.generate_index ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/bdoc.rb', line 47 def generate_index @gems = gems_with_doc_index index = ERB.new(File.read(File.join(File.dirname(__FILE__), '..', "templates","index.html"))).result(binding) Dir.mkdir(output_dir) unless File.exists?(output_dir) File.open(output_index,"w") {|f| f.write(index)} FileUtils.cp File.join(File.dirname(__FILE__), '..', "templates","jquery.js"), output_dir FileUtils.cp File.join(File.dirname(__FILE__), '..', "templates","screen.css"), output_dir end |
.open ⇒ Object
56 57 58 59 |
# File 'lib/bdoc.rb', line 56 def open generate_index Launchy::Browser.run(output_index) end |
.rdoc_file(gem_name) ⇒ Object
17 18 19 |
# File 'lib/bdoc.rb', line 17 def rdoc_file(gem_name) File.join(Gem.dir, "doc", gem_name, "rdoc", "index.html") end |