Class: Stefon::Editor
- Inherits:
-
Object
- Object
- Stefon::Editor
- Defined in:
- lib/stefon/surveyor/editor.rb
Overview
The editor is responsible for forming a team of surveyors and asking for and combining their results. The editor decides what story to run, i.e. to print recommendations or why recommendations are impossible
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#team ⇒ Object
readonly
Returns the value of attribute team.
Instance Method Summary collapse
- #combine_full_reports ⇒ Object
- #combine_short_reports ⇒ Object
- #full_report ⇒ Object
-
#initialize(options) ⇒ Editor
constructor
A new instance of Editor.
- #short_report ⇒ Object
- #summarize_results ⇒ Object
Constructor Details
#initialize(options) ⇒ Editor
Returns a new instance of Editor.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/stefon/surveyor/editor.rb', line 11 def initialize() @options = # currently unused @errors = [] # The editor has a team of surveyors, and tells them their importance @team = [ Surveyor::AddedFiles.new([:added_file]), Surveyor::AddedLines.new([:added_line]), Surveyor::DeletedFiles.new([:deleted_file]), Surveyor::DeletedLines.new([:deleted_line]) ] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
9 10 11 |
# File 'lib/stefon/surveyor/editor.rb', line 9 def errors @errors end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
8 9 10 |
# File 'lib/stefon/surveyor/editor.rb', line 8 def @options end |
#team ⇒ Object (readonly)
Returns the value of attribute team.
8 9 10 |
# File 'lib/stefon/surveyor/editor.rb', line 8 def team @team end |
Instance Method Details
#combine_full_reports ⇒ Object
34 35 36 37 38 |
# File 'lib/stefon/surveyor/editor.rb', line 34 def combine_full_reports @team.reduce(Surveyor::SurveyorStore.new([])) do |a, e| a.merge_scores(e.call_verbose) end end |
#combine_short_reports ⇒ Object
24 25 26 27 28 |
# File 'lib/stefon/surveyor/editor.rb', line 24 def combine_short_reports @team.reduce(Surveyor::SurveyorStore.new) do |a, e| a.merge_scores(e.call) end end |
#full_report ⇒ Object
40 41 42 43 |
# File 'lib/stefon/surveyor/editor.rb', line 40 def full_report # sort by the scores combine_full_reports.sort_by { |k, v| -combine_short_reports[k] } end |
#short_report ⇒ Object
30 31 32 |
# File 'lib/stefon/surveyor/editor.rb', line 30 def short_report combine_short_reports.sort_by { |k, v| -v } end |
#summarize_results ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/stefon/surveyor/editor.rb', line 45 def summarize_results if @options[:full_report] full_report.first(@options[:limit]).map(&:last).flatten else short_report.first(@options[:limit]).map(&:first).flatten end end |