Class: BigBand::WebInspector::Middleware
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- BigBand::WebInspector::Middleware
- Defined in:
- lib/big_band/web_inspector.rb
Instance Attribute Summary collapse
-
#sinatra_app ⇒ Object
Returns the value of attribute sinatra_app.
Instance Method Summary collapse
-
#git? ⇒ Boolean
Whether or not this is a git project.
-
#git_directory ⇒ Object
If this is a git project, then it returns the path to the .git directory.
-
#git_log ⇒ Object
Recent git log.
-
#git_remotes ⇒ Object
Figures out some URLs to public git hosts by parsing the remote urls from the git config.
Methods inherited from Sinatra::Base
register, register_without_big_band
Instance Attribute Details
#sinatra_app ⇒ Object
Returns the value of attribute sinatra_app.
17 18 19 |
# File 'lib/big_band/web_inspector.rb', line 17 def sinatra_app @sinatra_app end |
Instance Method Details
#git? ⇒ Boolean
Whether or not this is a git project.
28 29 30 |
# File 'lib/big_band/web_inspector.rb', line 28 def git? !!git_directory end |
#git_directory ⇒ Object
If this is a git project, then it returns the path to the .git directory.
23 24 25 |
# File 'lib/big_band/web_inspector.rb', line 23 def git_directory @git_directory ||= root_glob(".{,.,./..,./../..}/.git").first end |
#git_log ⇒ Object
Recent git log.
45 46 47 48 49 50 51 |
# File 'lib/big_band/web_inspector.rb', line 45 def git_log @git_format ||= begin line = ["<a href='mailto:%ae'>%an</a>", "%s", "<date>%ai</date>"].map { |e| "<td>#{e}</td>" }.join "<tr>#{line}</tr>" end %x[git log -50 --pretty=format:"#{@git_format}"] end |
#git_remotes ⇒ Object
Figures out some URLs to public git hosts by parsing the remote urls from the git config. Currently detects: GitHub, Codaset and Gitorious.
34 35 36 37 38 39 40 41 42 |
# File 'lib/big_band/web_inspector.rb', line 34 def git_remotes @git_remotes ||= (File.read(git_directory / :config).scan(/\s*url\s*=\s*(.*)\n/).flatten.collect do |url| case url when %r{(github.com)[:/](.+)/(.+)/?\.git$} then [$3, "GitHub", "http://#$1/#$2/#$3", "http://#$1"] when %r{(codaset.com)[:/](.+)/(.+)?\.git$} then [$3, "Codaset", "http://#$1/#$2/#$3", "http://#$1"] when %r{(gitorious.org)[:/](.+)/.+/?\.git$} then [$2, "Gitorious", "http://#$1/#$2", "http://#$1"] end end).compact end |