Class: CodeHunter::RailsBestPractices::Summarizer
- Inherits:
-
Object
- Object
- CodeHunter::RailsBestPractices::Summarizer
- Defined in:
- lib/code_hunter/rails_best_practices/summarizer.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #content ⇒ Object
- #find_line(element) ⇒ Object
- #find_message(element) ⇒ Object
- #find_path(element) ⇒ Object
- #find_url(element) ⇒ Object
-
#initialize(options = {}) ⇒ Summarizer
constructor
A new instance of Summarizer.
- #summarize ⇒ Object
- #tree ⇒ Object
- #warning_elements ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Summarizer
Returns a new instance of Summarizer.
8 9 10 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 8 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 6 def @options end |
Instance Method Details
#content ⇒ Object
48 49 50 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 48 def content RailsBestPractices::TEMPORAL_PATHNAME.read end |
#find_line(element) ⇒ Object
24 25 26 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 24 def find_line(element) element.css(".line").text.strip.to_i end |
#find_message(element) ⇒ Object
32 33 34 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 32 def (element) element.css(".message").text.strip end |
#find_path(element) ⇒ Object
28 29 30 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 28 def find_path(element) element.css(".filename").text.strip end |
#find_url(element) ⇒ Object
36 37 38 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 36 def find_url(element) element.css("a").first.try(:attr, "href") end |
#summarize ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 12 def summarize warning_elements.map do |element| { :service => "rails_best_practices", :line => find_line(element), :path => find_path(element), :message => (element), :url => find_url(element), } end end |
#tree ⇒ Object
44 45 46 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 44 def tree Nokogiri.HTML(content) end |
#warning_elements ⇒ Object
40 41 42 |
# File 'lib/code_hunter/rails_best_practices/summarizer.rb', line 40 def warning_elements tree.css(".result tbody tr") end |