Class: GenericReport
- Inherits:
-
Object
- Object
- GenericReport
- Defined in:
- lib/pqa.rb
Direct Known Subclasses
ErrorReport, MostFrequentQueriesReport, OverallStatsReport, ParseErrorReport, QueriesByTypeReport, QueriesThatTookUpTheMostTimeReport, SlowestQueriesReport
Instance Method Summary collapse
- #applicable ⇒ Object
- #colorize(txt) ⇒ Object
-
#initialize(log) ⇒ GenericReport
constructor
A new instance of GenericReport.
- #pctg_of(a, b) ⇒ Object
- #round(x, places) ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(log) ⇒ GenericReport
Returns a new instance of GenericReport.
864 865 866 |
# File 'lib/pqa.rb', line 864 def initialize(log) @log = log end |
Instance Method Details
#applicable ⇒ Object
890 891 892 |
# File 'lib/pqa.rb', line 890 def applicable true end |
#colorize(txt) ⇒ Object
868 869 870 871 872 873 874 875 876 |
# File 'lib/pqa.rb', line 868 def colorize(txt) ["SELECT","UPDATE","INSERT INTO","DELETE","WHERE","VALUES","FROM","AND","ORDER BY","GROUP BY","LIMIT", "OFFSET", "DESC","ASC","AS","EXPLAIN","DROP","EXEC"].each {|w| txt = txt.gsub(Regexp.new(w), "<span class='keyword'>#{w}</span>") } ["select","update","from","where","explain","drop"].each {|w| txt = txt.gsub(Regexp.new(w), "<span class='keyword'>#{w}</span>") } txt end |
#pctg_of(a, b) ⇒ Object
882 883 884 |
# File 'lib/pqa.rb', line 882 def pctg_of(a,b) a > 0 ? (((a.to_f/b.to_f)*100.0).round)/100.0 : 0 end |
#round(x, places) ⇒ Object
886 887 888 |
# File 'lib/pqa.rb', line 886 def round(x, places) (x * 10.0 * places).round / (10.0 * places) end |
#title ⇒ Object
878 879 880 |
# File 'lib/pqa.rb', line 878 def title "Unnamed report" end |