Module: Bdoc
- Defined in:
- lib/bdoc.rb
Constant Summary collapse
- VERSION =
'0.3.0'
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
- .gems_with_doc_index ⇒ Object
- .generate_index ⇒ Object
- .open ⇒ Object
- .public_path ⇒ Object
- .rdoc_file(gem_name) ⇒ Object
- .render ⇒ Object
- .root ⇒ Object
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
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 |
# File 'lib/bdoc.rb', line 25 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.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
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bdoc.rb', line 55 def generate_index Dir.mkdir(output_dir) unless File.exists?(output_dir) # First just link the path if true Dir[File.join(public_path, '*')].each do |d| symlink_path = File.join(output_dir, File.basename(d)) File.symlink(d, symlink_path) unless File.symlink? symlink_path end end File.open(output_index,"w") {|f| f.write(render)} end |
.open ⇒ Object
73 74 75 76 |
# File 'lib/bdoc.rb', line 73 def open generate_index Launchy::Browser.run(output_index) end |
.public_path ⇒ Object
69 70 71 |
# File 'lib/bdoc.rb', line 69 def public_path File.join(root, 'public') end |
.rdoc_file(gem_name) ⇒ Object
21 22 23 |
# File 'lib/bdoc.rb', line 21 def rdoc_file(gem_name) File.join(Gem.dir, "doc", gem_name, "rdoc", "index.html") end |
.render ⇒ Object
51 52 53 |
# File 'lib/bdoc.rb', line 51 def render ERB.new(File.read(File.join(File.dirname(__FILE__), '..', "templates","index.html"))).result(binding) end |
.root ⇒ Object
17 18 19 |
# File 'lib/bdoc.rb', line 17 def root File. File.join(File.dirname(__FILE__), '..') end |