forked from cbeer/is_it_working
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from customink/drinks/callbacks
Implement Reporters
- Loading branch information
Showing
6 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module IsItWorking | ||
class Reporter | ||
attr_reader :name, :filters, :func | ||
|
||
def initialize(filters, func) | ||
@filters = filters | ||
@func = func | ||
end | ||
|
||
def report_on?(filter) | ||
filters.include? filter.name | ||
end | ||
|
||
def report(filter) | ||
func.call(filter.name, filter.status&.time.to_f) | ||
end | ||
|
||
class << self | ||
# Run reporters for each named filter in their respective lists | ||
def run_reporters(reporters, filters) | ||
reporters.each do |reporter| | ||
filters.each do |filter| | ||
reporter.report(filter) if reporter.report_on? filter | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module IsItWorking | ||
VERSION = '1.2.1'.freeze | ||
VERSION = '1.3.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters