Module: Bdoc
- Defined in:
- lib/bdoc.rb
Constant Summary collapse
- VERSION =
'0.3.8'
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.
20 21 22 |
# File 'lib/bdoc.rb', line 20 def output_dir @output_dir end |
.output_index ⇒ Object
Returns the value of attribute output_index.
21 22 23 |
# File 'lib/bdoc.rb', line 21 def output_index @output_index end |
Class Method Details
.gems_with_doc_index ⇒ Object
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 |
# File 'lib/bdoc.rb', line 27 def gems_with_doc_index if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.7.0") installed_gems = Gem::Specification else installed_gems = Gem::SourceIndex.from_installed_gems.gems.map{|k,v|v} end 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.join(gem.full_gem_path,"..","..","doc",gem.full_name, "rdoc","index.html") { :version => gem.version.version, :rdoc_index => (File.exist?(rdoc_index) ? "file://"+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
57 58 59 60 61 62 63 64 |
# File 'lib/bdoc.rb', line 57 def generate_index @gems = gems_with_doc_index @gems_json = MultiJson.encode(@gems) index = ERB.new(File.read(File.join(File.dirname(__FILE__), '..', "templates","bdoc.html"))).result(binding) Dir.mkdir(output_dir) unless File.exists?(output_dir) File.open(output_index,"w:UTF-8") {|f| f.write(index)} end |
.open ⇒ Object
66 67 68 69 |
# File 'lib/bdoc.rb', line 66 def open generate_index Launchy.open("file:#{output_index}") end |
.rdoc_file(gem_name) ⇒ Object
23 24 25 |
# File 'lib/bdoc.rb', line 23 def rdoc_file(gem_name) File.join(Gem.dir, "doc", gem_name, "rdoc", "index.html") end |