In Files
Parent
- Component
Class Index
![show/hide quicksearch [+]](../../assets/icon/find.png)
- WebRI
- WebRI::Blackfish
- WebRI::Component
- WebRI::Generator
- WebRI::GeneratorOne
- WebRI::GitHub
- WebRI::Heirarchy
- WebRI::Highlight
- WebRI::Icons
- WebRI::JSONFile
- WebRI::Longfish
- WebRI::Metadata
- WebRI::Newfish
- WebRI::Oldfish
- WebRI::Onefish
- WebRI::Prettify
- WebRI::Redfish
- WebRI::RiService
- WebRI::Search
- WebRI::Search::FilesTree
- WebRI::Server
- WebRI::Subversion
- WebRI::Template
- WebRI::TimeDelta
- WebRI::Twofish
- RDoc
- RDoc::AnyMethod
- RDoc::ClassModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::TopLevel
- Syckle
- Syckle::Plugins
- Syckle::Plugins::WebRI
- Object
- OpEsc
GitHub
Public Instance Methods
github_url(path)
click to toggle source
# File lib/webri/components/github.rb, line 21 def github_url(path) unless github_url_cache.has_key? path github_url_cache[path] = false file = RDoc::TopLevel.find_file_named(path) if file base_url = repository_url(path) if base_url sha1 = commit_sha1(path) if sha1 relative_url = path_relative_to_repository(path) github_url_cache[path] = "#{base_url}#{sha1}#{relative_url}" end end end end github_url_cache[path] end
Protected Instance Methods
commit_sha1(path)
click to toggle source
(Not documented)
# File lib/webri/components/github.rb, line 46 def commit_sha1(path) name = File.basename(path) s = in_dir(File.join(path_base, File.dirname(path))) do `git log -1 --pretty=format:"commit %H" #{name}` end m = s.match(/commit\s+(\S+)/) m ? m[1] : false end
in_dir(dir)
click to toggle source
(Not documented)
# File lib/webri/components/github.rb, line 79 def in_dir(dir) pwd = Dir.pwd Dir.chdir dir return yield rescue Exception => e return '' ensure Dir.chdir pwd end
path_relative_to_repository(path)
click to toggle source
(Not documented)
# File lib/webri/components/github.rb, line 63 def path_relative_to_repository(path) absolute_path = File.join(path_base, path) root = path_to_git_dir(File.dirname(absolute_path)) absolute_path[root.size..absolute_path.size] end
path_to_git_dir(path)
click to toggle source
(Not documented)
# File lib/webri/components/github.rb, line 69 def path_to_git_dir(path) while !path.empty? && path != '.' if (File.exists? File.join(path, '.git')) return path end path = File.dirname(path) end '' end
repository_url(path)
click to toggle source
(Not documented)
# File lib/webri/components/github.rb, line 55 def repository_url(path) s = in_dir(File.join(path_base, File.dirname(path))) do `git config --get remote.origin.url` end m = s.match(%r{github.com[/:](.*)\.git$}) m ? "http://github.com/#{m[1]}/blob/" : false end
Disabled; run with --debug to generate this.